コード例 #1
0
        public int CompareTo(SymbolString other)
        {
            if (other == null)
            {
                return(1);
            }

            if (other.Count < Count)
            {
                return(1);
            }
            if (other.Count > Count)
            {
                return(-1);
            }

            for (int i = 0; i < this.Count; i++)
            {
                var cp = this[i].CompareTo(other[i]);
                if (cp != 0)
                {
                    return(cp);
                }
            }

            return(0);
        }
コード例 #2
0
        public static SymbolString Concat(SymbolString symbolString, TerminalSymbol symbol)
        {
            List <Symbol> symbols = new List <Symbol>(symbolString);

            if (symbol != null)
            {
                symbols.Add(symbol);
            }
            return(new SymbolString(symbols));
        }
コード例 #3
0
        public HashSet <TerminalSymbol> GetNextLookaheads(GrammarProductionDatabase db)
        {
            if (ParsingPoint == (Production.Body.Count - 1))
            {
                return new HashSet <TerminalSymbol> {
                           Lookahead
                }
            }
            ;

            return(SymbolString.Concat(Production.Body.Range(ParsingPoint + 1), Lookahead).FirstSet(db));
        }
    }
コード例 #4
0
        public bool Equals(SymbolString other)
        {
            if (other == null)
            {
                return(false);
            }

            if (this.Count != other.Count)
            {
                return(false);
            }

            for (int i = 0; i < other.Count; i++)
            {
                if (this[i] != other[i])
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #5
0
 public GrammarProduction(NonterminalSymbol head, SymbolString body)
 {
     this.Head = head;
     this.Body = body;
 }