ref: 833d2a6fada91ac6db51ac489a0a07a4c70bb2e7
parent: f1e1171eef004a7073a543989bf5151472826929
author: Tor Andersson <tor@ccxvii.net>
date: Wed Jan 22 13:01:53 EST 2014
Fix parser bug.
--- a/jsparse.c
+++ b/jsparse.c
@@ -848,13 +848,13 @@
return statement(J);
}
-static js_Ast *script(js_State *J)
+static js_Ast *script(js_State *J, int terminator)
{
js_Ast *head, *tail;
- if (J->lookahead == '}' || J->lookahead == 0)
+ if (J->lookahead == terminator)
return NULL;
head = tail = LIST(scriptelement(J));
- while (J->lookahead != '}' && J->lookahead != 0)
+ while (J->lookahead != terminator)
tail = tail->b = LIST(scriptelement(J));
return jsP_list(head);
}
@@ -863,7 +863,7 @@
{
js_Ast *a;
expect(J, '{');
- a = script(J);
+ a = script(J, '}');
expect(J, '}');
return a;
}
@@ -949,7 +949,7 @@
jsY_initlex(J, filename, source);
next(J);
- p = script(J);
+ p = script(J, 0);
if (p)
jsP_foldconst(p);