[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SableCC sources doc?



Robert Feldt wrote:
> > The main difficulty you'll have in reading the AST traversal stuff, is
> > that SableCC 1.0 ASTs didn't have a nice naming scheme.  Child nodes
> > were numbered, e.g. node.getNode1(), getNode2(), etc.
> >
> I dont follow you here. I'm looking into SableCC 2.14.1 so if you've
> updated the AST names that wouldn't be a problem, eh? I guess I've
> misunderstood something.

SableCC 2.14.1 (I should say SableCC 2.1, to be precise) was partly
generated using SableCC 1.0.  So, for instance, if you look in the
org.sablecc.sablecc.node package, you'll see classes like:
Alt.java
Alt1.java
Alt2.java

and in Alt1.java you'll find:

public AltNameOpt getNode1()

If these classes were generated by SableCC 2.x, you would have:

PAlt.java
ASomethingAlt.java
ASomethingElseAlt.java

and in ASomethingAlt.java you would have

public PAltNameOpt getAltNameOpt()

which would be much more intuitive.  So in ResolveIds, you will see
things like:

public void outTokenDef1(TokenDef1 node)

You will have a hard time knowing what TokenDef1 is in the input
grammar.

Have fun!

Etienne
-- 
----------------------------------------------------------------------
Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                             http://www.sablecc.org/
and SableVM:                                   http://www.sablevm.org/