public override Verb Parse() { var block = new Block(); var index = position; prefixOperatorParser = new PrefixOperatorParser(); valueParser = new ValueParser(); postfixOperatorParser = new PostfixOperatorParser(asStatement); infixOperatorParser = new InfixOperatorParser(); andOrParser = new AndOrParser(Stop.PassAlong(stop, Structures)); ignoreReturnsParser = new IgnoreReturnsParser(); ifExpressionParser = new IfExpressionParser(); if (index < source.Length) { if (isStopping(index).If(out var newIndex)) { return(returnBlock(block, newIndex)); } if (getTerm(block, index).If(out newIndex) && newIndex != index) { index = newIndex; } else { return(null); } } while (index < source.Length) { if (isStopping(index).If(out var newIndex)) { return(returnBlock(block, newIndex)); } if (infixOperatorParser.Scan(source, index)) { block.Add(infixOperatorParser.Verb); index = infixOperatorParser.Position; } else { break; } if (getTerm(block, index).If(out var newIndex2) && newIndex2 != index) { index = newIndex2; }
public override Verb Parse() { var block = new Block(); var index = position; prefixOperatorParser = new PrefixOperatorParser(); valueParser = new ValueParser(); postfixOperatorParser = new PostfixOperatorParser(asStatement); infixOperatorParser = new InfixOperatorParser(); andOrParser = new AndOrParser(Stop.PassAlong(stop, Structures)); ignoreReturnsParser = new IgnoreReturnsParser(); ifExpressionParser = new IfExpressionParser(); IMaybe <int> newIndex; if (index < source.Length) { newIndex = isStopping(index); if (newIndex.IsSome) { return(returnBlock(block, newIndex.Value)); } newIndex = getTerm(block, index); if (newIndex.IsNone || newIndex.Value == index) { return(null); } index = newIndex.Value; } while (index < source.Length) { newIndex = isStopping(index); if (newIndex.IsSome) { return(returnBlock(block, newIndex.Value)); } if (infixOperatorParser.Scan(source, index)) { block.Add(infixOperatorParser.Verb); index = infixOperatorParser.Position; } else { break; } newIndex = getTerm(block, index); if (newIndex.IsNone || newIndex.Value == index) { return(null); } index = newIndex.Value; } if (index < source.Length) { newIndex = isStopping(index); if (newIndex.IsSome) { return(returnBlock(block, newIndex.Value)); } if (andOrParser.Scan(source, index)) { block.Add(andOrParser.Verb); index = andOrParser.Position; } } return(returnBlock(block, index)); }
public SingleValueBlockParser() : base(@"^\s*\^\s*") { valueParser = new ValueParser(); }