/// <summary> /// Specific rule implementation of the match. Which is if one or more children matches. /// </summary> /// <param name="state">The state.</param> /// <returns><c>true</c> if input is matched, <c>false</c> otherwise.</returns> protected internal override bool MatchImpl(ParserState state) { while (FirstLeaf.MatchImpl(state)) { } return(true); }
/// <summary> /// Specific rule implementation of the match. /// </summary> /// <param name="state">The state.</param> /// <returns><c>true</c> if input is matched, <c>false</c> otherwise.</returns> protected internal override bool MatchImpl(ParserState state) { if (!Leafs.Any()) { Leafs.Add(RuleFunc()); } return(FirstLeaf.MatchImpl(state)); }
/// <summary> /// Specific rule implementation of the match. Which inverses the given rule. /// </summary> /// <param name="state">The state.</param> /// <returns><c>true</c> if input is matched, <c>false</c> otherwise.</returns> protected internal override bool MatchImpl(ParserState state) { var oldState = state.Clone(); if (!FirstLeaf.MatchImpl(state)) { return(true); } state.Assign(oldState); return(false); }
/// <summary> /// Specific rule implementation of the match. Which caches the result. /// </summary> /// <param name="state">The state.</param> /// <returns><c>true</c> if input is matched, <c>false</c> otherwise.</returns> protected internal override bool MatchImpl(ParserState state) { var node = CreateNode(Name, state.Input, state.Position, this); var oldChilds = state.Nodes; state.Nodes = new List <Node>(); if (!FirstLeaf.MatchImpl(state)) { state.Nodes = oldChilds; return(false); } node.End = state.Position; node.Leafs = state.Nodes; oldChilds.Add(node); state.Nodes = oldChilds; return(true); }