Skip to content

Commit d806209

Browse files
committed
Ignore trailing trivia in Core parser hook
For compatibility with the flisp parser, we must consume any trailing whitespace at the end of a string. Otherwise Meta.parse() will fail unnecessarily when parsing a single statement.
1 parent 9606d96 commit d806209

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/hooks.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ function core_parser_hook(code, filename, lineno, offset, options)
2525
stream = ParseStream(io)
2626
rule = options === :all ? :toplevel : options
2727
if rule !== :toplevel
28-
# To copy the flisp parser driver, we ignore leading trivia when
29-
# parsing statements or atoms
28+
# To copy the flisp parser driver, we ignore leading and trailing
29+
# trivia when parsing statements or atoms
3030
bump_trivia(stream)
3131
end
3232
JuliaSyntax.parse(stream; rule=rule)
33+
if rule !== :toplevel
34+
bump_trivia(stream)
35+
end
3336

3437
if any_error(stream)
3538
e = Expr(:error, ParseError(SourceFile(code), stream.diagnostics))

0 commit comments

Comments
 (0)