예제 #1
0
        public override Verb CreateVerb(string[] tokens)
        {
            Color(position, tokens[1].Length, Whitespaces);
            Color(tokens[2].Length, KeyWords);

            if (GetExpression(source, NextPosition, Stop.IfThen()).If(out var condition, out var i) &&
                GetExpression(source, i, Stop.IfElse()).If(out var ifTrue, out var j) &&
                GetExpression(source, j, Stop.IfEnd()).If(out var ifFalse, out var k))
            {
                overridePosition = k;
                var ifResult = new If(condition, ifTrue)
                {
                    ElseBlock = ifFalse
                };
                return(new IfExecute(ifResult, VerbPresidenceType.Push));
            }

            return(null);
        }
예제 #2
0
        public override Verb CreateVerb(string[] tokens)
        {
            Color(position, tokens[1].Length, Whitespaces);
            Color(tokens[2].Length, KeyWords);

            var expressions =
                from e1 in GetExpression(source, NextPosition, Stop.IfThen())
                from e2 in GetExpression(source, e1.position, Stop.IfElse())
                from e3 in GetExpression(source, e2.position, Stop.IfEnd())
                select(e1.block, e2.block, e3.block, e3.position);

            if (expressions.If(out var condition, out var ifTrue, out var ifFalse, out var newPosition))
            {
                overridePosition = newPosition;
                var ifResult = new If(condition, ifTrue)
                {
                    ElseBlock = ifFalse
                };
                return(new IfExecute(ifResult, VerbPrecedenceType.Push));
            }

            return(null);
        }