[antlr-interest] THE STEAMROLLER PROBLEM!

Randall R Schulz rschulz at sonic.net
Thu Oct 2 18:43:44 PDT 2008


Hi,

Sorry for shouting, but I really would like a definitive answer to this
question. ("Steamroller" referring to creating a flat AST.)

If one is to parse an infix operator notation, exemplified by this
input:

	1 OP 2 OP 3 OP 4 OP 5

and produce from it this AST:

	(OP 1 2 3 4 5)

How, if it is indeed possible, would one do this?

It seems simple enough, but so far, no suggestion offered nor idea of my
own has succeeded in producing anything other than one of these results:

Result 1:
	(OP 1 (OP 2 (OP 3 (OP 4 5))))

Result 2:
	(OP (OP (OP (OP 1 2) 3) 4) 5))))

Result 3:

Exception in thread "main" org.antlr.runtime.tree.RewriteEmptyStreamException: token OP


Any definitive answers out there? Terence??

Thanks.


Randall Schulz


More information about the antlr-interest mailing list