[antlr-interest] Newbe bug: Why are these two code snippets not equivalent?

chris king kingces95 at gmail.com
Thu Jul 28 01:28:37 PDT 2011


Hello antlr-interest! So I'm working on my C# pre-processor and I'm trying
to implement the skipping #ifdefed code in the lexer when I ran across this.
I expected


PP_SKIPPED_CHARACTERS
  : //{ false }? ( ~(F_NEW_LINE_CHARACTER | '#') F_INPUT_CHARACTER*
F_NEW_LINE )*
  ;


to be equivalent to


PP_SKIPPED_CHARACTERS
  : { false }? ( ~(F_NEW_LINE_CHARACTER | '#') F_INPUT_CHARACTER* F_NEW_LINE
)*
  ;

but I'm seeing different runtime behavior. So I guess I don't understand
what the { false }? syntax is all about. I know there are probably other
ways to implement the #ifdefed logic but could someone enlighten me as to
why these two bits of code are not equivalent?

Thanks,
Chris


More information about the antlr-interest mailing list