本文整理汇总了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);
*/
}