[antlr-interest] Comments, EOF, and Debugger
Jim Idle
jimi at temporal-wave.com
Tue Jun 1 11:33:37 PDT 2010
Remember antlr.markmail.org. The simplest way to deal with this is to
add a newline to your input before parsimg it.
Jim
On Jun 1, 2010, at 6:33, Nathan Eloe <powerofazure at gmail.com> wrote:
> -----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
More information about the antlr-interest
mailing list