Package org.antlr.v4.codegen.model.decl

Examples of org.antlr.v4.codegen.model.decl.RuleContextDecl


  @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

    return c;
  }

  @Override
  public List<SrcOp> getLL1Test(IntervalSet look, GrammarAST blkAST) {
    return list(new TestSetInline(this, blkAST, look));
  }
View Full Code Here

    else if ( ast.getType()==ANTLRParser.RULE_REF ) { // a rule reference?
      Rule r = g.getRule(ast.getText());
      String implLabel = gen.getTarget().getImplicitRuleLabel(ast.getText());
      String ctxName =
        gen.getTarget().getRuleFunctionContextStructName(r);
      d = new RuleContextDecl(this, implLabel, ctxName);
      ((RuleContextDecl)d).isImplicit = true;
    }
    else {
      String implLabel = gen.getTarget().getImplicitTokenLabel(ast.getText());
      d = getTokenLabelDecl(implLabel);
View Full Code Here

        String listLabel = gen.getTarget().getListLabel(label);
        RuleContextListDecl l = new RuleContextListDecl(factory, listLabel, ctxName);
        rf.addContextDecl(ast.getAltLabel(), l);
      }
      else {
        RuleContextDecl d = new RuleContextDecl(factory,label,ctxName);
        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
    if ( factory.getCurrentOuterMostAlt().ruleRefsInActions.containsKey(ast.getText()) ) {
      String label = gen.getTarget().getImplicitRuleLabel(ast.getText());
      RuleContextDecl d = new RuleContextDecl(factory,label,ctxName);
      labels.add(d);
      rf.addContextDecl(ast.getAltLabel(), d);
    }
  }
View Full Code Here

      String label = idAST.getText();
      GrammarAST rrefAST = (GrammarAST)idAST.getParent().getChild(1);
      if ( rrefAST.getType() == ANTLRParser.RULE_REF ) {
        Rule targetRule = factory.getGrammar().getRule(rrefAST.getText());
        String ctxName = gen.getTarget().getRuleFunctionContextStructName(targetRule);
        RuleContextDecl d;
        if (idAST.getParent().getType() == ANTLRParser.ASSIGN) {
          d = new RuleContextDecl(factory, label, ctxName);
        }
        else {
          d = new RuleContextListDecl(factory, label, ctxName);
        }
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.decl.RuleContextDecl

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.