Examples of BlockAST


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

    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

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

    LoopEndState end = newState(LoopEndState.class, starAST);
    StarLoopbackState loop = newState(StarLoopbackState.class, starAST);
    entry.loopBackState = loop;
    end.loopBackState = loop;

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

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

      }
      // create for each literal: (RULE <uniquename> (BLOCK (ALT <lit>))
      String rname = combinedGrammar.getStringLiteralLexerRuleName(lit);
      // can't use wizard; need special node types
      GrammarAST litRule = new RuleAST(ANTLRParser.RULE);
      BlockAST blk = new BlockAST(ANTLRParser.BLOCK);
      AltAST alt = new AltAST(ANTLRParser.ALT);
      TerminalAST slit = new TerminalAST(new CommonToken(ANTLRParser.STRING_LITERAL, lit));
      alt.addChild(slit);
      blk.addChild(alt);
      CommonToken idToken = new CommonToken(ANTLRParser.TOKEN_REF, rname);
      litRule.addChild(new TerminalAST(idToken));
      litRule.addChild(blk);
      lexerRulesRoot.insertChild(insertIndex, litRule);
//      lexerRulesRoot.getChildren().add(0, litRule);
View Full Code Here

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

  public PlusBlock(OutputModelFactory factory,
           GrammarAST plusRoot,
           List<CodeBlockForAlt> alts)
  {
    super(factory, plusRoot, alts);
    BlockAST blkAST = (BlockAST)plusRoot.getChild(0);
    PlusBlockStartState blkStart = (PlusBlockStartState)blkAST.atnState;
    PlusLoopbackState loop = blkStart.loopBackState;
    stateNumber = blkStart.loopBackState.stateNumber;
    blockStartStateNumber = blkStart.stateNumber;
    loopBackStateNumber = loop.stateNumber;
View Full Code Here

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

/** */
public class LL1PlusBlockSingleAlt extends LL1Loop {
  public LL1PlusBlockSingleAlt(OutputModelFactory factory, GrammarAST plusRoot, List<CodeBlockForAlt> alts) {
    super(factory, plusRoot, alts);

    BlockAST blkAST = (BlockAST)plusRoot.getChild(0);
    PlusBlockStartState blkStart = (PlusBlockStartState)blkAST.atnState;

    stateNumber = blkStart.loopBackState.stateNumber;
    blockStartStateNumber = blkStart.stateNumber;
    PlusBlockStartState plus = (PlusBlockStartState)blkAST.atnState;
View Full Code Here

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

  }

  @Override
  public void finishRule(RuleAST rule, GrammarAST ID, GrammarAST block) {
    if ( rule.isLexerRule() ) return;
    BlockAST blk = (BlockAST)rule.getFirstChildWithType(BLOCK);
    int nalts = blk.getChildCount();
    GrammarAST idAST = (GrammarAST)rule.getChild(0);
    for (int i=0; i< nalts; i++) {
      AltAST altAST = (AltAST)blk.getChild(i);
      if ( altAST.altLabel!=null ) {
        String altLabel = altAST.altLabel.getText();
        // first check that label doesn't conflict with a rule
        // label X or x can't be rule x.
        Rule r = ruleCollector.rules.get(Utils.decapitalize(altLabel));
View Full Code Here

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

   *       (ALT {3 >= $_p}? '++') (ALT {2 >= $_p}? '--'))))))
   * </pre>
   */
  public void setAltASTPointers(LeftRecursiveRule r, RuleAST t) {
//    System.out.println("RULE: "+t.toStringTree());
    BlockAST ruleBlk = (BlockAST)t.getFirstChildWithType(ANTLRParser.BLOCK);
    AltAST mainAlt = (AltAST)ruleBlk.getChild(0);
    BlockAST primaryBlk = (BlockAST)mainAlt.getChild(0);
    BlockAST opsBlk = (BlockAST)mainAlt.getChild(1).getChild(0); // (* BLOCK ...)
    for (int i = 0; i < r.recPrimaryAlts.size(); i++) {
      LeftRecursiveRuleAltInfo altInfo = r.recPrimaryAlts.get(i);
      altInfo.altAST = (AltAST)primaryBlk.getChild(i);
      altInfo.altAST.leftRecursiveAltInfo = altInfo;
      altInfo.originalAltAST.leftRecursiveAltInfo = altInfo;
//      altInfo.originalAltAST.parent = altInfo.altAST.parent;
//      System.out.println(altInfo.altAST.toStringTree());
    }
    for (int i = 0; i < r.recOpAlts.size(); i++) {
      LeftRecursiveRuleAltInfo altInfo = r.recOpAlts.getElement(i);
      altInfo.altAST = (AltAST)opsBlk.getChild(i);
      altInfo.altAST.leftRecursiveAltInfo = altInfo;
      altInfo.originalAltAST.leftRecursiveAltInfo = altInfo;
//      altInfo.originalAltAST.parent = altInfo.altAST.parent;
//      System.out.println(altInfo.altAST.toStringTree());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.