| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.commons.jexl.parser.JJTParserState | 
 | 
 | 
| 1 |  /* | |
| 2 |   * Copyright 2002-2006 The Apache Software Foundation. | |
| 3 |   * | |
| 4 |   * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 |   * you may not use this file except in compliance with the License. | |
| 6 |   * You may obtain a copy of the License at | |
| 7 |   * | |
| 8 |   *      http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 |   * | |
| 10 |   * Unless required by applicable law or agreed to in writing, software | |
| 11 |   * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 |   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 |   * See the License for the specific language governing permissions and | |
| 14 |   * limitations under the License. | |
| 15 |   */ | |
| 16 |  /* Generated By:JJTree: Do not edit this line. JJTParserState.java */ | |
| 17 | ||
| 18 |  package org.apache.commons.jexl.parser; | |
| 19 | ||
| 20 |  import java.util.Stack; | |
| 21 | ||
| 22 |  class JJTParserState { | |
| 23 | private final Stack nodes; | |
| 24 | ||
| 25 | private final Stack marks; | |
| 26 | ||
| 27 | private int sp; // number of nodes on stack | |
| 28 | ||
| 29 | private int mk; // current mark | |
| 30 | ||
| 31 | private boolean node_created; | |
| 32 | ||
| 33 | 14 |      JJTParserState() { | 
| 34 | 14 |          nodes = new Stack(); | 
| 35 | 14 |          marks = new Stack(); | 
| 36 | 14 | sp = 0; | 
| 37 | 14 | mk = 0; | 
| 38 | 14 | } | 
| 39 | ||
| 40 |      /* | |
| 41 |       * Determines whether the current node was actually closed and pushed. This | |
| 42 |       * should only be called in the final user action of a node scope. | |
| 43 |       */ | |
| 44 |      boolean nodeCreated() { | |
| 45 | 0 |          return node_created; | 
| 46 | } | |
| 47 | ||
| 48 |      /* | |
| 49 |       * Call this to reinitialize the node stack. It is called automatically by | |
| 50 |       * the parser's ReInit() method. | |
| 51 |       */ | |
| 52 |      void reset() { | |
| 53 | 288 | nodes.removeAllElements(); | 
| 54 | 288 | marks.removeAllElements(); | 
| 55 | 288 | sp = 0; | 
| 56 | 288 | mk = 0; | 
| 57 | 288 | } | 
| 58 | ||
| 59 |      /* | |
| 60 |       * Returns the root node of the AST. It only makes sense to call this after | |
| 61 |       * a successful parse. | |
| 62 |       */ | |
| 63 |      Node rootNode() { | |
| 64 | 0 |          return (Node) nodes.elementAt(0); | 
| 65 | } | |
| 66 | ||
| 67 |      /* Pushes a node on to the stack. */ | |
| 68 |      void pushNode(Node n) { | |
| 69 | 2424 | nodes.push(n); | 
| 70 | 2424 | ++sp; | 
| 71 | 2424 | } | 
| 72 | ||
| 73 |      /* | |
| 74 |       * Returns the node on the top of the stack, and remove it from the stack. | |
| 75 |       */ | |
| 76 |      Node popNode() { | |
| 77 | 2142 |          if (--sp < mk) { | 
| 78 | 0 |              mk = ((Integer) marks.pop()).intValue(); | 
| 79 | } | |
| 80 | 2142 |          return (Node) nodes.pop(); | 
| 81 | } | |
| 82 | ||
| 83 |      /* Returns the node currently on the top of the stack. */ | |
| 84 |      Node peekNode() { | |
| 85 | 0 |          return (Node) nodes.peek(); | 
| 86 | } | |
| 87 | ||
| 88 |      /* | |
| 89 |       * Returns the number of children on the stack in the current node scope. | |
| 90 |       */ | |
| 91 |      int nodeArity() { | |
| 92 | 2150 |          return sp - mk; | 
| 93 | } | |
| 94 | ||
| 95 |      void clearNodeScope(Node n) { | |
| 96 | 22 |          while (sp > mk) { | 
| 97 | 2 | popNode(); | 
| 98 | } | |
| 99 | 10 | mk = ((Integer) marks.pop()).intValue(); | 
| 100 | 10 | } | 
| 101 | ||
| 102 |      void openNodeScope(Node n) { | |
| 103 | 2434 |          marks.push(new Integer(mk)); | 
| 104 | 2434 | mk = sp; | 
| 105 | 2434 | n.jjtOpen(); | 
| 106 | 2434 | } | 
| 107 | ||
| 108 |      /* | |
| 109 |       * A definite node is constructed from a specified number of children. That | |
| 110 |       * number of nodes are popped from the stack and made the children of the | |
| 111 |       * definite node. Then the definite node is pushed on to the stack. | |
| 112 |       */ | |
| 113 | void closeNodeScope(Node n, int num) { | |
| 114 | 274 | mk = ((Integer) marks.pop()).intValue(); | 
| 115 | 1065 |          while (num-- > 0) { | 
| 116 | 517 | Node c = popNode(); | 
| 117 | 517 | c.jjtSetParent(n); | 
| 118 | 517 | n.jjtAddChild(c, num); | 
| 119 | } | |
| 120 | 274 | n.jjtClose(); | 
| 121 | 274 | pushNode(n); | 
| 122 | 274 |          node_created = true; | 
| 123 | 274 | } | 
| 124 | ||
| 125 |      /* | |
| 126 |       * A conditional node is constructed if its condition is true. All the nodes | |
| 127 |       * that have been pushed since the node was opened are made children of the | |
| 128 |       * the conditional node, which is then pushed on to the stack. If the | |
| 129 |       * condition is false the node is not constructed and they are left on the | |
| 130 |       * stack. | |
| 131 |       */ | |
| 132 | void closeNodeScope(Node n, boolean condition) { | |
| 133 | 2150 |          if (condition) { | 
| 134 | 2150 |              int a = nodeArity(); | 
| 135 | 2150 | mk = ((Integer) marks.pop()).intValue(); | 
| 136 | 5923 |              while (a-- > 0) { | 
| 137 | 1623 | Node c = popNode(); | 
| 138 | 1623 | c.jjtSetParent(n); | 
| 139 | 1623 | n.jjtAddChild(c, a); | 
| 140 | } | |
| 141 | 2150 | n.jjtClose(); | 
| 142 | 2150 | pushNode(n); | 
| 143 | 2150 |              node_created = true; | 
| 144 |          } else { | |
| 145 | 0 |              mk = ((Integer) marks.pop()).intValue(); | 
| 146 | 0 |              node_created = false; | 
| 147 | } | |
| 148 | 2150 | } | 
| 149 | } | 
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |