Package org.antlr.v4.tool.ast

Examples of org.antlr.v4.tool.ast.ActionAST


                        new AttributeChecks(g, r, alt, a, a.token);
                    checker.examineAction();
                }
            }
            for (GrammarAST e : r.exceptions) {
        ActionAST a = (ActionAST)e.getChild(1);
                AttributeChecks checker = new AttributeChecks(g, r, null, a, a.token);
                checker.examineAction();
      }
      if ( r.finallyAction!=null ) {
        AttributeChecks checker =
View Full Code Here


    // walk alt info records and set their altAST to point to appropriate ALT subtree
    // from freshly created AST
    setAltASTPointers(r, t);

    // update Rule to just one alt and add prec alt
    ActionAST arg = (ActionAST)r.ast.getFirstChildWithType(ANTLRParser.ARG_ACTION);
    if ( arg!=null ) {
      r.args = ScopeParser.parseTypedArgList(arg, arg.getText(), g);
      r.args.type = AttributeDict.DictType.ARG;
      r.args.ast = arg;
      arg.resolver = r.alt[1]; // todo: isn't this Rule or something?
    }
View Full Code Here

      r.locals.ast = locals;
    }

    for (GrammarAST a : actions) {
      // a = ^(AT ID ACTION)
      ActionAST action = (ActionAST) a.getChild(1);
      r.namedActions.put(a.getChild(0).getText(), action);
      action.resolver = r;
    }
  }
View Full Code Here

  public String getPredicateDisplayString(SemanticContext.Predicate pred) {
    if ( indexToPredMap==null ) {
      indexToPredMap = getIndexToPredicateMap();
    }
    ActionAST actionAST = indexToPredMap.get(pred.predIndex);
    return actionAST.getText();
  }
View Full Code Here

//    System.out.println("setAltAssoc: op " + alt + ": " + t.getText()+", assoc="+assoc);
  }

  @Override
  public void binaryAlt(AltAST originalAltTree, int alt) {
    AltAST altTree = (AltAST)originalAltTree.dupTree();
    String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null;

    String label = null;
    boolean isListLabel = false;
    GrammarAST lrlabel = stripLeftRecursion(altTree);
View Full Code Here

    //System.out.println("binaryAlt " + alt + ": " + altText + ", rewrite=" + rewriteText);
  }

  @Override
  public void prefixAlt(AltAST originalAltTree, int alt) {
    AltAST altTree = (AltAST)originalAltTree.dupTree();
    stripAltLabel(altTree);

    int nextPrec = precedence(alt);
    // rewrite e to be e_[prec]
    altTree = addPrecedenceArgToRules(altTree, nextPrec);
View Full Code Here

   * {@code (BLOCK (ALT .))} or {@code (BLOCK (ALT 'a') (ALT .))}.
   */
  public static boolean blockHasWildcardAlt(@NotNull GrammarAST block) {
    for (Object alt : block.getChildren()) {
      if ( !(alt instanceof AltAST) ) continue;
      AltAST altAST = (AltAST)alt;
      if ( altAST.getChildCount()==1 || (altAST.getChildCount() == 2 && altAST.getChild(0).getType() == ANTLRParser.ELEMENT_OPTIONS) ) {
        Tree e = altAST.getChild(altAST.getChildCount() - 1);
        if ( e.getType()==ANTLRParser.WILDCARD ) {
          return true;
        }
      }
    }
View Full Code Here

    //System.out.println("prefixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText);
  }

  @Override
  public void suffixAlt(AltAST originalAltTree, int alt) {
    AltAST altTree = (AltAST)originalAltTree.dupTree();
    String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null;

    String label = null;
    boolean isListLabel = false;
    GrammarAST lrlabel = stripLeftRecursion(altTree);
View Full Code Here

//    System.out.println("suffixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText);
  }

  @Override
  public void otherAlt(AltAST originalAltTree, int alt) {
    AltAST altTree = (AltAST)originalAltTree.dupTree();
    stripAltLabel(altTree);
    String altText = text(altTree);
    String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null;
    LeftRecursiveRuleAltInfo a =
      new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree);
View Full Code Here

    end.loopBackState = loop;

    plusAST.atnState = loop;
    epsilon(blkEnd, loop);    // blk can see loop back

    BlockAST blkAST = (BlockAST)plusAST.getChild(0);
    if ( ((QuantifierAST)plusAST).isGreedy() ) {
      if (expectNonGreedy(blkAST)) {
        g.tool.errMgr.grammarError(ErrorType.EXPECTED_NON_GREEDY_WILDCARD_BLOCK, g.fileName, plusAST.getToken(), plusAST.getToken().getText());
      }
View Full Code Here

TOP

Related Classes of org.antlr.v4.tool.ast.ActionAST

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.