SMACS

Package smacs.tree

[4] Dynamic AST implementation, along with w3c.dom interface.

See:
          Description

Interface Summary
GetSimpleNode has a SimpleNode.
HasNodeHandler has NodeHandler.
HasNodeReferenceAttribute has NodeReferenceAttribute.
IsaNodeReferenceAttribute NodeReferenceAttribute interface.
IsaNodeReferenceChildListener NodeReferenceElement listener.
IsaNodeReferenceId interface NodeReferenceId
IsaNodeReferenceListener NodeReferenceElement listener.
NewSimpleNode class works as node factory.
NodeHandler SimpleNode functional wrapper.
SimpleElement a SimpleNode being an Element.
SimpleNode hybrid of JJ Parser node and dom4j Element node.
SimpleNodeChild Simplified List interface.
SimpleText a SimpleNode being an Text.
 

Class Summary
NodeDefaultAttribute wrapper around dom4j DefaultAttribute.
NodeExtendedAttribute structured attribute.
NodeReferenceAttribute special refer attribute
NodeReferenceId special id attribute.
NodeReferenceTest Extra Class to Test NodeReference functionality.
NodeTreeWalkerXml NodeTreeWalker Visitor that outputs an XML text representation.
NodeVector unused.
ScriptNode hybrid of JJ Parser node and dom4j Element node.
ScriptNodeParser parse an xml file into a simplenode tree.
SimpleNodeFixType after reloading a tree, fix the node handler types.
SimpleNodeFixType.ClassLoaded  
SimpleNodeHandler simple NodeHandler.
SimpleNodeWalkerXml SimpleNodeWalker Visitor that outputs an XML text representation.
SimpleNodeXml print SimpleNode tree as XML.
SqlParserNode Wrapping the Sql Parser.
SqlScript wrap sql SqlScript parser returning SimpleNode tree.
SqlWalker for each Token[Name] call an "each[Name]" method of this class.
SqlWalkerXml SqlWalker that outputs an XML text representation.
SqlWriter Formatting a ParsingTree into SQL strings.
 

Package smacs.tree Description

[4] Dynamic AST implementation, along with w3c.dom interface.

This is an extension of the smacs.sql.* parser

The basis of the functionality is an alternative SimpleNode class that does also implement the smacs.sql.Node interface generated by JavaCC. All code using such Node arguments can also get the SimpleNode here. Furthermore, we add the very same methods as the smacs.sql.SimpleNode class (also generated by JavaCC).

However, the smacs.tree.SimpleNode uses very different internal containers to store the child-nodes of the tree node. We have given it an external implementation SimpleNodeVector. So we do have the same methods as smacs.sql.SimpleNode but they work very different.

In essence, an smacs.sql AST is a very different thing than an smacs.tree AST - and we use again the ScriptNode class to abstract away the parser difference. In essence, we call the smacs.sql.SqlScript parser and copy the smacs.sql.SimpleNode tree to a new AST based on smacs.tree.SimpleNode

The reason to use the very same name (SimpleNode == SimpleNode) with the same method names is very simple: we can reuse code parts. Java does not have code templates however, so we do copy some interesting source code from smacs.sql.* to smacs.tree.*, check out the call to `make new` that fetched the code parts being virtually identical code-wise but one exception: the thing referenced as SimpleNode class is different.

Using all that copying from smacs.sql.* we get again proper parsers, writers, and walkers. Again, we use the very same name as over there, so we can reuse the code from smacs.findsql as code templates for an implementation using smacs.tree nodes. We just need to copy the source files, going to smacs.find.*

The reason for our new SimpleNode is simple: here we begin to handle it as a real semistructured resource. The tree SimpleNode is not only an sql.Node but also an org.w3c.dom.Node (actually, an org.w3c.dom.Element), so we get proper XML readers and writers for free. Furthermore, we can use the tree-nodes for very different things than SQL nodes, we even have means for arbitrary hints, being stored as xml attributes.

And finally, we can export the SimpleNode container with even more interface implementations, e.g. as kinds List interfaces allowing us to easily walk over the children and subtrees. That makes for easy code later on with algorithms taking advantage of the java containers and walkers.

As one extra implementation note, look again for `make new` that copies some source code form `smacs.sql.*` as if being source template code. - And there is a complete org.w3c.dom subtree here that is only being used on early Java2 platforms (e.g. java 1.2) which did not ship the w3c dom xml classes in the Java2 tarball.


SMACS