public override void ParseNode(ref Node node, out TokenWalker.StateWalker walk, TokenWalker walker, ParseResultHistory resultHistory) { TokenWalker LocalWalker = new TokenWalker(walker); TokenWalker.StateWalker localWalk = LocalWalker.State; List <Node> parsedNodes = new List <Node>(); while (true) { Node parsedNode = null; try { this.Parser.ParseNode(ref parsedNode, out localWalk, LocalWalker, resultHistory); } catch (Failure) { break; } catch (Success) { localWalk(LocalWalker); if (parsedNode != null) { parsedNodes.Add(parsedNode); } else { resultHistory.AddResult(new FailedParsingResult(walker.Location, this)); throw Failed; } } } if (!this.allowEmpty && parsedNodes.Count == 0) { resultHistory.AddResult(new FailedParsingResult(walker.Location, this)); throw Failed; } node = new ManyNode(parsedNodes, walker.To(LocalWalker)); walk = localWalk; resultHistory.AddResult(new SuccessfulParsingResult(walker.To(localWalk), this)); throw Succeded; }
public override void ParseNode(ref Node node, out TokenWalker.StateWalker walk, TokenWalker walker, ParseResultHistory resultHistory) { TokenWalker LocalWalker = new TokenWalker(walker); TokenWalker.StateWalker localWalk = LocalWalker.State; List <Node> parsedNodes = new List <Node>(); foreach (NodeParser parser in this.Parsers) { Node parsedNode = null; try { parser.ParseNode(ref parsedNode, out localWalk, LocalWalker, resultHistory); } catch (Failure) { resultHistory.AddResult(new FailedParsingResult(walker.Location, this)); throw; } catch (Success) { if (parsedNode != null) { parsedNodes.Add(parsedNode); } localWalk(LocalWalker); continue; } } walk = localWalk; var context = walker.To(walk); node = new ManyNode(parsedNodes, context); resultHistory.AddResult(new SuccessfulParsingResult(context, this)); throw Succeded; }