[antlr-interest] Problem with disambiguating semantic predicates and the decision DFA

Markus Stoeger spamhole at gmx.at
Wed Dec 31 09:22:29 PST 2008


First of all, a happy new year to everyone!

I'm writing a grammar for one of those twisted languages, written by 
social deviants, that allow keywords to be used as variables.

The solution provided in the ANTLR Reference book on page 287 ("Keywords 
as Variables") seems to work fine in most cases.

However I have found one case where my tests fail:

Please have a look at the attached grammar in keywords.g. Debug it with 
the start symbol "procedureDecl" and feed it the input "PROCEDURE Proc; 
FORWARD;"

The problem happens in "subroutineBlock" where the decision dfa chooses 
the wrong alternative 3 (asmBlock) instead of 2 (forward).

To me the generated decision DFA for the symbol "subroutineBlock" (also 
attached) looks erroneous. It correctly evaluates the disambiguating 
semantic predicates for alternatives 1 (external) and 2 (forward), but 
it skips the evaluation for alternative 3 (asmBlock) and makes its 
decision based on the SEMICOLON token, which is wrong because the 
semicolon can belong to the outer procedureDecl.

I have tested this with the latest stable version of the ANTLRWorks 
bundle (1.2.2).

thanks for any hints,
Markus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dfa.png
Type: image/png
Size: 12649 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20081231/abcd3ddd/attachment.png 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: input.txt
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20081231/abcd3ddd/attachment.txt 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: keywords.g
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20081231/abcd3ddd/attachment.pl 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tree.png
Type: image/png
Size: 8844 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20081231/abcd3ddd/attachment-0001.png 


More information about the antlr-interest mailing list