1 2 package org.codehaus.aspectwerkz.annotation.expression.ast; 3 4 class JJTAnnotationParserState { 5 private java.util.Stack nodes; 6 7 private java.util.Stack marks; 8 9 private int sp; 11 private int mk; 13 private boolean node_created; 14 15 JJTAnnotationParserState() { 16 nodes = new java.util.Stack (); 17 marks = new java.util.Stack (); 18 sp = 0; 19 mk = 0; 20 } 21 22 26 boolean nodeCreated() { 27 return node_created; 28 } 29 30 33 void reset() { 34 nodes.removeAllElements(); 35 marks.removeAllElements(); 36 sp = 0; 37 mk = 0; 38 } 39 40 43 Node rootNode() { 44 return (Node) nodes.elementAt(0); 45 } 46 47 48 void pushNode(Node n) { 49 nodes.push(n); 50 ++sp; 51 } 52 53 56 Node popNode() { 57 if (--sp < mk) { 58 mk = ((Integer ) marks.pop()).intValue(); 59 } 60 return (Node) nodes.pop(); 61 } 62 63 64 Node peekNode() { 65 return (Node) nodes.peek(); 66 } 67 68 71 int nodeArity() { 72 return sp - mk; 73 } 74 75 void clearNodeScope(Node n) { 76 while (sp > mk) { 77 popNode(); 78 } 79 mk = ((Integer ) marks.pop()).intValue(); 80 } 81 82 void openNodeScope(Node n) { 83 marks.push(new Integer (mk)); 84 mk = sp; 85 n.jjtOpen(); 86 } 87 88 92 void closeNodeScope(Node n, int num) { 93 mk = ((Integer ) marks.pop()).intValue(); 94 while (num-- > 0) { 95 Node c = popNode(); 96 c.jjtSetParent(n); 97 n.jjtAddChild(c, num); 98 } 99 n.jjtClose(); 100 pushNode(n); 101 node_created = true; 102 } 103 104 109 void closeNodeScope(Node n, boolean condition) { 110 if (condition) { 111 int a = nodeArity(); 112 mk = ((Integer ) marks.pop()).intValue(); 113 while (a-- > 0) { 114 Node c = popNode(); 115 c.jjtSetParent(n); 116 n.jjtAddChild(c, a); 117 } 118 n.jjtClose(); 119 pushNode(n); 120 node_created = true; 121 } else { 122 mk = ((Integer ) marks.pop()).intValue(); 123 node_created = false; 124 } 125 } 126 } | Popular Tags |