[antlr-interest] Have I found an Antlr CSharp3 lexer bug if...
chris king
kingces95 at gmail.com
Thu Jul 28 14:18:59 PDT 2011
Have I found an Antlr lexer CSharp3 bug if I can alter program execution
(exception instead of no exception) by introducing a lexer production with a
predicate that is always false? For example
PP_SKIPPED_CHARACTERS
: { false }? ( ~(F_NEW_LINE_CHARACTER | '#') F_INPUT_CHARACTER* F_NEW_LINE
)*
;
I would think that such a production should always be ignored because it's
predicate is always false and therefore would never alter program execution.
Yet I'm seeing a change in the execution of my program. I'm seeing it enter
this function and throw a FailedPredicateException. I wouldn't have expected
that this function should ever even have been executed because the predicate
is always false.
[GrammarRule("PP_SKIPPED_CHARACTERS")]
private void mPP_SKIPPED_CHARACTERS()
{
EnterRule_PP_SKIPPED_CHARACTERS();
EnterRule("PP_SKIPPED_CHARACTERS", 31);
TraceIn("PP_SKIPPED_CHARACTERS", 31);
try
{
int _type = PP_SKIPPED_CHARACTERS;
int _channel = DefaultTokenChannel;
// CSharp\\CSharpPreProcessor.g:197:3: ({...}? (~ ( F_NEW_LINE_CHARACTER |
F_POUND_SIGN ) ( F_INPUT_CHARACTER )
DebugEnterAlt(1);
// CSharp\\CSharpPreProcessor.g:197:5: {...}? (~ ( F_NEW_LINE_CHARACTER |
F_POUND_SIGN ) ( F_INPUT_CHARACTER )
{
DebugLocation(197, 5);
if (!(( false )))
{
throw new FailedPredicateException(input, "PP_SKIPPED_CHARACTERS", " False()
");
}
Sam, I'm on an all CSharp stack v3.3.1.7705. I'm using your VS plugin (which
is wonderful) and build integration to generate the lexer/parser (also
wonderful) and then running on top of your CSharp port of the runtime. If
you think this is a bug and you'd like to have a look at the repro please
let me know. The project is open source up on CodePlex.
Thanks,
Chris
More information about the antlr-interest
mailing list