=?gb2312?q?=BB=D8=B8=B4=A3=BA=20RE:=20[antlr-interest]=20Tree=20generatio?=
=?gb2312?q?n=20qestion=20?=
=?gb2312?q?=CB=EF=BC=CD=B8=D5=20Jigang=20(Robert)=20Sun?=
sunjigang1965 at yahoo.com.cn
Tue Feb 28 13:53:50 PST 2006
The code generated by following grammar
program
:
m:mainClass l:classDeclList {## = #( #[PROGRAM,
"PROGRAM","MiniJava.Program"],#m,#l);} EOF
;
runs into infinite iteration at
public virtual AST make(params AST[] nodes)
{
...
while (tail.getNextSibling() != null) //could not
get out of here
{
tail = tail.getNextSibling();
Console.WriteLine(tail.GetType());//added by
me
}
}
return root;
}
After putting to the end of ! program, got expected
tree.
What I remember last time for formalList, I put ! to
formalList after computer got into dead iteration,
then I continue to other grammar modification which
is irrelavant to formalList, then remove the bomb off.
It worked normally.
Jigang
--- Micheal J <open.zone at virgin.net>дµÀ:
> > Code generated by the attached grammar only
> produces a
> > root StatementList node contains an empty list of
> > Statement. After remove ! from end of
> > "statementList", desired result got. Is this
> normal?
>
> Yes. "!" means don't generate standard tree creation
> code. You now have to
> provide that yourself. For statementList, you should
> leave it out.
>
> > While the following grammar works well.
> >
> > formalList!
> > :
> > (formal ( COMMA! formal)* { ## =
> > #(#[FORMAL_LIST,"FORMAL_LIST"],##); })?
> > ;
>
> Strange. This should give the root node only as
> well.
>
>
> Micheal
>
>
___________________________________________________________
ÑÅ»¢1GÃâ·ÑÓÊÏä°Ù·Ö°Ù·ÀÀ¬»øÐÅ
http://cn.mail.yahoo.com/
More information about the antlr-interest
mailing list