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

lgcraymer lgc at mail1.jpl.nasa.gov
Fri Apr 16 10:43:41 PDT 2004


That looks like an approximate LLk issue--it may still generate
correct code.

--Loring


--- In antlr-interest at yahoogroups.com, Jon Schewe <jpschewe at m...> wrote:
> 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



 
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