[antlr-interest] [v3] Help on CFScript Parser - Help on recursive rules
Mark Mandel
mark.mandel at gmail.com
Sun May 13 01:51:53 PDT 2007
Never mind, I think I've got it covered.
There seems to be some differences between what ANTLR actually does,
and what shows up in ANTLRWorks.
Otherwise, ANTLRWorks is a great product.
Mark
On 5/13/07, Mark Mandel <mark.mandel at gmail.com> wrote:
> All,
>
> I'm building a CFScript (think lightweight javascript) parser, which
> will eventually get blown into a ColdFusion parser, but I'm getting
> stuck on statements like this;
>
> var object = getObjectManager().getObject(arguments.transfer.getClassName());
>
> The code that ANTLR throws a wobbly on is:
>
> codeStatement
> :
> code (DOT code)*
> ;
>
> code
> :
> IDENTIFIER | function
> ;
>
> function
> :
> IDENTIFIER OPEN_PAREN (argumentStatement)? CLOSE_PAREN
> CLOSE_PAREN)
> ;
>
> argumentStatement
> :
> codeStatement (COMMA codeStatement)*
> ;
>
> Now, essentially, the grammar is true - and argument can be a
> codeStatement... but that gives multiple paths back to the same
> rule... so I don't know how I can set something like this up?
>
> Is there where backtracking is required. I can't seem to find a
> example of backtracking that I can understand, so I'm not sure how to
> go about using it. I've been following some parts of the Java 5
> grammar, but this bit I can't work out.
>
> I've attached my full grammar as it currently stands, for further reference.
>
> Any help would be appreciated,
>
> Thanks,
>
> Mar
>
> --
> E: mark.mandel at gmail.com
> W: www.compoundtheory.com
>
>
--
E: mark.mandel at gmail.com
W: www.compoundtheory.com
More information about the antlr-interest
mailing list