From f2bea0fc0f861d28485ff4ef59974461808599a9 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 3 Jun 2014 21:15:45 +1000 Subject: [PATCH] Scanner: parsing of comments and strings must recognise end-of-node If the file does not end in a newline, then a node might not also. This requires a little more care in parsing strings and comments. Signed-off-by: NeilBrown --- csrc/scanner.mdc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/csrc/scanner.mdc b/csrc/scanner.mdc index ecc202b..37b336f 100644 --- a/csrc/scanner.mdc +++ b/csrc/scanner.mdc @@ -450,7 +450,8 @@ followed by the start of a new string. * unget so the newline is seen, * but return rest of string as an error. */ - unget_char(state); + if (is_newline(ch)) + unget_char(state); close_token(state, &tk); tk.num = TK_error; return tk; @@ -484,14 +485,18 @@ If `TK_string` is ignored, then quote characters will appear as `TK_mark`s. !(ignored & (1<