public static IList<string> Parse(Reader r, char open, char close)
        {
            if (r.Peek == open)
            {
                var result = new List<string>();

                r.Take();

                while (!r.End)
                {
                    var builder = new StringBuilder();
                    while (!r.End && r.Peek != ',' && r.Peek != close && !char.IsWhiteSpace(r.Peek))
                    {
                        builder.Append(r.Take());
                    }
                    if (builder.Length == 0)
                    {
                        throw new ExpressionParseException(r.Position, "Expected indexer argument.");
                    }
                    result.Add(builder.ToString());

                    r.SkipWhitespace();

                    if (r.End)
                    {
                        throw new ExpressionParseException(r.Position, "Expected ','.");
                    }
                    else if (r.TakeIf(close))
                    {
                        return result;
                    }
                    else
                    {
                        if (r.Take() != ',')
                        {
                            throw new ExpressionParseException(r.Position, "Expected ','.");
                        }

                        r.SkipWhitespace();
                    }
                }

                if (!r.End)
                {
                    r.Take();
                    return result;
                }
                else
                {
                    throw new ExpressionParseException(r.Position, "Expected ']'.");
                }
            }

            return null;
        }
 private static bool ParseOpenBrace(Reader r)
 {
     return !r.End && r.TakeIf('(');
 }
 private static bool ParseMemberAccessor(Reader r)
 {
     return !r.End && r.TakeIf('.');
 }
 private static bool ParseNot(Reader r)
 {
     return !r.End && r.TakeIf('!');
 }
        private State ParseAttachedProperty(Reader r, List<ExpressionNode> nodes)
        {
            var owner = IdentifierParser.Parse(r);

            if (r.End || !r.TakeIf('.'))
            {
                throw new ExpressionParseException(r.Position, "Invalid attached property name.");
            }

            var name = IdentifierParser.Parse(r);

            if (r.End || !r.TakeIf(')'))
            {
                throw new ExpressionParseException(r.Position, "Expected ')'.");
            }

            nodes.Add(new PropertyAccessorNode(owner + '.' + name, _enableValidation));
            return State.AfterMember;
        }
 private static bool ParseStreamOperator(Reader r)
 {
     return !r.End && r.TakeIf('^');
 }
Exemple #7
0
 private static bool ParseStreamOperator(Reader r)
 {
     return(!r.End && r.TakeIf('^'));
 }
Exemple #8
0
 private static bool ParseOpenBrace(Reader r)
 {
     return(!r.End && r.TakeIf('('));
 }
Exemple #9
0
 private static bool ParseMemberAccessor(Reader r)
 {
     return(!r.End && r.TakeIf('.'));
 }
Exemple #10
0
 private static bool ParseNot(Reader r)
 {
     return(!r.End && r.TakeIf('!'));
 }