[antlr-interest] TreeWalker error(100)

向秦贤 fyaoxy at gmail.com
Thu Aug 30 22:15:04 PDT 2007


I guess you wanna write this:
qualifiedName
     :     Identifier ('.' Identifier)* -> ^(IDENTIFIER $text)
     ;
I not try in current laptop, I will try it when off.

2007/8/29, benjamin.b.lenz at daimlerchrysler.com
<benjamin.b.lenz at daimlerchrysler.com>:
>
> Hi guys,
>
> I'm new developing a parser grammar with ANTLR. I have to rewrite some of
> the Java1.5 rules to create an AST and build a TreeWalker to visit the
> nodes and extract the infos...
>
> During my beginning I tried to start from bottom to top and rewrite more
> and more grammar rules. But in a very basic grammar I found the error(100)
> and no useful ref on the antlr list.
>
> I want to use the duplicating nodes rule on
>
> qualifiedName
>       :     Identifier ('.' Identifier)*
>       ;
>
> So I tried
>
> qualifiedName
>       :     Identifier ('.' Identifier)* -> ^(Identifier Identifier*)
>       ;
>
> This works in the parser grammar but the ANTLR plugin for eclipse gives me
> the
> error(100): unexpected token: ^(
> expecting SEMI, foun
>
>
> and later on
>
> error(204): duplicate token type '\005f' when collapsing subrule into set
>
> it would be great if anybody could help me what wrong here..
>
> thanks!!
>
> Ben
>
> here the code:
>
> tree grammar Walker;
>
> options{
>       tokenVocab = Java;
>       ASTLabelType = CommonTree;
> }
>
> compilationUnit
>       :     packageDeclaration?
>       ;
>
> packageDeclaration
>       :     'package' qualifiedName ';'
>       ;
>
> qualifiedName
>       :     Identifier ('.' Identifier)* -> ^(Identifier Identifier*)
>       ;
>
> Identifier
>     :   Letter (Letter|JavaIDDigit)*
>     ;
>
> fragment
> Letter
>     :  '\u0024' |
>        '\u0041'..'\u005a' |
>        '\u005f' |
>        '\u0061'..'\u007a' |
>        '\u00c0'..'\u00d6' |
>        '\u00d8'..'\u00f6' |
>        '\u00f8'..'\u00ff' |
>        '\u0100'..'\u1fff' |
>        '\u3040'..'\u318f' |
>        '\u3300'..'\u337f' |
>        '\u3400'..'\u3d2d' |
>        '\u4e00'..'\u9fff' |
>        '\uf900'..'\ufaff'
>     ;
>
> fragment
> JavaIDDigit
>     :  '\u0030'..'\u0039' |
>        '\u0660'..'\u0669' |
>        '\u06f0'..'\u06f9' |
>        '\u0966'..'\u096f' |
>        '\u09e6'..'\u09ef' |
>        '\u0a66'..'\u0a6f' |
>        '\u0ae6'..'\u0aef' |
>        '\u0b66'..'\u0b6f' |
>        '\u0be7'..'\u0bef' |
>        '\u0c66'..'\u0c6f' |
>        '\u0ce6'..'\u0cef' |
>        '\u0d66'..'\u0d6f' |
>        '\u0e50'..'\u0e59' |
>        '\u0ed0'..'\u0ed9' |
>        '\u1040'..'\u1049'
>    ;
>
>
>
>
> If you are not the intended addressee, please inform us immediately that you have received this e-mail by mistake and delete it. We thank you for your support.
>


-- 
致敬
向秦贤


More information about the antlr-interest mailing list