- changed status to open
Some invalid symbols get ignored
The following code compiles without errors, and outputs 43. The invalid characters seems to be ignored.
testVar§$!=€@42; say "test", "$testVar";
Comments (9)
-
-
- changed milestone to 3.0.1
-
- marked as major
This can cause unintended behavior, e.g. when confusing
!=
with~=
. -
I can't seem to get ANTLR to actually recognize these characters to be there; they're just ignored. Has to be investigated further why this is a thing.
-
- changed milestone to Future
-
- changed milestone to 3.0.5
- changed component to MobTalkerScript
-
assigned issue to
-
It appears that ANTLR does recognize the invalid characters correctly. For example, when running the following script in the Interactive Console…
testVar§$!=€@42; print(testVar)
…, the following errors are printed to the console…
line 1:7 token recognition error at: '§' line 1:8 token recognition error at: '$' line 1:9 token recognition error at: '!' line 1:11 token recognition error at: '€' line 1:12 token recognition error at: '@'
…and the script prints
42
to the output afterwards.Hence, it seems that the error recovery setting of the ANTLR lexer/parser only prints error to stderr without raising any errors in the Java code.
I’m not sure if MTS sets the error recovery manually. Let’s dive into the code.
-
Issue is caused by the
Mts3Lexer
instance only having its default error listener (which prints any errors to stderr and continues as if nothing happened). By adding a custom error handler which functions similarly to the existingMtsAntlrErrorListener
class, this issue can be prevented. -
- changed status to resolved
Add error listener to ANTLR lexer (fixes
#29)Renamed MtsAntlrErrorListener to MtsParserErrorListener for clarity
→ <<cset 9ebc48d65496>>
- Log in to comment