Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

JJTPredicateParserState.java

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

Generated at Thu Feb 7 06:48:49 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001