[antlr-interest] Why is ANTLR getting lost?

Jon Schewe jpschewe at mtu.net
Wed Feb 20 06:42:35 PST 2008


shmuel siegel wrote:
> Jon Schewe wrote:
>> I've figured out that ANTLR is dying in the DFA when it's trying to
>> determine which branch of the constraintDecl rule to follow. 
>> Attached is the grammar, suggestions on how to resolve this are very
>> welcome.
>>
>> Test case is here:
>>  /**
>>   * @throws RecognitionException
>>   */
>>  @Test
>>  public void testConstraintDecl0() throws RecognitionException {
>>    final String data = "constraint3: 5.0 <= 6 + 6 * a[1 + 3] * c - 1
>> <= 10.0;";
>>
>>    final GHOCESLexer lexer = new GHOCESLexer(new
>> ANTLRStringStream(data));
>>    final CommonTokenStream tokens = new CommonTokenStream(lexer);
>>    final GHOCESParser parser = new GHOCESParser(tokens);
>>    final GHOCESParser.constraintDecl_return r = parser.constraintDecl();
>>    Assert.assertNotNull(r);
>>  }
>>
> I can't tell you why but I can tell you that the dfa predictor is
> failing on
>        (addExpr[true] EQ) => addExpr[true] EQ addExpr[false]
>      | (number LE addExpr[true] LE) => lb=number LE addExpr[false] LE
> ub=number
>      | (addExpr[true] LE) => ae+=addExpr[true] LE ae+=addExpr[false]
>
> Note that the second alternative satisfies the conditions of the
> condition of the third alternative. If you eliminate the third
> alternative, the rule works. The rule also works if you change the
> third alternative to be different then the second, say by adding LE
> before addExpr. I suspect that something is wrong with the dfa predictor.
>
I need both alternatives to do the tree rewrite correctly.  I removed
the extra sytantatic predicate on the third alternative, but that didn't
help. 

-- 
Jon Schewe | http://mtu.net/~jpschewe
If you see an attachment named signature.asc, this is my digital
signature.
See http://www.gnupg.org for more information.

For I am convinced that neither death nor life, neither angels 
nor demons, neither the present nor the future, nor any 
powers, neither height nor depth, nor anything else in all 
creation, will be able to separate us from the love of God that 
is in Christ Jesus our Lord. - Romans 8:38-39



More information about the antlr-interest mailing list