示例#1
0
        /// <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);
        }
示例#2
0
        /// <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));
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <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);
        }