[antlr-interest] Grammar does not match a valid sentence

Edson Tirelli tirelli at post.com
Mon Dec 3 04:52:49 PST 2007


     All,

     I have a grammar that is not matching a valid sentence and I don't
understand exactly why. If anyone can shed some light, I would really
appreciate.
     To see the problem:

Using: antlr v3.0 and antlrworks 1.1.4:

1. Load the attached grammar in antlrworks
2. Select the interpreter tab and paste the following sentence:

Address( street[1] == "Low" && street[2] == "High" )

3. Use the rule "fact" as an entry point to parse the sentence above.

     The above sentence is a valid sentence, but it is raising a
NoViableAltException in the "and_restr_connective" rule, while the expected
behavior is not to match "and_restr_connective", but go back in the call
hierarchy and to match the "and_constr" rule.
     If you remove the square brackets, the sentence will work fine
(matching the "and_constr" rule):

Address( street1 == "Low" && street2 == "High" )

     Any idea how can I fix that?
     Thanks in advance,

     []s
     Edson

-- 
  Edson Tirelli
  JBoss Drools Core Development
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071203/20eeeb1d/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DRL2.g
Type: application/octet-stream
Size: 6542 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20071203/20eeeb1d/attachment.obj 


More information about the antlr-interest mailing list