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


C# Antlr3.Codegen.CodeGenerator.GenerateSpecialState方法代码示例

本文整理汇总了C#中Antlr3.Codegen.CodeGenerator.GenerateSpecialState方法的典型用法代码示例。如果您正苦于以下问题:C# Antlr3.Codegen.CodeGenerator.GenerateSpecialState方法的具体用法?C# Antlr3.Codegen.CodeGenerator.GenerateSpecialState怎么用?C# Antlr3.Codegen.CodeGenerator.GenerateSpecialState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Antlr3.Codegen.CodeGenerator的用法示例。


在下文中一共展示了Antlr3.Codegen.CodeGenerator.GenerateSpecialState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateStateTables

        public virtual void CreateStateTables( CodeGenerator generator )
        {
            //JSys[email protected]("createTables:\n"+this);
            this._generator = generator;
            Description = NFADecisionStartState.Description;
            Description = generator.Target.GetTargetStringLiteralFromString( Description );

            // create all the tables
            //special = new List<int>( this.NumberOfStates ); // Vector<short>
            //special.setSize( this.NumberOfStates );
            _special = Enumerable.Repeat( EmptyValue, NumberOfStates ).ToArray();
            _specialStates = new List<DFAState>();
            _specialStateSTs = new List<StringTemplate>();
            //accept = new List<int>( this.NumberOfStates ); // Vector<int>
            //accept.setSize( this.NumberOfStates );
            _accept = Enumerable.Repeat( EmptyValue, NumberOfStates ).ToArray();
            //eot = new List<int>( this.NumberOfStates ); // Vector<int>
            //eot.setSize( this.NumberOfStates );
            _eot = Enumerable.Repeat( EmptyValue, NumberOfStates ).ToArray();
            //eof = new List<int>( this.NumberOfStates ); // Vector<int>
            //eof.setSize( this.NumberOfStates );
            _eof = Enumerable.Repeat( EmptyValue, NumberOfStates ).ToArray();
            //min = new List<int>( this.NumberOfStates ); // Vector<int>
            //min.setSize( this.NumberOfStates );
            _min = Enumerable.Repeat( EmptyValue, NumberOfStates ).ToArray();
            //max = new List<int>( this.NumberOfStates ); // Vector<int>
            //max.setSize( this.NumberOfStates );
            _max = Enumerable.Repeat( EmptyValue, NumberOfStates ).ToArray();
            _transition = new int[NumberOfStates][]; // Vector<Vector<int>>
            //transition.setSize( this.NumberOfStates );
            _transitionEdgeTables = new List<int?>( this.NumberOfStates ); // Vector<Vector<int>>
            _transitionEdgeTables.Resize( this.NumberOfStates );

            // for each state in the DFA, fill relevant tables.
            IEnumerable<DFAState> it = null;
            if ( UserMaxLookahead > 0 )
            {
                it = _states;
            }
            else
            {
                it = UniqueStates.Values;
            }

            foreach ( DFAState s in it )
            {
                if ( s == null )
                {
                    // ignore null states; some acylic DFA see this condition
                    // when inlining DFA (due to lacking of exit branch pruning?)
                    continue;
                }

                if ( s.IsAcceptState )
                {
                    // can't compute min,max,special,transition on accepts
                    _accept[s.StateNumber] = s.GetUniquelyPredictedAlt();
                }
                else
                {
                    CreateMinMaxTables( s );
                    CreateTransitionTableEntryForState( s );
                    CreateSpecialTable( s );
                    CreateEOTAndEOFTables( s );
                }
            }

            // now that we have computed list of specialStates, gen code for 'em
            for ( int i = 0; i < _specialStates.Count; i++ )
            {
                DFAState ss = _specialStates[i];
                StringTemplate stateST = generator.GenerateSpecialState( ss );
                _specialStateSTs.Add( stateST );
            }

            // check that the tables are not messed up by encode/decode
            /*
            testEncodeDecode(min);
            testEncodeDecode(max);
            testEncodeDecode(accept);
            testEncodeDecode(special);
            [email protected]("min="+min);
            [email protected]("max="+max);
            [email protected]("eot="+eot);
            [email protected]("eof="+eof);
            [email protected]("accept="+accept);
            [email protected]("special="+special);
            JSystem[email protected]("transition="+transition);
            */
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:90,代码来源:DFA.cs


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