Exemple #1
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // c_compound_literal_head ::= c_round_open c_round_close
   {
     CompoundLiteral RESULT = null;
     Token rl =
         (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).value;
     Token rr = (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     RESULT =
         new CompoundLiteral(
             parser.missing("compound literal", "type name", rl.getLeft(), rr.getRight()), null);
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "c_compound_literal_head",
                 34,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
Exemple #2
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // c_postfix_expression ::= c_compound_literal
   {
     Expression RESULT = null;
     CompoundLiteral c =
         (CompoundLiteral) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     RESULT = c;
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "c_postfix_expression",
                 32,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
 public boolean forLoopHasNext(
     @Nullable XExpression before,
     @Nullable XExpression separator,
     @NonNull CharSequence indentation) {
   if (!ignore()) {
     if (forLoopStack.peek() != null) {
       int remaining = forLoopStack.peek();
       boolean first = false;
       if (remaining < 0) {
         first = true;
         remaining = remaining * -1;
       }
       if (remaining > 0) {
         forLoopStack.set(forLoopStack.size() - 1, remaining - 1);
         if (first) {
           if (before != null) acceptExpression(before, indentation);
         } else if (separator != null) {
           acceptExpression(separator, indentation, true);
         }
         return true;
       }
     }
   }
   return false;
 }
  public static boolean isBalanced(String s) {
    Stack<Character> stack = new Stack<Character>();

    for (int i = 0; i < s.length(); ++i) {
      char c = s.charAt(i);
      if (c == '{' || c == '[' || c == '(') stack.push(c);
      else if (c == '}') {
        if (!stack.isEmpty() && stack.peek() == '{') {
          stack.pop();
        } else return false;
      } else if (c == ']') {
        if (!stack.isEmpty() && stack.peek() == '[') {
          stack.pop();
        } else return false;
      } else if (c == ')') {
        if (!stack.isEmpty() && stack.peek() == '(') {
          stack.pop();
        } else return false;
      } else {

      }
    }

    return stack.isEmpty();
  }
  private void visitCase(IASTStatement statement) throws ScopeTraceException {
    /* TODO: specific params: don't show the switch part (only the case argument) */

    ScopeInfo scope = _scopeStack.peek();
    if (!(scope._statement instanceof IASTSwitchStatement)) {
      if (!((scope._statement instanceof IASTCaseStatement)
          || (scope._statement instanceof IASTDefaultStatement))) {
        throw new ScopeTraceException(
            "Lost track of stack (in case), found:" + scope._statement); // $NON-NLS-1$
      }

      _scopeStack.pop();
      scope = _scopeStack.peek();
    }

    if (!(scope._statement instanceof IASTSwitchStatement)) {
      throw new ScopeTraceException(
          "Lost track of stack (in case2), found:" + scope._statement); // $NON-NLS-1$
    }

    String hint = ""; // $NON-NLS-1$
    if (statement instanceof IASTCaseStatement) {
      IASTExpression cond = ((IASTCaseStatement) statement).getExpression();
      if (cond != null) hint = cond.getRawSignature();
      hint = "case: " + hint; // $NON-NLS-1$
    } else // default
    {
      hint = "default"; // $NON-NLS-1$
    }

    int startLoc = statement.getFileLocation().getNodeOffset();
    _scopeStack.push(new ScopeInfo(scope._str + " - " + hint, startLoc, statement)); // $NON-NLS-1$
  }
Exemple #6
0
  private void adjustLevel(BlockType type, String typeSpec, int level) {
    for (ListState previousState = listState.peek();
        level != previousState.level || previousState.type != type;
        previousState = listState.peek()) {

      if (level > previousState.level) {
        if (!previousState.openItem) {
          builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
          previousState.openItem = true;
        }

        Attributes blockAttributes = new Attributes();
        computeAttributes(blockAttributes, type, typeSpec);

        listState.push(new ListState(previousState.level + 1, type));
        builder.beginBlock(type, blockAttributes);
      } else {
        closeOne();
        if (listState.isEmpty()) {
          Attributes blockAttributes = new Attributes();
          computeAttributes(blockAttributes, type, typeSpec);

          listState.push(new ListState(1, type));
          builder.beginBlock(type, blockAttributes);
        }
      }
    }
  }
Exemple #7
0
    @SuppressWarnings("rawtypes")
    @Override
    protected Object createNode(Object key, Object value) {
      if (getCurrent() == null && stack.peek() == BuilderMode.OBJECT) {
        throw new IllegalArgumentException(
            "only call to [element { }] is allowed when creating array");
      }

      try {
        int retVal = 0;
        if (stack.peek().equals(BuilderMode.ARRAY)) {
          writeObject();
          retVal = 1;
        }
        if (value instanceof Collection) {
          Collection c = (Collection) value;
          writer.key(String.valueOf(key));
          handleCollectionRecurse(c);
        } else {
          writer.key(String.valueOf(key));
          json.convertAnother(value); // .value(value);
        }
        return retVal != 0 ? retVal : null;
      } catch (JSONException e) {
        throw new IllegalArgumentException("invalid element");
      }
    }
 private void processText(Segment segment) {
   String inputValue = segment.toString();
   String outputValue = inputValue;
   try {
     if (stack.isEmpty()) {
       // This can happen for whitespace outside of the root element.
       // outputValue = filterText( null, inputValue );
     } else {
       String tagType = stack.peek().getTag().getAttributeValue("type");
       String tagName = stack.peek().getTag().getName();
       if (SCRIPTTAG.equals(tagName)
           && JSTYPES.contains(tagType)
           && config != null
           && !config.getSelectors().isEmpty()) {
         // embedded javascript content
         outputValue = UrlRewriteUtil.filterJavaScript(inputValue, config, this, REGEX_COMPILER);
       } else {
         outputValue = filterText(stack.peek().getQName(), inputValue, null);
       }
     }
     if (outputValue == null) {
       outputValue = inputValue;
     }
   } catch (Exception e) {
     LOG.failedToFilterValue(inputValue, null, e);
   }
   writer.write(outputValue);
 }
Exemple #9
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // c_external_declaration ::= n_module
   {
     ExternalDeclaration RESULT = null;
     Module d = (Module) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     parser.scopes().clean();
     RESULT = d;
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "c_external_declaration",
                 136,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
  /** @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String) */
  public void processingInstruction(String target, String data) throws SAXException {
    if (inModification && charBuf.length() > 0) {
      final String normalized = charBuf.getNormalizedString(FastStringBuffer.SUPPRESS_BOTH);
      if (normalized.length() > 0) {
        final Text text = doc.createTextNode(normalized);
        if (stack.isEmpty()) {

          if (LOG.isDebugEnabled()) {
            LOG.debug("appending text to fragment: " + text.getData());
          }

          contents.add(text);
        } else {
          final Element last = stack.peek();
          last.appendChild(text);
        }
      }
      charBuf.setLength(0);
    }
    if (inModification) {
      final ProcessingInstruction pi = doc.createProcessingInstruction(target, data);
      if (stack.isEmpty()) {
        contents.add(pi);
      } else {
        final Element last = stack.peek();
        last.appendChild(pi);
      }
    }
  }
 /* (non-Javadoc)
  * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
  */
 public void comment(char[] ch, int start, int length) throws SAXException {
   if (inModification && charBuf.length() > 0) {
     final String normalized = charBuf.getNormalizedString(FastStringBuffer.SUPPRESS_BOTH);
     if (normalized.length() > 0) {
       final Text text = doc.createTextNode(normalized);
       if (stack.isEmpty()) {
         // LOG.debug("appending text to fragment: " + text.getData());
         contents.add(text);
       } else {
         final Element last = stack.peek();
         last.appendChild(text);
       }
     }
     charBuf.setLength(0);
   }
   if (inModification) {
     final Comment comment = doc.createComment(new String(ch, start, length));
     if (stack.isEmpty()) {
       contents.add(comment);
     } else {
       final Element last = stack.peek();
       last.appendChild(comment);
     }
   }
 }
Exemple #12
0
 public void setUndoStart(String name, boolean merge) {
   if (!undoEnabled) return;
   commitToDB();
   if (merge && !undoStack.isEmpty())
     if ((undoStack.peek() != null) && (undoStack.peek().name.equals(name))) return;
   undoStack.push(new UndoRow(name, latestUndoRow(), null));
 }
Exemple #13
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // n_binary_component ::= NK_COMPONENT c_curly_open c_curly_close
   {
     BinaryComponent RESULT = null;
     Token rl =
         (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 2)).value;
     Token rr = (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     RESULT =
         new BinaryComponent(
             parser.missing("binary component", "identifier", rl.getRight()), null, null);
     RESULT.setLeft(rl.getLeft());
     RESULT.setRight(rr.getRight());
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "n_binary_component",
                 194,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 2)),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
 public boolean isValid(String s) {
   Stack<Character> stack = new Stack<Character>();
   for (char str : s.toCharArray()) {
     if (str == '(' || str == '[' || str == '{') {
       stack.push(str);
     } else if (str == ')') {
       if (!stack.isEmpty() && stack.peek() == '(') {
         stack.pop();
       } else {
         return false;
       }
     } else if (str == ']') {
       if (!stack.isEmpty() && stack.peek() == '[') {
         stack.pop();
       } else {
         return false;
       }
     } else if (str == '}') {
       if (!stack.isEmpty() && stack.peek() == '{') {
         stack.pop();
       } else {
         return false;
       }
     }
   }
   return stack.isEmpty();
 }
  public void sort() {
    if (stack.isEmpty()) {
      return;
    }

    helper.push(stack.pop());

    boolean sorted = false;
    while (!sorted) {
      while (!stack.isEmpty() && stack.peek() > helper.peek()) {
        helper.push(stack.pop());

        if (stack.isEmpty()) {
          while (!helper.isEmpty()) {
            stack.push(helper.pop());
          }
          sorted = true;
          break;
        }
      }
      if (!sorted) {
        int temp = stack.pop();
        while (!helper.isEmpty() && helper.peek() > temp) {
          stack.push(helper.pop());
        }
        helper.push(temp);
      }
    }
  }
  /**
   * Builds a condition tree starting from a database cursor. The cursor should point to rows
   * representing the nodes of the tree.
   *
   * @param cursor Cursor pointing to the first of a bunch or rows. Each rows should contains 1 tree
   *     node.
   * @return A condition tree.
   */
  public static ConditionsTreeNode buildTreeFromDB(Cursor cursor) {
    Stack<ConditionsTreeNode> stack = new Stack<ConditionsTreeNode>();
    ConditionsTreeNode tmp = null;

    // root node
    if (cursor.moveToFirst()) {
      tmp = buildNodeFromRow(cursor);
      stack.push(tmp);
    }

    // other nodes
    while (cursor.moveToNext()) {
      tmp = buildNodeFromRow(cursor);
      if (tmp.mRightMPTTMarker < stack.peek().mRightMPTTMarker) {
        stack.peek().mLeft = tmp;
        stack.push(tmp);
      } else {
        while (stack.peek().mRightMPTTMarker < tmp.mRightMPTTMarker) {
          stack.pop();
        }
        stack.peek().mRight = tmp;
      }
    }
    return tmp;
  }
 public static void flattenIterative1(TreeNode root) {
   Stack<TreeNode> stack = new Stack<>();
   while (root != null) {
     if (root.left != null) {
       stack.push(root);
       root = root.left;
     } else if (root.right != null) {
       stack.push(root);
       root = root.right;
     } else if (!stack.isEmpty()) {
       TreeNode end = root;
       while (!stack.isEmpty()
           && (stack.peek().left == null
               || (stack.peek().left != null && stack.peek().left != root))) {
         root = stack.pop();
       }
       if (stack.isEmpty()) root = root.right;
       else {
         TreeNode top = stack.peek();
         TreeNode temp = top.right;
         top.right = root;
         top.left = null;
         end.right = temp;
         root = (end.left != null || temp == null) ? end : temp;
       }
     } else root = root.right;
   }
 }
Exemple #18
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // n_component_list ::= n_component_list P_COMMA n_component_ref
   {
     ComponentList RESULT = null;
     ComponentList s =
         (ComponentList)
             ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 2)).value;
     Component i = (Component) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     RESULT = s.add(i);
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "n_component_list",
                 189,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 2)),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
