Examples of ActionAST


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

      epsilon(left, right);
      return new Handle(left, right);
    }

    // define action AST for this rule as if we had found in grammar
        ActionAST ast =  new ActionAST(new CommonToken(ANTLRParser.ACTION, action));
    currentRule.defineActionInAlt(currentOuterAlt, ast);
    return action(ast);
  }
View Full Code Here

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

  public ParserFile(OutputModelFactory factory, String fileName) {
    super(factory, fileName);
    Grammar g = factory.getGrammar();
    namedActions = new HashMap<String, Action>();
    for (String name : g.namedActions.keySet()) {
      ActionAST ast = g.namedActions.get(name);
      namedActions.put(name, new Action(factory, ast));
    }
    genPackage = g.tool.genPackage;
    // need the below members in the ST for Python
    genListener = g.tool.gen_listener;
View Full Code Here

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

      else {
        // if labels, must label all. no need for generic rule visitor then
        visitorNames.add(r.name);
      }
    }
    ActionAST ast = g.namedActions.get("header");
    if ( ast!=null ) header = new Action(factory, ast);
    genPackage = factory.getGrammar().tool.genPackage;
  }
View Full Code Here

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

        labels.add(d);
        rf.addContextDecl(ast.getAltLabel(), d);
      }
    }

    ActionAST arg = (ActionAST)ast.getFirstChildWithType(ANTLRParser.ARG_ACTION);
    if ( arg != null ) {
      argExprsChunks = ActionTranslator.translateAction(factory, rf, arg.token, arg);
    }

    // If action refs rule as rulename not label, we need to define implicit label
View Full Code Here

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

    ruleLabels = r.getElementLabelNames();
    tokenLabels = r.getTokenRefs();
    if ( r.exceptions!=null ) {
      exceptions = new ArrayList<ExceptionClause>();
      for (GrammarAST e : r.exceptions) {
        ActionAST catchArg = (ActionAST)e.getChild(0);
        ActionAST catchAction = (ActionAST)e.getChild(1);
        exceptions.add(new ExceptionClause(factory, catchArg, catchAction));
      }
    }

    startState = factory.getGrammar().atn.ruleToStartState[r.index];
View Full Code Here

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

      finallyAction = new Action(factory, r.finallyAction);
    }

    namedActions = new HashMap<String, Action>();
    for (String name : r.namedActions.keySet()) {
      ActionAST ast = r.namedActions.get(name);
      namedActions.put(name, new Action(factory, ast));
    }
  }
View Full Code Here

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

      else {
        // only add rule context if no labels
        listenerNames.add(r.name);
      }
    }
    ActionAST ast = g.namedActions.get("header");
    if ( ast!=null ) header = new Action(factory, ast);
    genPackage = factory.getGrammar().tool.genPackage;
  }
View Full Code Here

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

  public LexerFile(OutputModelFactory factory, String fileName) {
    super(factory, fileName);
    namedActions = new HashMap<String, Action>();
    Grammar g = factory.getGrammar();
    for (String name : g.namedActions.keySet()) {
      ActionAST ast = g.namedActions.get(name);
      namedActions.put(name, new Action(factory, ast));
    }
    genPackage = factory.getGrammar().tool.genPackage;
  }
View Full Code Here

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

    predicate = gen.getTarget().getTargetStringLiteralFromString(predicate);

    if ( failNode==null ) return;

    if ( failNode instanceof ActionAST ) {
      ActionAST failActionNode = (ActionAST)failNode;
      RuleFunction rf = factory.getCurrentRuleFunction();
      failChunks = ActionTranslator.translateAction(factory, rf,
                              failActionNode.token,
                              failActionNode);
    }
View Full Code Here

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

    //System.out.println("actions="+chunks);
  }

  public Action(OutputModelFactory factory, StructDecl ctx, String action) {
    super(factory,null);
    ActionAST ast = new ActionAST(new CommonToken(ANTLRParser.ACTION, action));
    RuleFunction rf = factory.getCurrentRuleFunction();
    if ( rf!=null ) { // we can translate
      ast.resolver = rf.rule;
      chunks = ActionTranslator.translateActionChunk(factory, rf, action, ast);
    }
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.