예제 #1
0
 public static bool IsApplicable(string source, int pos)
 {
     if (pos >= source.Length)
     {
         return(false);
     }
     return(FactorParser.IsApplicable(source, pos));
 }
예제 #2
0
        public static IExpression Parse(string source, ref int pos)
        {
            IExpression left = FactorParser.Parse(source, ref pos);

            ParserImpl.SkipSpaces(source, ref pos);
            if (pos == source.Length)
            {
                return(left);
            }
            if (source[pos] == '^')
            {
                pos++;
                ParserImpl.SkipSpaces(source, ref pos);
                if (!TermParser.IsApplicable(source, pos))
                {
                    throw new ParserException("Invalid term at " + pos);
                }
                IExpression right = PowerParser.Parse(source, ref pos);
                return(new PowerOperation(left, right));
            }
            return(left);
        }