[prev in list] [next in list] [prev in thread] [next in thread] 

List:       antlr-interest
Subject:    =?gb2312?q?=BB=D8=B8=B4=A3=BA=20RE:=20[antlr-interest]=20Tree=20generatio?=
From:       sunjigang1965 () yahoo ! com ! cn (=?gb2312?q?=CB=EF=BC=CD=B8=D5=20Jigang=20(Robert)=20
Date:       2006-02-28 13:53:55
Message-ID: 20060228215350.41800.qmail () web15703 ! mail ! cnb ! yahoo ! com
[Download RAW message or body]

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@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/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic