[antlr-interest] lisp-like issues

Terence Parr parrt at cs.usfca.edu
Tue Dec 20 12:56:14 PST 2005


On Dec 19, 2005, at 3:26 PM, Brannon King wrote:

> Suppose I have a grammar like the following:
>
> (funcName returnName param1 param2 (funcName ...) ...)
>
> (The actual grammar is EDIF and it is LISP-like).
>
> I set all my built-in funcNames as tokens in the Lexer. The Lexer
> Identifier rule picks up funcName, retName, param, etc. However, there
> is no restriction in the language that the returnName or params be
> different from any of the built-in function names. Function calls just
> happen to be the first item in the list. So when I tell the Identifier
> rule to testLiterals, I get errors when my other params have the same
> name as a function. When I tell it to not test literals, I get an  
> error
> on the very first function that looks like this: expecting "funcName",
> found 'funcName'.

This is the standard "my keywords can be variables" problem.  I  
suggest not having keywords as LISP type stuff usually  doesn't.   
Just treat everything uniformly like ID (no "literals" in your grammar).

Ter


More information about the antlr-interest mailing list