[antlr-interest] How much abstraction would use recommend?

Andreas Rueckert a_rueckert at gmx.net
Fri Dec 21 03:05:59 PST 2001


You may know that I'm working on a grammar for Java classfiles. I'm no expert
on Antlr (although I've used it for a few years) or grammars. So I'd like to
ask you for advice.
I think I've the parser for classfile working and now I'm working on the
treeparser. I'd like to use the treeparser for the ArgoUML project, so I could
import class- and jar files. That works in Argo via a Modeller (written by
Marcus Andersson), that you pass values like classnames, attributes etc. and
that'll create the corresponding UML elements for you. However, a classfile
looks very different. It's mainly content is a so called constant pool, that
holds data structures for classes, UTF8 strings and so on. Then follows the
actual data structures for the compiled class, which are mainly index fields to
constant pool entries. So I have to dereferences those fields somehow.
I could do this in some modeller utility class, but I'd rather like to have a
comfortable parser, that does it for me. So I added some code to the parser to
do the dereferences and construct a tree, that holds the info, like it's rather
structured in a source file. My treeparser has rules like
	: CLASS_NAME { System.out.println("Classname: " + #CLASS_NAME.getText()); }
, so you can directly acces the classname here, and don't have to care about
the constant pool data structures at all. In fact I left the constant pool
completely out of the generated AST at all.
What do you think is better: 
Keep the parser close the classfile structure and
pass all the info to the user of the parser, but let him deal with all the
classfile structures (that he has to learn then first)?
Or hide most of the classfile details and make the usage of the parser very
comfortable, so the user gets all the info plain in the rules, so he doesn't
have to understand the classfile structure at all?



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

More information about the antlr-interest mailing list