[antlr-interest] How to write this lexer rule?

chain one chainone at gmail.com
Tue Jan 13 23:58:53 PST 2009


I am still working on this. Searching for solutions that could make the
IDENT rule and FUNCTION_DECL work together.Could anybody help me with these?
Thanks.


On Wed, Jan 14, 2009 at 10:54 AM, chain one <chainone at gmail.com> wrote:

> I know where the problem isThere is another rule named IDENT:
>
> IDENT
>
> : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
>  ;
>
> seems this rule conflicts with the FUNCTION_DECL rule.
>
> On Wed, Jan 14, 2009 at 10:09 AM, chain one <chainone at gmail.com> wrote:
>
>> Seems it still doesn't work.I am still working on this.
>> I learned a lot from your rely. Thanks Gavin.
>>
>> On Wed, Jan 14, 2009 at 4:21 AM, Gavin Lambert <antlr at mirality.co.nz>wrote:
>>
>>> At 00:29 14/01/2009, chain one wrote:
>>>
>>>> I tried the lexer rule you gave me. But following error comes out:
>>>>
>>>> Alternative 155: after matching input such as
>>>> 'F''U''N''C''T''I''O''N''F''U''N''C''T''I''O''N''F''U''N''C''T''I''O''N''E''N''D''_''F''U''N''C''T''I''O''N'{'0'..'9',
>>>> 'A'..'Z', '_',
>>>> 'a'..'z'}'F''U''N''C''T''I''O''N''E''N''D''_''F''U''N''C''T''I''O''N'{'0'..'9',
>>>> 'A'..'Z', '_', 'a'..'z'}'F''U''N''C''T''I''O'{'\u0000'..'/', ':'..'@', 'N',
>>>> '['..'^', '`', '{'..'\uFFFF'} decision cannot predict what comes next due to
>>>> recursion overflow to FUNCTION_DECL from FUNCTION_DECL
>>>>
>>>
>>> Hmm.  Well, another variation (that it might like better) would be:
>>>
>>> FUNCTION_DECL
>>>  : 'FUNCTION' { $channel = HIDDEN; }
>>>    (FUNCTION_DECL | ~'E' | 'E' (~'N' | 'N' (~'D' | 'D'
>>>      (~'_' | '_' (~'F' | 'F' (~'U' | 'U' (~'N' | 'N'
>>>      (~'C' | 'C' (~'T' | 'T' (~'I' | 'I' (~'O' | 'O'
>>>      (~'N' | 'N' ~SEMI))))))))))))*
>>>    'END_FUNCTION' SEMI
>>>  ;
>>>
>>> Another thing that might help is to change the embedded reference to
>>> FUNCTION_DECL to ('FUNCTION') => FUNCTION_DECL; ie:
>>>
>>> FUNCTION_DECL
>>>  : 'FUNCTION' { $channel = HIDDEN; }
>>>    ('FUNCTION') => FUNCTION_DECL | ~'E' | 'E' (~'N' | 'N'
>>>      (~'D' | 'D' (~'_' | '_' (~'F' | 'F' (~'U' | 'U'
>>>      (~'N' | 'N' (~'C' | 'C' (~'T' | 'T' (~'I' | 'I'
>>>      (~'O' | 'O' (~'N' | 'N' ~SEMI))))))))))))*
>>>    'END_FUNCTION' SEMI
>>>  ;
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090114/919f841d/attachment.html 


More information about the antlr-interest mailing list