[antlr-interest] nested return statements

genericised trigonometric at softhome.net
Thu Aug 15 06:44:08 PDT 2002

I am trying to get some rules in a parser to
return strings to each other in a heirarchy,
this is what I have so far:

file returns [String s] 
{s=""; String lineData="";}

       : {s+="<table align=\"center\" border=\"1\">\n";}

protected line returns [String rec] {rec="";String s="";}

       : {s+="  <tr>\n";}
          rec:((record)+) NEWLINE
           s+=rec+"  <tr/>\n";
protected record returns [String s] {s="";}

       : {s+="    <td>";} (r:RECORD) (COMMA)? {

This does not work, and I know why it does not work
but I do not know how to get it to work...yet.

I can get it to work if I edit the generated parsers so that
they are like:

if ((LA(1)==RECORD)) {

so that the string lineData is assigned the value returned by
the line rule, how does one do this in ANTLR, is it possible?
(without modifying the generated parsers).


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list