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

chain one chainone at gmail.com
Tue Jan 13 18:09:21 PST 2009


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/3bb7b32c/attachment.html 


More information about the antlr-interest mailing list