Skip to content

Commit

Permalink
[parser] check for Eof
Browse files Browse the repository at this point in the history
see #11368
  • Loading branch information
Simn committed Nov 10, 2023
1 parent e6442b2 commit 5432abb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/syntax/grammar.mly
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ let check_redundant_var p1 = parser

let parsing_macro_cond = ref false

let rec parse_file s =
let rec parse_file s =
last_doc := None;
match s with parser
| [< '(Kwd Package,_); pack = parse_package; s >] ->
Expand Down
8 changes: 8 additions & 0 deletions src/syntax/parserEntry.ml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ let parse entry ctx code file =
) in
try
let l = entry s in
begin match Stream.peek s with
| None ->
() (* Eof could already have been consumed *)
| Some (Eof,_) ->
() (* This is what we want *)
| Some (tok,p) ->
error (Unexpected tok) p (* This isn't *)
end;
let was_display_file = !in_display_file in
restore();
Lexer.restore old;
Expand Down

0 comments on commit 5432abb

Please sign in to comment.