コード例 #1
0
        static private Token ExpandVariable(CharReader reader, StringBuilder literal, IResolver resolver)
        {
            char c;

            while (reader.Next())
            {
                c = reader.Current;
                if (char.IsLetterOrDigit(c))
                {
                    literal.Append(c);
                }
                else
                {
                    if (literal.ToString() == "true")
                    {
                        return(true);
                    }
                    else if (literal.ToString() == "false")
                    {
                        return(false);
                    }
                    else if (char.IsWhiteSpace(c))
                    {
                        continue;
                    }
                    else if (c == '(')
                    {
                        string name = literal.ToString();
                        literal.Length = 0;
                        reader.Read(); // skip the char
                        Token[] args   = ExpandParameters(reader, literal, resolver);
                        Token   result = resolver.HandleFunction(name, args);
                        return(result);
                    }
                    else
                    {
                        Token result = resolver.HandleVariable(literal.ToString());
                        return(result);
                    }
                }
                reader.Read();
            }
            return(Token.Null);
        }