コード例 #1
0
 /**
  * Pushes a new operator onto the opp stack, resolving existing opps as needed.
  *
  * @param node The operator node
  */
 private void pushOpp(OppNode node) {
   // If node is null then it's just a group marker
   if (node == null) {
     oppStack.add(0, node);
     return;
   }
   while (true) {
     if (oppStack.size() == 0) break;
     OppNode top = oppStack.get(0);
     // If the top is a spacer then don't pop
     // anything
     if (top == null) break;
     // If the top node has a lower precedence then
     // let it stay
     if (top.getPrecedence() < node.getPrecedence()) break;
     // Remove the top node
     oppStack.remove(0);
     // Let it fill its branches
     top.popValues(nodeStack);
     // Stick it on the resolved node stack
     nodeStack.add(0, top);
   }
   // Add the new node to the opp stack
   oppStack.add(0, node);
 }
コード例 #2
0
 /** Resolves all pending opp nodes on the stack until the next group marker is reached. */
 private void resolveGroup() {
   OppNode top = null;
   while ((top = oppStack.remove(0)) != null) {
     // Let it fill its branches
     top.popValues(nodeStack);
     // Stick it on the resolved node stack
     nodeStack.add(0, top);
   }
 }