[antlr-interest] java 1.5 grammar corrections

Koen Vanderkimpen koen.vanderkimpen+antlr at cs.kuleuven.be
Wed Oct 25 06:45:51 PDT 2006


Hi,

I already mailed some time ago because I had a problem with the java 1.5 grammar and generic casts.
By using antlrworks, my colleague and me fixed this, and also a typo in the rule for interface declarations.


castExpression
    :  '(' primitiveType ')' unaryExpression
    |  '(' type ')' unaryExpressionNotPlusMinus
    ;

In the third line of that rule, we changed " '(' expression | type ')' ", because, according to the Java Language Specification, expressions don't belong there. But it only says so in the semantics of casting, not in the syntax at the end of the document. The rule made it impossible to use a castExpression of the form " (List<Object>)someList ".


normalInterfaceDeclaration
 : 'interface' Identifier typeParameter? ('extends' typeList)? interfaceBody
 ;

Here, "typeParameters" was changed from "typeParameter", according to JLS syntax.


I attached a modified grammar file to this message, so that people are able to use it from here or put it on the site.


Regards,

Koen Vanderkimpen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20061025/31debb01/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: java.g
Type: application/octet-stream
Size: 15927 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20061025/31debb01/attachment-0001.obj 


More information about the antlr-interest mailing list