range-pattern ( pattern -- parser )


Vocabulary
peg.parsers

Inputs
patterna string


Outputs
parsera parser


Word description
Returns a parser that matches a single character based on the set of characters in the pattern string. Any single character in the pattern matches that character. If the pattern begins with a ^ then the set is negated (the element matches any character not in the set). Any pair of characters separated with a dash (-) represents the range of characters from the first to the second, inclusive.

Examples
USING: peg peg.parsers prettyprint strings ; "a" "_a-zA-Z" range-pattern parse 1string .
"a"

USING: peg peg.parsers prettyprint ; "0" "^0-9" range-pattern parse => exception


Definition