[antlr-interest] Have I found an Antlr CSharp3 lexer bug if...
chris king
kingces95 at gmail.com
Thu Aug 4 01:48:20 PDT 2011
Sam, while trying build my pre-processor with a mixed parser/lexer I ran
across what I think might be a bug. I reduced the repro below. I expected
the program below to accept "/**/ " but instead fails because the lexer
prediction enters PP_SKIPPED_CHARACTERS. That rule has a gated semantic
predicate which is always false. I expected a lexer rule with a gated
semantic predicate which is always false to never be matched. If I comment
out the PP_SKIPPED_CHARACTERS rule then it does match "/**/ ". So the
inclusion of that rule is cause the problem. Let me know if you think this
is a bug and if you can repro.
Thanks,
Chris
grammar Bug;
options {
language=CSharp3;
output=AST;
}
public start
: DELIMITED_COMMENT !EOF
;
PP_SKIPPED_CHARACTERS
: { false }? => ~(F_NEW_LINE_CHARACTER | F_PP_POUND_SIGN)
F_INPUT_CHARACTER*
;
DELIMITED_COMMENT
: { true }? => '/*' .* '*/'
;
WHITESPACE
: F_WHITESPACE {skip();}
;
fragment F_WHITESPACE
: (' ' | '\t' | '\v' | '\f')+
;
fragment F_NEW_LINE_CHARACTER
: '\r'
| '\n'
;
fragment F_PP_POUND_SIGN
: '#'
;
fragment F_INPUT_CHARACTER
: ~F_NEW_LINE_CHARACTER
;
More information about the antlr-interest
mailing list