Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6043e02

Browse files
committed
parse tree generation
1 parent df8b674 commit 6043e02

File tree

11 files changed

+7048
-3562
lines changed

11 files changed

+7048
-3562
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/* Generated By:JavaCC: Do not edit this line. JJTPlSqlState.java Version 6.0_1 */
2+
package parser;
3+
4+
public class JJTPlSqlState {
5+
private java.util.List<Node> nodes;
6+
private java.util.List<Integer> marks;
7+
8+
private int sp; // number of nodes on stack
9+
private int mk; // current mark
10+
private boolean node_created;
11+
12+
public JJTPlSqlState() {
13+
nodes = new java.util.ArrayList<Node>();
14+
marks = new java.util.ArrayList<Integer>();
15+
sp = 0;
16+
mk = 0;
17+
}
18+
19+
/* Determines whether the current node was actually closed and
20+
pushed. This should only be called in the final user action of a
21+
node scope. */
22+
public boolean nodeCreated() {
23+
return node_created;
24+
}
25+
26+
/* Call this to reinitialize the node stack. It is called
27+
automatically by the parser's ReInit() method. */
28+
public void reset() {
29+
nodes.clear();
30+
marks.clear();
31+
sp = 0;
32+
mk = 0;
33+
}
34+
35+
/* Returns the root node of the AST. It only makes sense to call
36+
this after a successful parse. */
37+
public Node rootNode() {
38+
return nodes.get(0);
39+
}
40+
41+
/* Pushes a node on to the stack. */
42+
public void pushNode(Node n) {
43+
nodes.add(n);
44+
++sp;
45+
}
46+
47+
/* Returns the node on the top of the stack, and remove it from the
48+
stack. */
49+
public Node popNode() {
50+
if (--sp < mk) {
51+
mk = marks.remove(marks.size()-1);
52+
}
53+
return nodes.remove(nodes.size()-1);
54+
}
55+
56+
/* Returns the node currently on the top of the stack. */
57+
public Node peekNode() {
58+
return nodes.get(nodes.size()-1);
59+
}
60+
61+
/* Returns the number of children on the stack in the current node
62+
scope. */
63+
public int nodeArity() {
64+
return sp - mk;
65+
}
66+
67+
68+
public void clearNodeScope(Node n) {
69+
while (sp > mk) {
70+
popNode();
71+
}
72+
mk = marks.remove(marks.size()-1);
73+
}
74+
75+
76+
public void openNodeScope(Node n) {
77+
marks.add(mk);
78+
mk = sp;
79+
n.jjtOpen();
80+
}
81+
82+
83+
/* A definite node is constructed from a specified number of
84+
children. That number of nodes are popped from the stack and
85+
made the children of the definite node. Then the definite node
86+
is pushed on to the stack. */
87+
public void closeNodeScope(Node n, int num) {
88+
mk = marks.remove(marks.size()-1);
89+
while (num-- > 0) {
90+
Node c = popNode();
91+
c.jjtSetParent(n);
92+
n.jjtAddChild(c, num);
93+
}
94+
n.jjtClose();
95+
pushNode(n);
96+
node_created = true;
97+
}
98+
99+
100+
/* A conditional node is constructed if its condition is true. All
101+
the nodes that have been pushed since the node was opened are
102+
made children of the conditional node, which is then pushed
103+
on to the stack. If the condition is false the node is not
104+
constructed and they are left on the stack. */
105+
public void closeNodeScope(Node n, boolean condition) {
106+
if (condition) {
107+
int a = nodeArity();
108+
mk = marks.remove(marks.size()-1);
109+
while (a-- > 0) {
110+
Node c = popNode();
111+
c.jjtSetParent(n);
112+
n.jjtAddChild(c, a);
113+
}
114+
n.jjtClose();
115+
pushNode(n);
116+
node_created = true;
117+
} else {
118+
mk = marks.remove(marks.size()-1);
119+
node_created = false;
120+
}
121+
}
122+
}
123+
/* JavaCC - OriginalChecksum=eee7b1d101280e9bb519abeec26d9bcb (do not edit this line) */

‎PLSQL2Java/src/parser/Node.java‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* Generated By:JJTree: Do not edit this line. Node.java Version 6.0 */
2+
/* JavaCCOptions:MULTI=false,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
3+
package parser;
4+
5+
/* All AST nodes must implement this interface. It provides basic
6+
machinery for constructing the parent and child relationships
7+
between nodes. */
8+
9+
public
10+
interface Node {
11+
12+
/** This method is called after the node has been made the current
13+
node. It indicates that child nodes can now be added to it. */
14+
public void jjtOpen();
15+
16+
/** This method is called after all the child nodes have been
17+
added. */
18+
public void jjtClose();
19+
20+
/** This pair of methods are used to inform the node of its
21+
parent. */
22+
public void jjtSetParent(Node n);
23+
public Node jjtGetParent();
24+
25+
/** This method tells the node to add its argument to the node's
26+
list of children. */
27+
public void jjtAddChild(Node n, int i);
28+
29+
/** This method returns a child node. The children are numbered
30+
from zero, left to right. */
31+
public Node jjtGetChild(int i);
32+
33+
/** Return the number of children the node has. */
34+
public int jjtGetNumChildren();
35+
36+
public int getId();
37+
}
38+
/* JavaCC - OriginalChecksum=325004c75c4d67cb790a649f5208602a (do not edit this line) */

‎PLSQL2Java/src/parser/ParseException.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,4 @@ static String add_escapes(String str) {
184184
}
185185

186186
}
187-
/* JavaCC - OriginalChecksum=3d3b87c136d4ef51cb621720c51a0611 (do not edit this line) */
187+
/* JavaCC - OriginalChecksum=f4a1858459a06e38b9b008f4564f0c8a (do not edit this line) */

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /