[antlr-interest] help needed ... : java grammar & identifier

Lloyd Dupont lloyd at galador.net
Sun Apr 14 22:13:39 PDT 2002


I am stuck.

I try to do something intelligible with identifier in the format
IDENT (DOT IDENT) *

my purpose is to create a class like this

public class JavaIdentifier
{
    String[] valuePath; // all IDENT as String
    // some fct....
}

I am using the tree parser, I hardly find how to build (easily) such a class
from such a messy rule:

#---------------
primaryExpression
    :   IDENT
    |   #( DOT
   ( expr
    ( IDENT
    | arrayIndex
    | "this"
    | "class"
    | #( "new" IDENT elist )
    |   "super"
    )
   | #(ARRAY_DECLARATOR typeSpecArray)
   | builtInType ("class")?
   )
  )
 | arrayIndex
 | #(METHOD_CALL primaryExpression elist)
 | #(TYPECAST typeSpec expr)
 |   newExpression
 |   constant
    |   "super"
    |   "true"
    |   "false"
    |   "this"
    |   "null"
 | typeSpec // type name used with instanceof
 ;
#-----------------
I should recursively descend a tree like #(DOT IDENT #(DOT....)), how to do
this ? using ANTLR ?
and in a single rule so i could build my structure ?

any idea help will be wellcome !

thanks.


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list