[POTENTIAL SPAM - OPEN AT USER DISCRETION] Re: [antlr-interest] java example grammar

ronald.petty at milliman.com ronald.petty at milliman.com
Tue Apr 27 07:01:09 PDT 2004


Monty,
I was just making sure I understood a more complicated (at least for 
myselft) example.  I finally figured out how to read the Trace output and 
that helps out a TON.

Have a good day,
Ron




Monty Zukowski <monty at codetransform.com> 
04/27/2004 01:15 AM
Please respond to
antlr-interest at yahoogroups.com


To
antlr-interest at yahoogroups.com
cc
Monty Zukowski <monty at codetransform.com>
Subject
[POTENTIAL SPAM - OPEN AT USER DISCRETION] Re: [antlr-interest] java 
example grammar 






I think you got it right, Ron, though I'm not sure what your question 
really was.  It does go through that whole chain of rules to match 
IDENT in identPrimary.

Monty Zukowski

ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit -- 
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
On Apr 23, 2004, at 4:44 PM, ronald.petty at milliman.com wrote:

>
> I was trying to use the java grammar as a bases for a VB grammar (just 
> seeing how to handle expression order etc).  The first structure I was 
> trying to figure out for the for loop.  In the java.g there is
>
> statement
>         :
>         ...
>         // For statement
>         |       "for"
>                         LPAREN!
>                                 forInit SEMI!   // initializer
>                                 forCond SEMI!   // condition test
>                                 forIter         // updater
>                         RPAREN!
>                         statement                     // statement to 
> loop over
>
>         ....
>         ;
>
> If I was using this as the input
>
> for ( i = 0; .......
>
> It would match "for" "(" then call the rule forInit.  
>
> forInit
>                 // if it looks like a declaration, it is
>         :       (       (declaration)=> declaration
>                 // otherwise it could be an expression list...
>                 |       expressionList
>                 )?
>                 {#forInit = #(#[FOR_INIT,"FOR_INIT"],#forInit);}
>         ;
>
> I noticed that "i" cannot be a declaration because of the typeSpec in 
> the declaration rule would mean it needs to "int i" or something like 
> that, so I assume "i" is an expressionList (also because i had to be 
> declared already).  So following that path lead to this
>
> expressionList ->
> expression->
> assignmentExpression->
> conditionalExpression->
> logicalOrExpression->
> logicalAndExpression->
> inclusiveOrExpression->
> exclusiveOrExpression->
> andExpression->
> equalityExpression->
> relationalExpression->  (not 100% here)  (nested question; ( subrule1 
> )* | subrule2  if you don't match subrule1 do you have to match 
> subrule2?  I think this does a zero match subrule1 here
> shiftExpression->
> additiveExpression->
> multiplicativeExpression->
> unaryExpression->
> unaryExpressionNotPlusMinus->
> postfixExpression->
> primaryExpression->
> identPrimary->
> IDENT  (Match finally)
>
> Hopefully I was right in this, if this is true, is this because
>         1) "i" is not a declaration (becuase in Java it has already 
> been declared (and if Option Explicit is on in VB this is the same as 
> having it Dim i somewhere or Public i)
>         2) "i" is really an expression becuase it is really an LValue 
> which is the output of someprevious RValue?  (I hope I am not 
> slaughtering terms here)
>         3) and becuase of 2) this means that an LValue is the simplest 
> kind of expression and that is why it is at the end of this chain 
> (meaning it is the highest on the precendence) (not sure about this)
>
> I am thinking in the right way about this?
>
> Thanks alot
> Ron
> *********************************************************************** 
> ***************
> This communication is intended solely for the addressee and is
> confidential. If you are not the intended recipient, any disclosure,
> copying, distribution or any action taken or omitted to be taken in
> reliance on it, is prohibited and may be unlawful. Unless indicated
> to the contrary: it does not constitute professional advice or
> opinions upon which reliance may be made by the addressee or any
> other party, and it should be considered to be a work in progress.
> *********************************************************************** 
> ***************
>
>
> 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 
the Yahoo! Terms of 
> Service.
>
>




 
Yahoo! Groups Links



 




**************************************************************************************
This communication is intended solely for the addressee and is
confidential. If you are not the intended recipient, any disclosure, 
copying, distribution or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. Unless indicated
to the contrary: it does not constitute professional advice or 
opinions upon which reliance may be made by the addressee or any
other party, and it should be considered to be a work in progress.
**************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20040427/9a470652/attachment.html


More information about the antlr-interest mailing list