Пример #1
0
        /// <inheritdoc/>
        public override ParserRuleResult Execute(InputBuffer buffer)
        {
            var succeeded = _delegate(buffer, out var token);

            return(succeeded ?
                   ParserRuleResult.Success(token) :
                   ParserRuleResult.Fail());
        }
Пример #2
0
        /// <inheritdoc/>
        public override ParserRuleResult Execute(InputBuffer buffer)
        {
            var tokens = new List <IToken>();

            foreach (var rule in _rules)
            {
                var result = rule.Execute(buffer);

                // All rules must succeed for this rule to pass through to the mapping stage.
                if (!result.Succeeded)
                {
                    return(ParserRuleResult.Fail());
                }

                if (result.Token != null)
                {
                    tokens.Add(result.Token);
                }
            }

            return(_mapper(tokens));
        }
Пример #3
0
 /// <inheritdoc/>
 public override ParserRuleResult Execute(InputBuffer buffer)
 {
     return(_condition(buffer) ?
            ParserRuleResult.Success(token: null) :
            ParserRuleResult.Fail());
 }