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