blob: 89a4497878fc9bd797c3b15e1a8543d4d616b612 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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.<p>
*
* 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 <code>ParseTreeVisitor</code> object as the role of a
* Visitor in the Visitor pattern, as the role of an Element in the
* Visitor pattern.<p>
*
* This invoke an appropriate <code>visit()</code> method on the
* accepted visitor.
*
* @param visitor a visitor
*/
public void accept(ParseTreeVisitor visitor) throws ParseTreeException;
/**
* Accepts a <code>ParseTreeVisitor</code> object as the role of a
* Visitor in the Visitor pattern, as the role of an Element in the
* Visitor pattern.<p>
*
* This invoke an appropriate <code>visit()</code> method on each
* child <code>ParseTree</code> object with this visitor.
*
* @param visitor a visitor
*/
public void childrenAccept(ParseTreeVisitor visitor)
throws ParseTreeException;
}
|