[antlr-interest] Custom AST node type - guidance needed

Bill Andersen andersen at highfleet.com
Mon Jul 19 11:29:52 PDT 2010


Hi folks

Having some trouble making ASTs using a custom node type.  Before I ask any stupid questions, what is the best place to look on how to do this ( I'm using 3.2 )?  I'm finding bits and pieces, some of them contradictory.  For example I find this example

static class V extends CommonTree {
  public int x,y,z;
  public V(int ttype, int x, int y, int z) {
    this.x=x; this.y=y; this.z=z; token=new CommonToken(ttype,"");
  }
at http://www.antlr.org/wiki/display/ANTLR3/Tree+construction

When I try to define a constructor like this I'm forced to put a cast between on CommonToken to Token, which causes a runtime can't cast error.

What I want is really quite simple.  Need to add one extra field to my AST nodes to carry DSL type information.

Any help appreciated.  Thanks.

	.bill

Bill Andersen 
Highfleet, Inc. (www.highfleet.com)
3600 O'Donnell Street, Suite 600
Baltimore, MD 21224
Office: +1.410.675.1201
Cell: +1.443.858.6444
Fax: +1.410.675.1204







More information about the antlr-interest mailing list