[antlr-interest] Flow of control in AST parsing.

Bharath Sundararaman Bharath.Sundararaman at starthis.com
Wed Feb 16 08:08:59 PST 2005

Hi all,

I have a tree walker which walks function calls in the AST to perform
type checking in the following form:

A function sqrt(a,b); will be walked as #(s:IDENT #(PARAM param_List));

If I find out the "sqrt" is an undefined/erroneous function, I want to
avoid walking through the parameters of the function. So, I did this:

If (sqrt is an erroneous function) #s.removeChildren(); Note that "s" is
the label for the "IDENT" token which is the name of the function.

The problem is, the children are removed but I don't know how to return
the flow of control to the rule that invoked this rule. For example, I
am unable to return to an assignment statement of the form:

result := sqrt(a,b); How can I return the control to the assignment
statement after I remove the children?



-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Tuesday, February 15, 2005 8:30 PM
To: ANTLR Interest
Subject: [antlr-interest] new article on language translation


You all might be interested in the following article I just put up at 


"This article demonstrates how to translate a very simple C dialect, 
which I will call "C-" in honor of the grades I received in college, to 
three different languages, again using a single model and controller 
with multiple views. The targets are Java, Python, and bytecodes 
similar to the Jasmin Java bytecode assembler format. Merely swapping 
in a new template file generates completely different output without 
even recompiling the translator!"

CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com

More information about the antlr-interest mailing list