[antlr-interest] Re: How to make antlr parse this
Mark
markl at glyphic.com
Fri Apr 16 08:09:48 PDT 2004
First: recognize that, for the parser, javadocComment and invariantCondition are identical
parses - there is no way to tell them apart with any lookahead or syntatic predicates.
Second: this means your grammar:
> compilationUnit
> :
> (javadocComment)*
> (package)?
> (javadocComment | import)*
> ( (invariantCondition)* typeDefinition)*
> EOF
is basically the same as:
u : (c)* (p)? (c|i)* ((c)* t)* ;
Consider this sequence: c c c t
How many of those comments (c) should be used to match (c|i)*? how many should be
used to match ((c)* t)*?
The grammar is non-deterministic because your specification is. Once you decide hoe you
want to resolve the above ambiguity, then you can write a non-deterministic grammar for
it,
- Mark
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list