From ea3e1b949dcbdc09518f17eee0bcf21d41d76896 Mon Sep 17 00:00:00 2001 From: Kenny Ballou Date: Mon, 19 Nov 2018 22:59:50 -0700 Subject: OJ (aka OpenJava) modernization/mirroring Signed-off-by: Kenny Ballou --- .../io/devnulllabs/openjava/ptree/ParseTree.java | 106 +++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/main/java/io/devnulllabs/openjava/ptree/ParseTree.java (limited to 'src/main/java/io/devnulllabs/openjava/ptree/ParseTree.java') diff --git a/src/main/java/io/devnulllabs/openjava/ptree/ParseTree.java b/src/main/java/io/devnulllabs/openjava/ptree/ParseTree.java new file mode 100644 index 0000000..89a4497 --- /dev/null +++ b/src/main/java/io/devnulllabs/openjava/ptree/ParseTree.java @@ -0,0 +1,106 @@ +/* + * ParseTree.java 1.0 + * + * This subclass of symbol represents (at least) terminal symbols returned + * by the scanner and placed on the parse stack. At present, this + * class does nothing more than its super class. + * + * Jun 11, 1997 + * Sep 5, 1997 + * + * @see java_cup.runtime.symbol + * @version 1.0 last updated: Sep 5, 1997 + * @author Michiaki Tatsubori + */ +package io.devnulllabs.openjava.ptree; + +import io.devnulllabs.openjava.ptree.util.ParseTreeVisitor; + +/** + * The ParseTree class presents for the node of parse tree. + * This may be a token node, Leaf, or may be a nonterminal node, NonLeaf. + * + * @see io.devnulllabs.openjava.ptree.Leaf + * @see io.devnulllabs.openjava.ptree.NonLeaf + */ +public interface ParseTree { + + public void replace(ParseTree replacement) throws ParseTreeException; + + /** + * Makes a new copy (another object) of this nonleaf-node recursively. + * The objects contained by this object will also be copied. + * + * @return the copy of this nonleaf-node as a ptree-node. + */ + public ParseTree makeRecursiveCopy(); + + /** + * Makes a new copy of this nonleaf-node as a ptree-node. + * The objects contained by the new object are same as + * these contained by the original object. + * + * @return the copy of this nonleaf-node as a ptree-node. + */ + public ParseTree makeCopy(); + + /** + * Tests if this parse-tree-node's value equals to the specified + * ptree-node's. + * + * @return true if two values are same. + */ + public boolean equals(ParseTree p); + + /** + * Generates string which presents for this parse-tree + * + * @return string which presents for this parse-tree + */ + public String toString(); + + /** + * Generates the string expression from this node. Returned + * string doesn't have '"' without cancel ( \" ) and doesn't have + * newline.

+ * + * This method is useful to embed ptree objects as a string literal + * in source code. + * + * @return the flatten string which this node represents + */ + public String toFlattenString(); + + /** + * Returns the Identifier Number of this object + * + * @return the ID number of this object + */ + public int getObjectID(); + + /** + * Accepts a ParseTreeVisitor object as the role of a + * Visitor in the Visitor pattern, as the role of an Element in the + * Visitor pattern.

+ * + * This invoke an appropriate visit() method on the + * accepted visitor. + * + * @param visitor a visitor + */ + public void accept(ParseTreeVisitor visitor) throws ParseTreeException; + + /** + * Accepts a ParseTreeVisitor object as the role of a + * Visitor in the Visitor pattern, as the role of an Element in the + * Visitor pattern.

+ * + * This invoke an appropriate visit() method on each + * child ParseTree object with this visitor. + * + * @param visitor a visitor + */ + public void childrenAccept(ParseTreeVisitor visitor) + throws ParseTreeException; + +} -- cgit v1.2.1