-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report EmptyStackException as error #2006
Comments
This looks more like a parser activity than a lexer one, and using a parser you can customise error handling to your articular needs. |
I think adding an error message with correct recovery to the outermost mode (DEFAULT) is more expected and pleasant behavior. |
|
ok, i'll hang until you have a proposed fix. |
…mpty stack exception, fixes antlr#2006 Fixed for Java, C#, Python2/3, JavaScript, Go runtimes Need to be fixed: C++, Swift, Dart, PHP
…mpty stack exception, fixes antlr#2006 Fixed for Java, C#, Python2/3, JavaScript, Go runtimes Need to be fixed: C++, Swift, Dart, PHP
…mpty stack exception, fixes antlr#2006 Fixed for Java, C#, Python2/3, JavaScript, Go, Dart runtimes Need to be fixed: C++, Swift, PHP
…mpty stack exception, fixes antlr#2006 Fixed for Java, C#, Python2/3, JavaScript, Go, Dart runtimes Need to be fixed: C++, Swift, PHP
…mpty stack exception, fixes antlr#2006 Fixed for Java, C#, Python2/3, JavaScript, Go, Dart, Swift runtimes Need to be fixed: C++, PHP
I have written a C-like language grammar using
'{' '}'
for nesting blocks.The lexer pushes the
DEFAULT_MODE
on'{'
and pops it on'}'
I'm using this "trick" for parsing embedded expressions in strings (island language),
like so:
"xxx{a+b}xx"
.Now when the input is not nested well, a
EmptyStackException
will fire during parsing.Consider the following pseudo token stream:
Here is the call stack:
An error message with the token position would be helpful, instead of the exception.
Maybe the lexer should recover after the exception (in
DEFAULT_MODE
).The text was updated successfully, but these errors were encountered: