ref: 157e30c5b46fb90e193c2a15d7a9b6a1b7bce13c
parent: 5ead782e99fbde515d96284738a24662b833311e
author: Tor Andersson <tor@ccxvii.net>
date: Thu Jan 9 11:58:31 EST 2014
Handle "exp [NLTH] ++" case in parser rather than lexer.
--- a/js-lex.c
+++ b/js-lex.c
@@ -495,7 +495,7 @@
case '+':
if (LOOK('+'))
- return J->newline ? TK_INC : TK_NLTH_INC;
+ return TK_INC;
if (LOOK('='))
return TK_ADD_ASS;
return '+';
@@ -502,7 +502,7 @@
case '-':
if (LOOK('-'))
- return J->newline ? TK_DEC : TK_NLTH_DEC;
+ return TK_DEC;
if (LOOK('='))
return TK_SUB_ASS;
return '-';
--- a/js-parse.c
+++ b/js-parse.c
@@ -281,8 +281,8 @@
static js_Ast *postfix(js_State *J)
{
js_Ast *a = callexp(J);
- if (accept(J, TK_NLTH_INC)) return EXP1(POSTINC, a);
- if (accept(J, TK_NLTH_DEC)) return EXP1(POSTDEC, a);
+ if (!J->newline && accept(J, TK_INC)) return EXP1(POSTINC, a);
+ if (!J->newline && accept(J, TK_DEC)) return EXP1(POSTDEC, a);
return a;
}
@@ -291,8 +291,8 @@
if (accept(J, TK_DELETE)) return EXP1(DELETE, unary(J));
if (accept(J, TK_VOID)) return EXP1(VOID, unary(J));
if (accept(J, TK_TYPEOF)) return EXP1(TYPEOF, unary(J));
- if (accept(J, TK_INC) || accept(J, TK_NLTH_INC)) return EXP1(PREINC, unary(J));
- if (accept(J, TK_DEC) || accept(J, TK_NLTH_DEC)) return EXP1(PREDEC, unary(J));
+ if (accept(J, TK_INC)) return EXP1(PREINC, unary(J));
+ if (accept(J, TK_DEC)) return EXP1(PREDEC, unary(J));
if (accept(J, '+')) return EXP1(POS, unary(J));
if (accept(J, '-')) return EXP1(NEG, unary(J));
if (accept(J, '~')) return EXP1(BITNOT, unary(J));
--- a/js-parse.h
+++ b/js-parse.h
@@ -33,9 +33,7 @@
TK_OR_ASS,
TK_XOR_ASS,
TK_INC,
- TK_NLTH_INC,
TK_DEC,
- TK_NLTH_DEC,
/* keywords */
TK_BREAK,