[antlr-interest] ARRAY_DECLARATOR in java.g grammar

Juan Miguel dude_fiera at hotmail.com
Sun Oct 19 16:25:31 PDT 2003


Hi, I need help in the following in java.g grammar

If I have a variable like: String[][] var, java grammar generates a tree like:

TYPE
 |_ ARRAY_DECLARATOR
    |_ ARRAY_DECLARATOR
       |_ STRING

I want to generate a tree like:

 TYPE
|_ STRING[][]


If you see the code below (from java.g) I added a label to concatenate the IDENT, and then create a node with String[][]
But antlr says "Labeled subrules not yet supported"

Any suggestion to solve this issue?

identPrimary
: labelA:(IDENT
(
  options {greedy=true;}
  : DOT^ IDENT
  )*)

(
  options {greedy=true;}
  : ( lp:LPAREN^ {#lp.setType(METHOD_CALL);} argList RPAREN! )
  | ( options {greedy=true;} :
  lbc:LBRACK^ {#lbc.setType(ARRAY_DECLARATOR);} RBRACK!
  )+
)?
;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20031019/d36581d1/attachment.html


More information about the antlr-interest mailing list