[antlr-interest] [v3] Help on CFScript Parser - Help on recursive rules

Mark Mandel mark.mandel at gmail.com
Sat May 12 20:38:05 PDT 2007


All,

I'm building a CFScript (think lightweight javascript) parser, which
will eventually get blown into a ColdFusion parser, but I'm getting
stuck on statements like this;

var object = getObjectManager().getObject(arguments.transfer.getClassName());

The code that ANTLR throws a wobbly on is:

codeStatement
	:
	code (DOT code)*
	;

code
	:
	IDENTIFIER | function
	;

function
	:
	IDENTIFIER OPEN_PAREN (argumentStatement)? CLOSE_PAREN
CLOSE_PAREN)
	;
	
argumentStatement
	:
	codeStatement (COMMA codeStatement)*
	;

Now, essentially, the grammar is true - and argument can be a
codeStatement... but that gives multiple paths back to the same
rule... so I don't know how I can set something like this up?

Is there where backtracking is required.  I can't seem to find a
example of backtracking that I can understand, so I'm not sure how to
go about using it.  I've been following some parts of the Java 5
grammar, but this bit I can't work out.

I've attached my full grammar as it currently stands, for further reference.

Any help would be appreciated,

Thanks,

Mar

-- 
E: mark.mandel at gmail.com
W: www.compoundtheory.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CFScript.g
Type: application/octet-stream
Size: 1183 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20070513/c681cc44/attachment.obj 


More information about the antlr-interest mailing list