[antlr-interest] Looping forever on some input

Ola Bini ola.bini at gmail.com
Thu Apr 2 01:29:07 PDT 2009


Thomas Brandon wrote:
> The problem is most likely your DecimalLiteral rule:
> DecimalLiteral
>     :
>     ;
> Non-fragment lexer rules that can match no input will cause infinite loops.
> This may only occur for certain input as other input will be matched
> before ANTLR checks whether the troublesome rule can match. Having
> input that matches no other rule ensures such a rule will cause an
> infinite loop.
>
>   
Ah, interesting. Thank you, will try that.

Cheers
> Tom.
>
> On Thu, Apr 2, 2009 at 7:09 PM, Ola Bini <ola.bini at gmail.com> wrote:
>   
>> Hi,
>>
>> I'm having some trouble with the lexer looping forever on input that
>> should be possible to disambiguate in limited time. Not exactly sure why
>> this happens. It is definitely possible I have done something stupid in
>> my grammar, of course.
>>
>> I've seen eternal looping before, for some constructs. A typical example
>> was the input of a single quote, before defining anything that allows a
>> single quote. This behavior seems a bit strange, in my opinion, but I
>> never figured out why it happened.
>>
>> The current problem is for input such as "::foo". (without the double
>> quotes).
>>
>> The relevant productions (the only ones that include colon) look like this:
>> fragment
>> OperatorChar
>>    :
>>       '+'  | '-' | '*' | '%' | '<'
>>    |  '>'  | '!' | '?' | '~' | '&'
>>    |  '|'  | '^' | '$' | '=' | '@'
>>    |  '\'' | '`' | ':'
>>    ;
>>
>> Identifier
>>    :
>>        '[]'
>>    |   '{}'
>>    |   (OperatorChar | '/') (OperatorChar | '#' | '/')*
>>    |   '#' (OperatorChar | '#')+
>>    |   '.' '.'+
>>    |   Letter (Letter|IDDigit|':'|'!'|'?'|'$')*
>>    |   ':' (Letter|IDDigit) (Letter|IDDigit|':'|'!'|'?'|'$')*
>>    ;
>>
>> Where Identifier is part of the main production for the parser.
>>
>> The full grammar can be seen at:
>> http://github.com/olabini/ioke/raw/9e2795c9c5f2b326c0cbb3dfb456f885b9625ba2/src/grammar/ioke.g
>>
>>
>> Cheers
>>
>> --
>>  Ola Bini (http://olabini.com)
>>  Ioke creator (http://ioke.org)
>>  JRuby Core Developer (http://jruby.org)
>>  Developer, ThoughtWorks Studios (http://studios.thoughtworks.com)
>>  Practical JRuby on Rails (http://apress.com/book/view/9781590598818)
>>
>>  "Yields falsehood when quined" yields falsehood when quined.
>>
>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>>     
>
>   


-- 
 Ola Bini (http://olabini.com) 
 Ioke creator (http://ioke.org)
 JRuby Core Developer (http://jruby.org)
 Developer, ThoughtWorks Studios (http://studios.thoughtworks.com)
 Practical JRuby on Rails (http://apress.com/book/view/9781590598818)

 "Yields falsehood when quined" yields falsehood when quined.




More information about the antlr-interest mailing list