public override Verb CreateVerb(string[] tokens)
        {
            Color(position, length, IDEColor.EntityType.Structure);
            var index = position + length;

            messageInvokeParser = new BlockMessageInvokeParser();
            if (messageInvokeParser.Scan(source, index))
            {
                overridePosition = messageInvokeParser.Result.Position;
                return(new Push(messageInvokeParser.Result.Value));
            }
            lambdaInvokeParser = new LambdaInvokeParser();
            if (lambdaInvokeParser.Scan(source, index))
            {
                overridePosition = lambdaInvokeParser.Result.Position;
                return(new Push(lambdaInvokeParser.Result.Value));
            }
            if (valueParser.Scan(source, index))
            {
                var block = new Block
                {
                    new Push(valueParser.Result.Value)
                };
                overridePosition = valueParser.Result.Position;
                Result.Value     = block;
                return(new Push(block));
            }
            return(null);
        }
Beispiel #2
0
        IMaybe <int> getTerm(Block block, int index)
        {
            index = ignoreReturns(index);

            if (ifExpressionParser.Scan(source, index))
            {
                block.Add(ifExpressionParser.Verb);
                return(ifExpressionParser.Position.Some());
            }

            while (prefixOperatorParser.Scan(source, index))
            {
                block.Add(prefixOperatorParser.Verb);
                index = prefixOperatorParser.Position;
            }

            index = ignoreReturns(index);

            if (valueParser.Scan(source, index))
            {
                block.Add(valueParser.Verb);
                index = valueParser.Position;
            }
            else
            {
                return(none <int>());
            }

            index = ignoreReturns(index);

            while (postfixOperatorParser.Scan(source, index))
            {
                block.Add(postfixOperatorParser.Verb);
                index = postfixOperatorParser.Position;
                index = ignoreReturns(index);
            }

            return(index.Some());
        }