Esempio n. 1
0
        public override Verb CreateVerb(string[] tokens)
        {
            Color(position, tokens[1].Length, KeyWords);

            AdvanceTabs();

            var statementParser = new StatementParser();
            var block           = new Block();

            var index = NextPosition;

            while (index < source.Length)
            {
                if (statementParser.Scan(source, index))
                {
                    index = statementParser.Position;
                    var verb = statementParser.Verb;
                    if (verb != null && !(verb is NullOp))
                    {
                        block.Add(verb);
                    }
                }
                else
                {
                    break;
                }
            }

            RegressTabs();

            overridePosition = index;
            Block            = block;
            return(block.PushedVerb);
        }
Esempio n. 2
0
        public static IMaybe <(Block, int)> OneLineStatement(string source, int index)
        {
            var oldTabs = Tabs;

            Tabs = "/s*";
            var whenUnlessParser = new WhenUnlessParser();

            try
            {
                var parser = new StatementParser();
                if (parser.Scan(source, index))
                {
                    var verb = ReturnExpression.Convert(parser.Verb);
                    whenUnlessParser.OtherVerb = verb;
                    if (whenUnlessParser.Scan(source, parser.Position))
                    {
                        return((Inline(whenUnlessParser.Verb), whenUnlessParser.Position).Some());
                    }
                    else
                    {
                        return((Inline(verb), parser.Position).Some());
                    }
                }

                return(none <(Block, int)>());
            }
            finally
            {
                Tabs = oldTabs;
            }
        }