Exemple #1
0
        public override Verb CreateVerb(string[] tokens)
        {
            var fieldName   = tokens[2];
            var messageName = tokens[4];
            var type        = tokens[5];

            Color(position, tokens[1].Length, Whitespaces);
            Color(fieldName.Length, Variables);
            Color(tokens[3].Length, Structures);
            Color(messageName.Length, Messaging);

            if (type.StartsWith("$"))
            {
                Color(type.Length, Messaging);
                var argumentExp  = PushValue(type.Drop(1));
                var assignParser = new AssignParser();
                if (assignParser.Parse(source, NextPosition).If(out var assignment, out var index))
                {
                    overridePosition = index;
                    return(new IndexedSetterMessage(fieldName, messageName, argumentExp, assignment.Verb, assignment.Expression,
                                                    false)
                    {
                        Index = position
                    });
                }

                return(null);
            }

            Color(type.Length, Structures);
            var insert = type.EndsWith("+");

            if (GetExpression(source, NextPosition, CloseBracket(), true).If(out var exp, out var i1))
            {
                var assignParser = new AssignParser();
                if (assignParser.Parse(source, i1).If(out var assignment, out var i))
                {
                    overridePosition = i;
                    return(new IndexedSetterMessage(fieldName, messageName, exp, assignment.Verb, assignment.Expression, insert));
                }
            }

            return(null);
        }
Exemple #2
0
        public override Verb CreateVerb(string[] tokens)
        {
            var message = tokens[2];

            Color(position, tokens[1].Length, Whitespaces);
            Color(1, Structures);
            Color(message.Length, Messaging);
            Color(tokens[3].Length, Whitespaces);

            var assignParser = new AssignParser();
            var start        = position + tokens[1].Length + 1 + message.Length + tokens[3].Length;

            if (assignParser.Parse(source, start).If(out var assignment, out var index))
            {
                overridePosition = index;
                return(new ClassSetter(message, assignment.Verb, assignment.Expression));
            }

            return(null);
        }