6/1/2010 3:33 PM keltezéssel, Nathan Eloe írta:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello all,
> I'm working on an AST parser for the Bash language and I've come across the
> following strange behavior:
> I'm trying to handle comments, so I used the comments token you can get when
> you start a new grammar in ANTLRworks. It works.
>
> COMMENT
> : '#' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
> ;
>
> The problem arises when the comment is the last thing from the input (i.e, no
> new line before EOF). Removing the '\n' from the token causes it to freak
> out when I run the tests, but I can't get it to match comments at the end of
> file. Leaving that '\n' in lets the code compile, but I still can't match
> that last case.
>
> Here's where the interesting part happens. When I run it through the
> debugger with the same test case that I use in gunit, the debugger allows the
> input and parses it correctly (meaning, it ignores it as it should) and
> correctly generates the expected AST.
>
> Does the debugger allow the code to be more robust in its decision making
> abilities? Or does it do something to the input to allow it to be matched to
> a token.
>
> Thanks for the help!
>
> Nathan
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
>
> iEYEARECAAYFAkwFDBsACgkQFpoRlVgtqKZHIgCfRWHiKc6fr51t7tHT1xtxlVYG
> s9sAmwak2ZHv3XPVPeMgwYNDbqhXJztq
> =2bxk
> -----END PGP SIGNATURE-----
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>
What about
COMMENT
: '#' ~('\n'|'\r')* ('\r'? '\n')? {$channel=HIDDEN;}
;
?
Have you tried that?
Marton Papp
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.