JJTEJBQLState.java

00001 /* Generated By:JJTree: Do not edit this line. JJTEJBQLState.java */
00002 
00003 package org.objectweb.jonas_ejb.deployment.ejbql;
00004 
00005 class JJTEJBQLState {
00006   private java.util.Stack nodes;
00007   private java.util.Stack marks;
00008 
00009   private int sp;               // number of nodes on stack
00010   private int mk;               // current mark
00011   private boolean node_created;
00012 
00013   JJTEJBQLState() {
00014     nodes = new java.util.Stack();
00015     marks = new java.util.Stack();
00016     sp = 0;
00017     mk = 0;
00018   }
00019 
00020   /* Determines whether the current node was actually closed and
00021      pushed.  This should only be called in the final user action of a
00022      node scope.  */
00023   boolean nodeCreated() {
00024     return node_created;
00025   }
00026 
00027   /* Call this to reinitialize the node stack.  It is called
00028      automatically by the parser's ReInit() method. */
00029   void reset() {
00030     nodes.removeAllElements();
00031     marks.removeAllElements();
00032     sp = 0;
00033     mk = 0;
00034   }
00035 
00036   /* Returns the root node of the AST.  It only makes sense to call
00037      this after a successful parse. */
00038   Node rootNode() {
00039     return (Node)nodes.elementAt(0);
00040   }
00041 
00042   /* Pushes a node on to the stack. */
00043   void pushNode(Node n) {
00044     nodes.push(n);
00045     ++sp;
00046   }
00047 
00048   /* Returns the node on the top of the stack, and remove it from the
00049      stack.  */
00050   Node popNode() {
00051     if (--sp < mk) {
00052       mk = ((Integer)marks.pop()).intValue();
00053     }
00054     return (Node)nodes.pop();
00055   }
00056 
00057   /* Returns the node currently on the top of the stack. */
00058   Node peekNode() {
00059     return (Node)nodes.peek();
00060   }
00061 
00062   /* Returns the number of children on the stack in the current node
00063      scope. */
00064   int nodeArity() {
00065     return sp - mk;
00066   }
00067 
00068 
00069   void clearNodeScope(Node n) {
00070     while (sp > mk) {
00071       popNode();
00072     }
00073     mk = ((Integer)marks.pop()).intValue();
00074   }
00075 
00076 
00077   void openNodeScope(Node n) {
00078     marks.push(new Integer(mk));
00079     mk = sp;
00080     n.jjtOpen();
00081   }
00082 
00083 
00084   /* A definite node is constructed from a specified number of
00085      children.  That number of nodes are popped from the stack and
00086      made the children of the definite node.  Then the definite node
00087      is pushed on to the stack. */
00088   void closeNodeScope(Node n, int num) {
00089     mk = ((Integer)marks.pop()).intValue();
00090     while (num-- > 0) {
00091       Node c = popNode();
00092       c.jjtSetParent(n);
00093       n.jjtAddChild(c, num);
00094     }
00095     n.jjtClose();
00096     pushNode(n);
00097     node_created = true;
00098   }
00099 
00100 
00101   /* A conditional node is constructed if its condition is true.  All
00102      the nodes that have been pushed since the node was opened are
00103      made children of the the conditional node, which is then pushed
00104      on to the stack.  If the condition is false the node is not
00105      constructed and they are left on the stack. */
00106   void closeNodeScope(Node n, boolean condition) {
00107     if (condition) {
00108       int a = nodeArity();
00109       mk = ((Integer)marks.pop()).intValue();
00110       while (a-- > 0) {
00111         Node c = popNode();
00112         c.jjtSetParent(n);
00113         n.jjtAddChild(c, a);
00114       }
00115       n.jjtClose();
00116       pushNode(n);
00117       node_created = true;
00118     } else {
00119       mk = ((Integer)marks.pop()).intValue();
00120       node_created = false;
00121     }
00122   }
00123 }

Generated on Tue Feb 15 15:05:46 2005 for JOnAS by  doxygen 1.3.9.1