From e928c1410c38c4befb60f103c4246323f2a59e02 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 28 Dec 2013 12:55:44 +0100 Subject: [PATCH] Set newline flag if a token is preceded by a line terminator. --- js-lex.c | 5 ++++- js-parse.h | 2 +- js.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js-lex.c b/js-lex.c index ff64e6b..d8f3e01 100644 --- a/js-lex.c +++ b/js-lex.c @@ -346,6 +346,8 @@ static int lexregexp(js_State *J, const char **sp) static int lex(js_State *J, const char **sp) { + J->newline = 0; + while (1) { int c = GET(); @@ -357,7 +359,8 @@ static int lex(js_State *J, const char **sp) if (c == '\r' && PEEK() == '\n') NEXT(); J->yyline++; - return TK_NEWLINE; + J->newline = 1; + continue; } if (c == '/') { diff --git a/js-parse.h b/js-parse.h index b9bea35..82fb17f 100644 --- a/js-parse.h +++ b/js-parse.h @@ -3,7 +3,7 @@ enum { TK_ERROR = 257, - TK_NEWLINE, + TK_IDENTIFIER, TK_NUMBER, TK_STRING, diff --git a/js.h b/js.h index bf3a605..6e33654 100644 --- a/js.h +++ b/js.h @@ -35,6 +35,7 @@ struct js_State struct { int g, i, m; } yyflags; int yyline; int lasttoken; + int newline; int strict; };