diff options
-rw-r--r-- | byterun/lexing.c | 6 | ||||
-rw-r--r-- | parsing/parse.ml | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/byterun/lexing.c b/byterun/lexing.c index 3efd46804..c5155587e 100644 --- a/byterun/lexing.c +++ b/byterun/lexing.c @@ -78,7 +78,6 @@ value lex_engine(tbl, start_state, lexbuf) /* ML */ return Val_int(-state - 1); }else{ c = 256; - lexbuf->lex_eof_reached = Val_int (0); } }else{ /* Read next input char */ @@ -98,6 +97,11 @@ value lex_engine(tbl, start_state, lexbuf) /* ML */ } else { return lexbuf->lex_last_action; } + }else{ + /* Erase the EOF condition only if the EOF pseudo-character was + consumed by the automaton (i.e. there was no backtrack above) + */ + if (c == 256) lexbuf->lex_eof_reached = Val_int (0); } } } diff --git a/parsing/parse.ml b/parsing/parse.ml index 0908b0804..d59fc3da4 100644 --- a/parsing/parse.ml +++ b/parsing/parse.ml @@ -21,8 +21,10 @@ let rec skip_phrase lexbuf = match Lexer.token lexbuf with Parser.SEMISEMI | Parser.EOF -> () | _ -> skip_phrase lexbuf - with Lexer.Error(_,_,_) -> - skip_phrase lexbuf + with + | Lexer.Error (Lexer.Unterminated_comment, _, _) -> () + | Lexer.Error (Lexer.Unterminated_string, _, _) -> () + | Lexer.Error(_,_,_) -> skip_phrase lexbuf let maybe_skip_phrase lexbuf = if Parsing.is_current_lookahead Parser.SEMISEMI |