예제 #1
0
        internal string GetJunction(TokenBounds bounds)
        {
            if (bounds.End - bounds.Start == 3)
            {
                var substring = UnparsedFormula.Substring(bounds.Start, 3);

                if (substring.Equals(Junctions.Imp))
                {
                    return(Junctions.Imp);
                }

                if (substring.Equals(Junctions.And))
                {
                    return(Junctions.And);
                }

                if (substring.Equals(Junctions.Ekv))
                {
                    return(Junctions.Ekv);
                }

                if (substring.Equals(Junctions.Not))
                {
                    return(Junctions.Not);
                }
            }

            if (bounds.End - bounds.Start == 2)
            {
                var substring = UnparsedFormula.Substring(bounds.Start, 2);

                if (substring.Equals(Junctions.Or))
                {
                    return(Junctions.Or);
                }
            }

            throw new ParseException($"Token starting with uppercase symbol at index {bounds.Start} of {UnparsedFormula} was not recognized as junction.");
        }
예제 #2
0
 internal TokenFactory(string unparsedFormula, TokenBounds bounds)
 {
     UnparsedFormula = unparsedFormula;
     Bounds          = bounds;
 }
예제 #3
0
 internal char GetChar(TokenBounds bounds)
 {
     return(UnparsedFormula[bounds.Start]);
 }
예제 #4
0
 internal TokenFactory GetNewBounds(TokenBounds bounds)
 {
     return(new TokenFactory(UnparsedFormula, bounds));
 }
예제 #5
0
 internal TokenFactory(string unparsedFormula)
 {
     UnparsedFormula = unparsedFormula;
     Bounds          = new TokenBounds(0, unparsedFormula.Length);
 }