[193] | 1 | /* Generated By:JavaCC: Do not edit this line. JJTFramclipseNonScriptParserState.java Version 4.2 */ |
---|
| 2 | package com.framsticks.framclipse.internal.parser; |
---|
| 3 | |
---|
| 4 | public class JJTFramclipseNonScriptParserState { |
---|
| 5 | private java.util.List nodes; |
---|
| 6 | private java.util.List 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 JJTFramclipseNonScriptParserState() { |
---|
| 13 | nodes = new java.util.ArrayList(); |
---|
| 14 | marks = new java.util.ArrayList(); |
---|
| 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 (Node)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 = ((Integer)marks.remove(marks.size()-1)).intValue(); |
---|
| 52 | } |
---|
| 53 | return (Node)nodes.remove(nodes.size()-1); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | /* Returns the node currently on the top of the stack. */ |
---|
| 57 | public Node peekNode() { |
---|
| 58 | return (Node)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 = ((Integer)marks.remove(marks.size()-1)).intValue(); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | public void openNodeScope(Node n) { |
---|
| 77 | marks.add(new Integer(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 = ((Integer)marks.remove(marks.size()-1)).intValue(); |
---|
| 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 = ((Integer)marks.remove(marks.size()-1)).intValue(); |
---|
| 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 = ((Integer)marks.remove(marks.size()-1)).intValue(); |
---|
| 119 | node_created = false; |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | } |
---|
| 123 | /* JavaCC - OriginalChecksum=ed2f6ddf30a55603bf51a90fa2bd55b9 (do not edit this line) */ |
---|