当前位置: 首页>>代码示例>>C#>>正文


C# Ast.GrammarAST类代码示例

本文整理汇总了C#中Antlr4.Tool.Ast.GrammarAST的典型用法代码示例。如果您正苦于以下问题:C# GrammarAST类的具体用法?C# GrammarAST怎么用?C# GrammarAST使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GrammarAST类属于Antlr4.Tool.Ast命名空间,在下文中一共展示了GrammarAST类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LabelElementPair

        public LabelElementPair(Grammar g, GrammarAST label, GrammarAST element, int labelOp)
        {
            this.label = label;
            this.element = element;
            // compute general case for label type
            if (element.GetFirstDescendantWithType(tokenTypeForTokens) != null)
            {
                if (labelOp == ANTLRParser.ASSIGN)
                    type = LabelType.TOKEN_LABEL;
                else
                    type = LabelType.TOKEN_LIST_LABEL;
            }
            else if (element.GetFirstDescendantWithType(ANTLRParser.RULE_REF) != null)
            {
                if (labelOp == ANTLRParser.ASSIGN)
                    type = LabelType.RULE_LABEL;
                else
                    type = LabelType.RULE_LIST_LABEL;
            }

            // now reset if lexer and string
            if (g.IsLexer())
            {
                if (element.GetFirstDescendantWithType(ANTLRParser.STRING_LITERAL) != null)
                {
                    if (labelOp == ANTLRParser.ASSIGN)
                        type = LabelType.LEXER_STRING_LABEL;
                }
            }
        }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:30,代码来源:LabelElementPair.cs

