Are you certain? I don't know your grammar, but it sounded to me like
it's not valid syntax to use a function name when the parser is
expecting a data type, and vice versa. If that's the case, then
wouldn't you be able to switch lexical states, thereby setting the
parser to correctly expect the next token type?
DR
Nathan Ward wrote:
>> Use 2 different lexical states?
>
> But, I don't have anything to key on in order to switch lexical states.
>
> -----Original Message-----
> From: David Rosenstrauch [mailto:
darose@...]
> Sent: Wednesday, July 16, 2008 3:26 PM
> To:
users@...
> Subject: Re: [JavaCC] How to handle case where a keyword can also be a
> function call?
>
> Nathan Ward wrote:
>> I'm making a parser for a language that uses "long" as a data type and
>> also has a function by the same name that takes a string as a
>> parameter and converts it to a long value. How can I setup the javacc
>> grammar to distinguish between the token of "long" and an identifier
>> that is the name of a function in a "FunctionCall" production?
>>
>> TOKEN :
>>
>> { < LONG: "long" > }
>>
>> void FunctionCall() :
>>
>> { }
>>
>> { Variable() "(" [Parameters()] ")" }
>>
>> Target language statement that is being matched as the token "long",
>> but should be treated as a FunctionCall():
>>
>> long(ls_id)
>>
>>
>> Nathan Ward
>
> Use 2 different lexical states?
>
> DR
---------------------------------------------------------------------
To unsubscribe, e-mail:
users-unsubscribe@...
For additional commands, e-mail:
users-help@...