Exemple #19
0
    @Override
    protected Object createNode(Object name) {
      int retVal = 1;
      try {
        if (start) {
          start = false;
          writeObject();
        } else {
          if (getCurrent() == null && stack.peek() == BuilderMode.OBJECT) {
            throw new IllegalArgumentException(
                "only call to [element { }] is allowed when creating array");
          }
          if (stack.peek() == BuilderMode.ARRAY) {
            writeObject();
            retVal = 2;
          }
          writer.key(String.valueOf(name)).array();
          stack.push(BuilderMode.ARRAY);
        }
      } catch (JSONException e) {
        throw new IllegalArgumentException("invalid element");
      }

      return retVal;
    }
Exemple #20
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // c_compound_statement ::= c_curly_open c_curly_close
   {
     CompoundStatement RESULT = null;
     Token lr =
         (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).value;
     Token rr = (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     CompoundStatement result = new CompoundStatement();
     RESULT = result;
     result.setRanges(lr, rr);
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "c_compound_statement",
                 124,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
 private void removeStackObj() throws XMLStreamException {
   if (!stackObj.empty()) {
     if (topNestedArrayObj == null) {
       stackObj.pop();
     } else {
       if (stackObj.peek().equals(topNestedArrayObj)) {
         topNestedArrayObj = null;
         processedJsonObject.clear();
         stackObj.pop();
       } else {
         processedJsonObject.push(stackObj.pop());
       }
     }
     if (!stackObj.empty()) {
       localName = stackObj.peek().getName();
     } else {
       localName = "";
     }
   } else {
     System.out.println("stackObj is empty");
     throw new XMLStreamException(
         "Error while processing input JSON stream, JSON request may not valid ,"
             + " it may has more end object characters ");
   }
 }
Exemple #22
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // c_type_specifier_notn ::= K_CHAR
   {
     TypeSpecifier RESULT = null;
     Token k = (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     RESULT = new PrimitiveSpecifier(k, PrimitiveSpecifier.Type.CHAR);
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "c_type_specifier_notn",
                 88,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
 public boolean isValid(String s) {
   if (s == null || s.length() == 0) return true;
   Stack<Character> stack = new Stack<Character>();
   for (int i = 0; i < s.length(); i++) {
     char c = s.charAt(i);
     switch (c) {
       case '(':
       case '[':
       case '{':
         stack.push(c);
         break;
       case ')':
         if (!stack.isEmpty() && stack.peek() == '(') stack.pop();
         else return false;
         break;
       case ']':
         if (!stack.isEmpty() && stack.peek() == '[') stack.pop();
         else return false;
         break;
       case '}':
         if (!stack.isEmpty() && stack.peek() == '{') stack.pop();
         else return false;
         break;
       default:
         return false;
     }
   }
   return stack.isEmpty();
 }
 public int longestValidParentheses(String s) {
   int cur = 0;
   int max = 0;
   if (s != null) {
     Stack<Character> st = new Stack<Character>();
     int i = 0;
     while (i < s.length()) {
       char c = s.charAt(i);
       if (c == '(' || c == '[' || c == '{') st.push(c);
       else if (st.isEmpty()
           || (st.peek() != '[' && c == ']')
           || (st.peek() != '{' && c == '}')
           || (st.peek() != '(' && c == ')')) {
         max = (max < cur) ? cur : max;
         cur = 0;
         st.push(c);
       } else {
         st.pop();
         cur += 2;
       }
       i++;
     }
   }
   max = (max < cur) ? cur : max;
   return max;
 }
Exemple #25
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // n_module_implementation ::= NK_IMPLEMENTATION c_curly_open_recycle n_external_definitions
   // c_curly_close
   {
     NesCExternalDefinitionList RESULT = null;
     Token rl =
         (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 3)).value;
     NesCExternalDefinitionList e =
         (NesCExternalDefinitionList)
             ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).value;
     Token rr = (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     RESULT = e;
     RESULT.setRanges(rl, rr);
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "n_module_implementation",
                 177,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 3)),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
Exemple #26
0
  /**
   * Convert an arithmetic expression in infix notation (e.g 1+2) to postfix notation (e.g 12+) Only
   * simple expressions not containing brackets are supported. <br>
   * A description of the algorithm used to accomplish this task can be found at:
   * http://scriptasylum.com/tutorials/infix_postfix/algorithms/infix-postfix/index.htm <br>
   * Basically the list of {@code Tokens} is being scanned from left to right, all operands
   * (numbers) are pushed onto a {@code Stack}. If the {@code Token} is an operator it is compared
   * to the operator on top of the {@code Stack}. If the operator on top of the {@code Stack} has a
   * higher or equal weight than the current operator, the top of the {@code Stack} is pushed to the
   * postfix list. Therefore the operators with higher weight are going to be executed first when
   * the expression is evaluated. This process continues until the top of the {@code Stack} has a
   * lower weight than the current operator or the {@code Stack} is empty. Then the current operator
   * is pushed onto the {@code Stack}.
   *
   * @param tokenizer The {@code Tokenizer} which will be converted to postfix. It must not be
   *     {@code null}.
   * @return The resulting {@code List} of {@code Token}s in postfix order.
   */
  private static List<Token> postfix(Tokenizer tokenizer) {
    Stack<Token> stack = new Stack<>();
    List<Token> postfix = new LinkedList<>();
    BiPredicate<Token, Token> hasHigherOrEqualWeight =
        (t1, t2) ->
            Operators.getOpWeight(t1.getOperator()) - Operators.getOpWeight(t2.getOperator()) >= 0;

    while (tokenizer.hasNext()) {
      Token t = tokenizer.next();
      switch (t.getType()) {
        case NUMBER:
          postfix.add(t);
          break;
        case OPERATOR:
          if (!stack.isEmpty() && hasHigherOrEqualWeight.test(stack.peek(), t)) {
            while (!stack.isEmpty() && hasHigherOrEqualWeight.test(stack.peek(), t)) {
              postfix.add(stack.pop());
            }
            stack.push(t);
          } else {
            stack.push(t);
          }
          break;
        case OPENING_BRACKET:
        case CLOSING_BRACKET:
          throw new IllegalArgumentException(
              "Cannot create postfix expression if the source contains brackets.");
      }
    }

    while (!stack.isEmpty()) postfix.add(stack.pop());

    return postfix;
  }
Exemple #27
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // c_declaration_specifiers_notp_tn_nosc ::= c_declaration_specifiers_notp_tn_nosc_norg
   {
     DeclarationSpecifierList RESULT = null;
     DeclarationSpecifierList d =
         (DeclarationSpecifierList) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     RESULT = d;
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "c_declaration_specifiers_notp_tn_nosc",
                 64,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
Exemple #28
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // c_selection_statement ::= K_SWITCH error c_statement
   {
     Statement RESULT = null;
     Token rl =
         (Token) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 2)).value;
     Statement s = (Statement) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     SwitchStatement result =
         new SwitchStatement(
             parser.errorNode(
                 "switch header", "expression", rl.getRight(), s.getRange().getLeft()),
             s);
     RESULT = result;
     result.setLeft(rl.getLeft());
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "c_selection_statement",
                 128,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 2)),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }
 public boolean ignore() {
   if (ignoreStack.isEmpty()) {
     if (printNext.isEmpty()) return false;
     return !printNext.peek().booleanValue();
   }
   return ignoreStack.peek().booleanValue();
 }
Exemple #30
0
 public final java_cup.runtime.Symbol do_action(
     int CUP$parser$act_num,
     java_cup.runtime.lr_parser CUP$parser$parser,
     java.util.Stack CUP$parser$stack,
     int CUP$parser$top,
     parser parser)
     throws java.lang.Exception {
   java_cup.runtime.Symbol CUP$parser$result;
   // c_abstract_declarator ::= c_pointer c_direct_abstract_declarator
   {
     AbstractDeclarator RESULT = null;
     Pointer p =
         (Pointer)
             ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).value;
     AbstractDeclarator d =
         (AbstractDeclarator) ((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
     RESULT = new PointerAbstractDeclarator(p, d);
     CUP$parser$result =
         parser
             .getSymbolFactory()
             .newSymbol(
                 "c_abstract_declarator",
                 113,
                 ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)),
                 ((java_cup.runtime.Symbol) CUP$parser$stack.peek()),
                 RESULT);
   }
   return CUP$parser$result;
 }