Exemple #1
0
            private IOperation parseVar()
            {
                Operations.OperationVariableAccess va = new Operations.OperationVariableAccess();

                var  cc        = _reader.Peek();
                bool blockMode = (cc == '{');

                StringBuilder sb = new StringBuilder();

                if (!blockMode)
                {
                    while ((cc = _reader.Peek()) != -1)
                    {
                        var ch = (char)cc;
                        if (!char.IsLetterOrDigit(ch) && _parser._tokenSpecialCharacters.IndexOf(ch) == -1)
                        {
                            break;
                        }

                        sb.Append(ch);
                        _reader.Read();
                    }
                    va.AddName(sb.ToString());
                    return(new Operations.OperationExpression(new IOperation[] { va }));
                }
                _reader.Read();  // Read {
                var v = _parser.ParseMulti(_reader);

                _reader.SkipWhiteSpaceAndComments();
                _reader.ReadAndThrowIfNot('}'); // eat }
                return(v);
            }
 /// Evaluate string and return the result of the evaluation, casted to the type T
 public T Eval <T>(string st)
 {
     using (var sr = new ParsingReader(new StringReader(st)))
     {
         var o = Eval <T>(sr);
         sr.SkipWhiteSpaceAndComments();
         sr.ReadAndThrowIfNot(-1);
         return(o);
     }
 }