Пример #1
0
        ///
        /// <summary>
        ///		Gets a CsEvaluator object for the expression
        /// </summary>
        ///
        /// <param name="data">Expression to evaluate</param>
        ///
        /// <returns>CsEvaluator object for the given expression</returns>
        ///
        public static CsEvaluator GetEvaluator(string data)
        {
            if (!data.TrimEnd().EndsWith("\n;"))
            {
                data += "\n;";
            }

            CseParser parser =
                new CseParser(
                    new CommonTokenStream(
                        new CseLexer(
                            new ANTLRInputStream(
                                new MemoryStream(Encoding.UTF8.GetBytes(data))
                                )
                            )
                        )
                    );

            CsEvaluator evaluator = new CsEvaluator();

            evaluator.parser = parser;

            return(evaluator);
        }
Пример #2
0
    ///
    /// <summary>
    ///		Gets a CsEvaluator object for the expression
    /// </summary>
    /// 
    /// <param name="data">Expression to evaluate</param>
    /// 
    /// <returns>CsEvaluator object for the given expression</returns>
    /// 
    public static CsEvaluator GetEvaluator(string data) {
      if (!data.TrimEnd().EndsWith("\n;"))
        data += "\n;";

      CseParser parser = 
        new CseParser(
          new CommonTokenStream(
            new CseLexer(
              new ANTLRInputStream(
                new MemoryStream(Encoding.UTF8.GetBytes(data))
              )
            )
          )
        );

      CsEvaluator evaluator = new CsEvaluator();
      evaluator.parser = parser;

      return evaluator;
    }