Defines how to parse source
Defines how to parse source
Captures the result of this parser and bind another parser
const parser = regexp(/\d/y).bind(digit => text(`${digit}abc`))
parser.matches('11abc') // true
parser.matches('99abc') // true
Maps the result of a parser to a different value
const parser = regexp(/\d/y).map(Number)
parser.parseToEnd('1') // 1
Mapping function
Returns true if the parser can parse the given string
const parser = text('a')
parser.matches('a') // true
parser.matches('b') // false
Input
Returns true if the parse can parse the given string to the end
const parser = text('a')
parser.matchesToEnd('a') // true
parser.matchesToEnd('ab') // false
Input
Attempts to parse a string to the end. Fails if the parser does not parse the entire input
const parser = text('a')
parser.parseToEnd('a') // 'a'
parse.parseToEnd('a1') instanceof ParseError // true
Input string
Generated using TypeDoc
The core parser which provides functions for combining parsers