[antlr-interest] Using tree grammar for second pass to check function signatures

Marko Simovic markobarko at gmail.com
Mon Apr 21 14:00:03 PDT 2008


hi all,

i was wondering about using the tree grammar to validate parameter
counts on some functions in my grammar. the rule in the parser is:

functionCall	:	functionName LParen parameterList RParen -> ^(Function
functionName parameterList)

in this case, functionName is any string token.

now, if i have a function called SUM that takes two parameters i'd like
to ensure that the params supplied are correct. to do this currently i
use (in parser):

functionCall	:	functionName LParen parameterList RParen -> ^(Function
functionName parameterList)
		| 
                    tfunc='sum' LParen parameter Comma parameter
RParen	-> ^(Function $tfunc parameter+);

is it possible to check this in a tree grammar instead?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080421/b8d2c9c7/attachment.html 


More information about the antlr-interest mailing list