class Rattler::Parsers::Match
Match
parses by matching with a Regexp
. If the Regexp
matches at the parse position the entire matched string is returned, otherwise the parse fails.
Public Class Methods
[](re)
click to toggle source
@param [Regexp] re the pattern to match @return [Match] a new match parser that matches with re
# File lib/rattler/parsers/match.rb, line 13 def self.[](re) self.new(:re => re) end
Public Instance Methods
parse(scanner, rules, scope = ParserScope.empty)
click to toggle source
If the Regexp
matches at the parse position, return the matched string, otherwise return a false value.
@param [StringScanner] scanner the scanner for the current parse @param [RuleSet] rules the grammar rules being used for the current parse @param [ParserScope] scope the scope of captured results
@return the matched string, or nil
# File lib/rattler/parsers/match.rb, line 30 def parse(scanner, rules, scope = ParserScope.empty) scanner.scan re end