Examples of LeftRecursiveRuleAltInfo


Examples of org.antlr.v4.analysis.LeftRecursiveRuleAltInfo

    List<AltAST> alts = new ArrayList<AltAST>();
    for (LeftRecursiveRuleAltInfo altInfo : recPrimaryAlts) {
      if (altInfo.altLabel == null) alts.add(altInfo.originalAltAST);
    }
    for (int i = 0; i < recOpAlts.size(); i++) {
      LeftRecursiveRuleAltInfo altInfo = recOpAlts.getElement(i);
      if ( altInfo.altLabel==null ) alts.add(altInfo.originalAltAST);
    }
    if ( alts.isEmpty() ) return null;
    return alts;
  }
View Full Code Here

Examples of org.antlr.v4.analysis.LeftRecursiveRuleAltInfo

        }
      }
    }
    if ( recOpAlts!=null ) {
      for (int i = 0; i < recOpAlts.size(); i++) {
        LeftRecursiveRuleAltInfo altInfo = recOpAlts.getElement(i);
        if ( altInfo.altLabel!=null ) {
          List<Pair<Integer, AltAST>> pairs = labels.get(altInfo.altLabel);
          if (pairs == null) {
            pairs = new ArrayList<Pair<Integer, AltAST>>();
            labels.put(altInfo.altLabel, pairs);
View Full Code Here

Examples of org.antlr.v4.analysis.LeftRecursiveRuleAltInfo

      opAltsCode.add((CodeBlockForAlt)opStuff);
    }

    // Insert code in front of each primary alt to create specialized ctx if there was a label
    for (int i = 0; i < primaryAltsCode.size(); i++) {
      LeftRecursiveRuleAltInfo altInfo = r.recPrimaryAlts.get(i);
      if ( altInfo.altLabel==null ) continue;
      ST altActionST = codegenTemplates.getInstanceOf("recRuleReplaceContext");
      altActionST.add("ctxName", Utils.capitalize(altInfo.altLabel));
      Action altAction =
        new Action(delegate, function.altLabelCtxs.get(altInfo.altLabel), altActionST);
      CodeBlockForAlt alt = primaryAltsCode.get(i);
      alt.insertOp(0, altAction);
    }

    // Insert code to set ctx.stop after primary block and before op * loop
    ST setStopTokenAST = codegenTemplates.getInstanceOf("recRuleSetStopToken");
    Action setStopTokenAction = new Action(delegate, function.ruleCtx, setStopTokenAST);
    outerAlt.insertOp(1, setStopTokenAction);

    // Insert code to set _prevctx at start of * loop
    ST setPrevCtx = codegenTemplates.getInstanceOf("recRuleSetPrevCtx");
    Action setPrevCtxAction = new Action(delegate, function.ruleCtx, setPrevCtx);
    opAltStarBlock.addIterationOp(setPrevCtxAction);

    // Insert code in front of each op alt to create specialized ctx if there was an alt label
    for (int i = 0; i < opAltsCode.size(); i++) {
      ST altActionST;
      LeftRecursiveRuleAltInfo altInfo = r.recOpAlts.getElement(i);
      String templateName;
      if ( altInfo.altLabel!=null ) {
        templateName = "recRuleLabeledAltStartAction";
        altActionST = codegenTemplates.getInstanceOf(templateName);
        altActionST.add("currentAltLabel", altInfo.altLabel);
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.