|
| 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) */ |
0 commit comments