示例2: Choice

 public Choice(OutputModelFactory factory,
               GrammarAST blkOrEbnfRootAST,
               IList<CodeBlockForAlt> alts)
     : base(factory, blkOrEbnfRootAST)
 {
     this.alts = alts;
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:7,代码来源:Choice.cs

示例3: GrammarAST

 public GrammarAST(GrammarAST node)
     : base(node)
 {
     this.g = node.g;
     this.atnState = node.atnState;
     this.textOverride = node.textOverride;
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:7,代码来源:GrammarAST.cs

示例4: Loop

 public Loop(OutputModelFactory factory,
             GrammarAST blkOrEbnfRootAST,
             IList<CodeBlockForAlt> alts)
     : base(factory, blkOrEbnfRootAST, alts)
 {
     bool nongreedy = (blkOrEbnfRootAST is QuantifierAST) && !((QuantifierAST)blkOrEbnfRootAST).GetGreedy();
     exitAlt = nongreedy ? 1 : alts.Count + 1;
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:8,代码来源:Loop.cs

示例5: ReduceBlocksToSets

 public virtual void ReduceBlocksToSets(GrammarAST root)
 {
     CommonTreeNodeStream nodes = new CommonTreeNodeStream(new GrammarASTAdaptor(), root);
     GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
     BlockSetTransformer transformer = new BlockSetTransformer(nodes, g);
     transformer.TreeAdaptor = adaptor;
     transformer.Downup(root);
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:8,代码来源:GrammarTransformPipeline.cs

示例6: SrcOp

 protected SrcOp(OutputModelFactory factory, GrammarAST ast)
     : base(factory, ast)
 {
     if (ast != null)
         uniqueID = ast.Token.TokenIndex;
     enclosingBlock = factory.GetCurrentBlock();
     enclosingRuleRunction = factory.GetCurrentRuleFunction();
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:8,代码来源:SrcOp.cs

示例7: AltBlock

        //	@ModelElement public ThrowNoViableAlt error;

        public AltBlock(OutputModelFactory factory,
                        GrammarAST blkOrEbnfRootAST,
                        IList<CodeBlockForAlt> alts)
            : base(factory, blkOrEbnfRootAST, alts)
        {
            decision = ((BlockStartState)blkOrEbnfRootAST.atnState).decision;
            // interp.predict() throws exception
            //		this.error = new ThrowNoViableAlt(factory, blkOrEbnfRootAST, null);
        }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:11,代码来源:AltBlock.cs

示例8: TestSetInline

 public TestSetInline(OutputModelFactory factory, GrammarAST ast, IntervalSet set, int wordSize)
     : base(factory, ast)
 {
     bitsetWordSize = wordSize;
     Bitset[] withZeroOffset = CreateBitsets(factory, set, wordSize, true);
     Bitset[] withoutZeroOffset = CreateBitsets(factory, set, wordSize, false);
     this.bitsets = withZeroOffset.Length <= withoutZeroOffset.Length ? withZeroOffset : withoutZeroOffset;
     this.varName = "_la";
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:9,代码来源:TestSetInline.cs

示例9: DiscoverRule

 public override void DiscoverRule(RuleAST rule, GrammarAST ID,
                          IList<GrammarAST> modifiers, ActionAST arg,
                          ActionAST returns, GrammarAST thrws,
                          GrammarAST options, ActionAST locals,
                          IList<GrammarAST> actions,
                          GrammarAST block)
 {
     currentRule = g.GetRule(ID.Text);
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:9,代码来源:SymbolCollector.cs

示例10: RuleRef

 public override IList<SrcOp> RuleRef(GrammarAST ID, GrammarAST label, GrammarAST args)
 {
     InvokeRule invokeOp = new InvokeRule(this, ID, label);
     // If no manual label and action refs as token/rule not label, we need to define implicit label
     if (controller.NeedsImplicitLabel(ID, invokeOp))
         DefineImplicitLabel(ID, invokeOp);
     AddToLabelList listLabelOp = GetAddToListOpIfListLabelPresent(invokeOp, label);
     return List(invokeOp, listLabelOp);
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:9,代码来源:ParserFactory.cs

示例11: MatchSet

 public MatchSet(OutputModelFactory factory, GrammarAST ast)
     : base(factory, ast)
 {
     SetTransition st = (SetTransition)ast.atnState.Transition(0);
     int wordSize = factory.GetGenerator().GetTarget().GetInlineTestSetWordSize();
     expr = new TestSetInline(factory, null, st.set, wordSize);
     Decl.Decl d = new TokenTypeDecl(factory, expr.varName);
     factory.GetCurrentRuleFunction().AddLocalDecl(d);
     capture = new CaptureNextTokenType(factory, expr.varName);
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:10,代码来源:MatchSet.cs

示例12: ThrowRecognitionException

 public ThrowRecognitionException(OutputModelFactory factory, GrammarAST ast, IntervalSet expecting)
     : base(factory, ast)
 {
     //this.decision = ((BlockStartState)ast.ATNState).decision;
     grammarLine = ast.Line;
     grammarLine = ast.CharPositionInLine;
     grammarFile = factory.GetGrammar().fileName;
     //this.expecting = factory.createExpectingBitSet(ast, decision, expecting, "error");
     //		factory.defineBitSet(this.expecting);
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:10,代码来源:ThrowRecognitionException.cs

示例13: StarBlock

 public StarBlock(OutputModelFactory factory,
                  GrammarAST blkOrEbnfRootAST,
                  IList<CodeBlockForAlt> alts)
     : base(factory, blkOrEbnfRootAST, alts)
 {
     loopLabel = factory.GetTarget().GetLoopLabel(blkOrEbnfRootAST);
     StarLoopEntryState star = (StarLoopEntryState)blkOrEbnfRootAST.atnState;
     loopBackStateNumber = star.loopBackState.stateNumber;
     decision = star.decision;
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:10,代码来源:StarBlock.cs

示例14: Sync

        //	public BitSetDecl expecting;

        public Sync(OutputModelFactory factory,
                    GrammarAST blkOrEbnfRootAST,
                    IntervalSet expecting,
                    int decision,
                    string position)
            : base(factory, blkOrEbnfRootAST)
        {
            this.decision = decision;
            //		this.expecting = factory.createExpectingBitSet(ast, decision, expecting, position);
            //		factory.defineBitSet(this.expecting);
        }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:13,代码来源:Sync.cs

示例15: LL1AltBlock

        public LL1AltBlock(OutputModelFactory factory, GrammarAST blkAST, IList<CodeBlockForAlt> alts)
            : base(factory, blkAST, alts)
        {
            this.decision = ((DecisionState)blkAST.atnState).decision;

            /* Lookahead for each alt 1..n */
            IntervalSet[] altLookSets = factory.GetGrammar().decisionLOOK[decision];
            altLook = GetAltLookaheadAsStringLists(altLookSets);

            IntervalSet expecting = IntervalSet.Or(altLookSets); // combine alt sets
            this.error = GetThrowNoViableAlt(factory, blkAST, expecting);
        }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:12,代码来源:LL1AltBlock.cs


注:本文中的Antlr4.Tool.Ast.GrammarAST类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。