[antlr-interest] Re: How to make antlr parse this

Jon Schewe jpschewe at mtu.net
Fri Apr 16 05:37:58 PDT 2004


Apparently that's still non-deterministic.  

Line 329 is (javaDocComment | import)*
ANTLR Parser Generator   Version 2.7.3   1989-2004 jGuru.com
java.g:329: warning:nondeterminism upon
java.g:329:     k==1:JAVADOC_OPEN
java.g:329:    
k==2:JAVADOC_CLOSE,POST_CONDITION,PRE_CONDITION,ASSERT_CONDITION,INVARIANT_CONDITION
java.g:329:     between alt 1 and exit branch of block

On Thu, 2004-04-15 at 23:10, lgcraymer wrote:
> Try something like
> 
> compilationUnit
>     :
>     (   ( (javaDocComment)* package )=> (javaDocComment)* package
>     |
>     )
>     (javaDocComment | import)*
>     ( (invariantCondition)* typeDefinition)*
>     EOF
>     ;
>     
> --Loring
> 
> 
> --- In antlr-interest at yahoogroups.com, Jon Schewe <jpschewe at m...> wrote:
> > I asked this question back in October of 2000 and never got an answer. 
> > I've worked on it on and off (mostly off) since then and have not come
> > up with an answer.  I've updated to antlr 2.7.3 hoping that it'd be
> > better at this, but still haven't gotten it working.  
> > 
> > So here's the question again to see if anyone else can figure it out.
> > 
> > The structure of the file is as follows:
> > 
> > compilationUnit
> >   :
> > (javadocComment)*
> > (package)?
> > (javadocComment | import)*
> > ( (invariantCondition)* typeDefinition)*
> > EOF
> > 
> > /**
> >    This is a javadoc comment that we're not looking for any conditions
> > in.
> > **/
> > javadocComment
> >   : JAVADOC_OPEN ( INVARIANT_CONDITION | PRE_CONDITION | POST_CONDITION
> > | ASSERT_CONDITION )* JAVADOC_CLOSE
> >   ;
> > 
> > /**
> >    This is a javadoc comment that we're looking for invariants in.
> > **/
> > invariantCondition
> >   : JAVADOC_OPEN ( iv:INVARIANT_CONDITION { addInvariant(iv); } |
> > PRE_CONDITION | POST_CONDITION | ASSERT_CONDITION )* JAVADOC_CLOSE
> >   ;
> > 
> > Basically it's a Java grammar, where the javadoc comments are
> > important.  I've gotten past the lexer by using two lexers, one for
> > inside comments and one for everything else.  That gives me a nice token
> > stream, but I just can't seem to get past the top rule above.  If I
> > don't allow comments anywhere above typeDefinition and require that
> > typeDefiniation exists, it'll compile and go.  However I want to allow
> > comments above typeDefinition and I want to allow a file that's
> > commented out with single line comments (thus no type definition).
> > 
> > Thanks for any help you can provide.
> > -- 
> > Jon Schewe | http://mtu.net/~jpschewe
> > GPG signature at http://mtu.net/~jpschewe/gpg.sig.html
> > For I am convinced that neither death nor life, neither angels 
> > nor demons, neither the present nor the future, nor any 
> > powers, neither height nor depth, nor anything else in all 
> > creation, will be able to separate us from the love of God that 
> > is in Christ Jesus our Lord. - Romans 8:38-39
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
-- 
Jon Schewe | http://mtu.net/~jpschewe
GPG signature at http://mtu.net/~jpschewe/gpg.sig.html
For I am convinced that neither death nor life, neither angels 
nor demons, neither the present nor the future, nor any 
powers, neither height nor depth, nor anything else in all 
creation, will be able to separate us from the love of God that 
is in Christ Jesus our Lord. - Romans 8:38-39
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20040416/f6e45ee0/attachment.bin


More information about the antlr-interest mailing list