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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public ScanAmbiguityResolver(IntSetType tokenSetType, int actionCount)
 {
     this.actionToTokenProducer = new TokenProducerInfo[actionCount];
     this.stateToTokenProducer  = new Dictionary <object, TokenProducerInfo>();
     this.tokenSetType          = tokenSetType;
 }
Esempio n. 4
0
 public BitSet(IntSetType setType, uint[] words)
     : base(setType, words)
 {
 }
Esempio n. 5
0
 public BitSet(IntSetType setType, int bitCount, bool defaultBit)
     : base(setType, bitCount, defaultBit)
 {
 }
Esempio n. 6
0
 public MutableBitSet(IntSetType setType, int bitCount, bool defaultBit)
     : base(setType, bitCount, defaultBit)
 {
 }
Esempio n. 7
0
 public MutableBitSet(IntSetType setType, uint[] words)
     : base(setType, words)
 {
 }