[antlr-interest] How to implement an IF

Joerg.Werner at qimonda.com Joerg.Werner at qimonda.com
Thu Dec 14 00:42:38 PST 2006


Hi Terr,

Makes sense to me to implement it in BufferedTreeNodeStream, because buffering the whole TreeNodeStream may consume a lot of memory. So people who do not need the seeking backwards functionality, but want less memory consumption/better performance can use TreeNodeStream.

Regards,

Jörg


-- 
Dr. Jörg Werner
Qimonda AG 
Memory Products Division
QAG PD PT TPE C
Am Campeon 1-12
D-85579 Neubiberg
email: joerg.werner at qimonda.com
Tel:  +49 89 234-26602
Fax: +49 89 234-9553128

-----Original Message-----
From: Terence Parr [mailto:parrt at cs.usfca.edu] 
Sent: Thursday, December 14, 2006 12:59 AM
To: Werner Joerg (QAG PD PT TPE C)
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] How to implement an IF

howdy Joerg, i just tweaked CommonTreeNodeStream to make rewind/ 
release work properly.  The seek is there also (already I guess).   
Wait, it says:

		if ( index<this.index() ) {
             throw new IllegalArgumentException("can't seek backwards in node stream");
		}

which is true.  You can't seek backwards w/o knowing your state in the past (whence the treestate objects).  What we need for interpreters is to do away with the small lookahead array and just suck all tokens from CommonTreeNodeStream into an array like CommonTokenStream does.

Perhaps we need another class BufferedTreeNodeStream that sucks from a TreeNodeStream and buffers them so you can seek with an index change.  Make sense?  If so, i'll build it real quick.

I also want to update this to use Object not Tree as the type of nodes to be more generic.

Ter


More information about the antlr-interest mailing list