[antlr-interest] Unfolding of loops with antlr?

Jon Schewe jpschewe at mtu.net
Thu Dec 27 15:38:59 PST 2007


Terence Parr wrote:
>
> On Dec 27, 2007, at 8:12 AM, Jon Schewe wrote:
>
>> Given the discussion here I've taken another look at custom AST walkers
>> and found that it's really not that difficult to write an AST walker if
>> you do a good job creating the tree in the parser with rewrite rules.  I
>> haven't rewritten the whole grammar yet, but have written an example
>> that contains most of the elements and found it very manageable.  Thank
>> you for the suggestions to look in another direction.
>
> Beware of simple walkers.  They are great if you want to print out
> every node or count them.  They cannot, however, answer important
> questions such as "am I in this context?". You cannot apply actions
> that are appropriate only in certain contexts very easily without
> grammatical context.
>
I'm not sure where you are getting at here, but I don't seem to have any
of these problems.  I've enhanced the AST to make it clear what context
I'm in and I'm parsing a simple language that just contains variable
declarations and equations and loops.

-- 
Jon Schewe | http://mtu.net/~jpschewe
If you see an attachment named signature.asc, this is my digital
signature.
See http://www.gnupg.org for more information.

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



More information about the antlr-interest mailing list