public void BuildState(Dictionary <ITokenSource, Captures.ICaptureTokenStructuralItem> sourceReplacementLookup) { /* * * ToDo: Analyze encodeTarget state and find the number of * characters necessary to encode it in the target * base. * */ var thisReplacement = sourceReplacementLookup.ContainsKey(this) ? (ITokenSource)(sourceReplacementLookup[this]) : (ITokenSource)this; InlinedTokenExpressionSeries encodeTarget = (InlinedTokenExpressionSeries)this.EncodeTarget; encodeTarget.BuildState(sourceReplacementLookup); var state = encodeTarget.State; List <RegularLanguageNFAState> originalStates = new List <RegularLanguageNFAState>(); RegularLanguageNFAState.FlatlineState(state, originalStates); if (!originalStates.Contains(state)) { originalStates.Add(state); } var onLookup = new Dictionary <RegularLanguageNFAState, RegularLanguageNFAState>(); foreach (var originalState in originalStates) { onLookup.Add(originalState, new RegularLanguageNFAState()); } Func <int, NumericBase> baseFactory = null; bool caseSensitive = false; if (this.NumericBase == null) { /* * * User-supplied base. * */ var ac = new AnyController(this.StringBase.GetCleanValue(), !this.StringBase.CaseInsensitive); baseFactory = ab => new AnyBase(ac, ab); caseSensitive = !StringBase.CaseInsensitive; } else { var cleanValue = this.NumericBase.GetCleanValue(); baseFactory = baseCreator[(EncodeBase)cleanValue]; switch (cleanValue) { case 8: case 16: case 18: case 27: case 36: caseSensitive = false; break; case 60: caseSensitive = true; break; } } Parallel.ForEach(originalStates, originalState => { var targetState = onLookup[originalState]; targetState.SetSources(originalState.Sources.ToDictionary(k => k.Item1, v => v.Item2)); CreateBaseEncodedGraph(targetState, originalState, onLookup, baseFactory, caseSensitive, Digits.GetCleanValue()); targetState.IsEdge = originalState.IsEdge; }); this.state = onLookup[state]; this.state.HandleRepeatCycle <RegularLanguageSet, RegularLanguageNFAState, RegularLanguageDFAState, ITokenSource, RegularLanguageNFARootState, IInlinedTokenItem>(this, thisReplacement, OilexerGrammarInliningCore.TokenRootStateClonerCache, OilexerGrammarInliningCore.TokenStateClonerCache); }
public AnyBase(AnyController controller, BigInteger value) : base(controller, value) { this.controller = controller; }