public static TokenProducerInfo Combine(IntSetType tokenSetType, IEnumerable <TokenProducerInfo> items) { switch (items.Count()) { case 0: return (new TokenProducerInfo { Disambiguation = Disambiguation.Exclusive, RealActions = SparseIntSetType.Instance.Empty, PossibleTokens = tokenSetType.Empty, MainTokenId = -1, }); case 1: return(items.First()); } TokenProducerInfo result = null; foreach (var item in items) { if (item.Disambiguation == Disambiguation.Exclusive) { if (result == null) { result = item; } } } if (result == null) { result = new TokenProducerInfo { Disambiguation = Disambiguation.Exclusive }; int mainToken = PredefinedTokens.NoToken; var allPossible = tokenSetType.Mutable(); var allActions = SparseIntSetType.Instance.Mutable(); foreach (var item in items) { if (mainToken != PredefinedTokens.NoToken && item.MainTokenId != PredefinedTokens.NoToken) { mainToken = item.MainTokenId; } allPossible.AddAll(item.PossibleTokens); allActions.AddAll(item.RealActions); } result.MainTokenId = mainToken; result.RealActions = allActions.CompleteAndDestroy(); result.PossibleTokens = allPossible.CompleteAndDestroy(); } return(result); }
public bool AddTransition(int token, DotState to, IntSetType tokenSetType) { bool result; var existing = Transitions.FirstOrDefault(t => t.To == to); if (existing == null) { existing = new DotTransition(tokenSetType.Mutable(), to); Transitions.Add(existing); result = true; } else { result = !existing.Tokens.Contains(token); } existing.Tokens.Add(token); return(result); }
public ScanAmbiguityResolver(IntSetType tokenSetType, int actionCount) { this.actionToTokenProducer = new TokenProducerInfo[actionCount]; this.stateToTokenProducer = new Dictionary <object, TokenProducerInfo>(); this.tokenSetType = tokenSetType; }
public BitSet(IntSetType setType, uint[] words) : base(setType, words) { }
public BitSet(IntSetType setType, int bitCount, bool defaultBit) : base(setType, bitCount, defaultBit) { }
public MutableBitSet(IntSetType setType, int bitCount, bool defaultBit) : base(setType, bitCount, defaultBit) { }
public MutableBitSet(IntSetType setType, uint[] words) : base(setType, words) { }