public override IMaybe <(Verb, int)> Parse(string source, int index)
        {
            if (freeParser.Scan(source, index, "^ |sp| 'case' /b"))
            {
                freeParser.ColorAll(KeyWords);
                if (GetComparisand(source, freeParser.Position, PassAlong("^ |sp| ':'"))
                    .If(out var comparisand, out var condition, out var cmpIndex) &&
                    GetExpression(source, cmpIndex, CommaOrCloseParenthesis()).If(out var resultBlock, out var blkIndex))
                {
                    Verb verb = new CaseExecute(comparisand, resultBlock, false, condition);
                    return((verb, blkIndex).Some());
                }
            }

            return(none <(Verb, int)>());
        }
Beispiel #2
0
        public override IMaybe <(Verb, int)> Parse(string source, int index)
        {
            if (freeParser.Scan(source, index, "^ |tabs| 'case' /b"))
            {
                freeParser.ColorAll(KeyWords);
                var pComparisand = GetComparisand(source, freeParser.Position, PassAlong(REGEX_DO_OR_END, false));
                if (pComparisand.If(out var comparisand, out var condition, out var cmpIndex) &&
                    GetOneOrMultipleBlock(source, cmpIndex).If(out var resultBlock, out var blkIndex))
                {
                    Verb verb = new CaseExecute(comparisand, resultBlock, false, condition);
                    return((verb, blkIndex).Some());
                }
            }

            return(none <(Verb, int)>());
        }