Package org.antlr.v4.codegen.model.chunk

Examples of org.antlr.v4.codegen.model.chunk.ActionText


  @Override
  public List<SrcOp> action(ActionAST ast) { return list(new Action(this, ast)); }

  @Override
  public List<SrcOp> sempred(ActionAST ast) { return list(new SemPred(this, ast)); }
View Full Code Here


    switch ( ebnf ) {
      case ANTLRParser.OPTIONAL :
        c = new OptionalBlock(this, ebnfRoot, alts);
        break;
      case ANTLRParser.CLOSURE :
        c = new StarBlock(this, ebnfRoot, alts);
        break;
      case ANTLRParser.POSITIVE_CLOSURE :
        c = new PlusBlock(this, ebnfRoot, alts);
        break;
    }
View Full Code Here

  public void qualifiedAttr(String expr, Token x, Token y) {
    gen.g.tool.log("action-translator", "qattr "+x+"."+y);
    if ( node.resolver.resolveToAttribute(x.getText(), node)!=null ) {
      // must be a member access to a predefined attribute like $ctx.foo
      attr(expr, x);
      chunks.add(new ActionText(nodeContext, "."+y.getText()));
      return;
    }
    Attribute a = node.resolver.resolveToAttribute(x.getText(), y.getText(), node);
    switch ( a.dict.type ) {
      case ARG: chunks.add(new ArgRef(nodeContext,y.getText())); break; // has to be current rule
View Full Code Here

    chunks.add(s);
  }

  @Override
  public void text(String text) {
    chunks.add(new ActionText(nodeContext,text));
  }
View Full Code Here

    ruleNames = g.rules.keySet();
    rules = g.rules.values();
    atn = new SerializedATN(factory, g.atn);
    if (g.getOptionString("superClass") != null) {
      superClass = new ActionText(null, g.getOptionString("superClass"));
    }
    else {
      superClass = null;
    }
View Full Code Here

      ast.resolver = rf.rule;
      chunks = ActionTranslator.translateActionChunk(factory, rf, action, ast);
    }
    else {
      chunks = new ArrayList<ActionChunk>();
      chunks.add(new ActionText(ctx, action));
    }
  }
View Full Code Here

  }

  public void reduceBlocksToSets(GrammarAST root) {
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(new GrammarASTAdaptor(), root);
    GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
    BlockSetTransformer transformer = new BlockSetTransformer(nodes, g);
    transformer.setTreeAdaptor(adaptor);
    transformer.downup(root);
  }
View Full Code Here

  public Map<Integer, ASSOC> altAssociativity = new HashMap<Integer, ASSOC>();

  public LeftRecursiveRuleAnalyzer(GrammarAST ruleAST,
                   Tool tool, String ruleName, String language)
  {
    super(new CommonTreeNodeStream(new GrammarASTAdaptor(ruleAST.token.getInputStream()), ruleAST));
    this.tool = tool;
    this.ruleName = ruleName;
    this.language = language;
    this.tokenStream = ruleAST.g.tokenStream;
    if (this.tokenStream == null) {
View Full Code Here

        tool.log("grammar", "after: "+root.toStringTree());
  }

  public void reduceBlocksToSets(GrammarAST root) {
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(new GrammarASTAdaptor(), root);
    GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
    BlockSetTransformer transformer = new BlockSetTransformer(nodes, g);
    transformer.setTreeAdaptor(adaptor);
    transformer.downup(root);
  }
View Full Code Here

     *
     *  Parameter must be a token.
     *  todo: do we want?
     */
    public void expandParameterizedLoops(GrammarAST root) {
        TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor());
        v.visit(root, new TreeVisitorAction() {
            @Override
            public Object pre(Object t) {
                if ( ((GrammarAST)t).getType() == 3 ) {
                    return expandParameterizedLoop((GrammarAST)t);
View Full Code Here

TOP

Related Classes of org.antlr.v4.codegen.model.chunk.ActionText

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.