Parser combinators module.
npm install @prelude/parser










---
``bash`
npm i -E @prelude/parser
`ts`
import * as P from '@prelude/parser'
* rfc4180 - CSV
* rfc5234 – ABNF
* rfc8259 – JSON
* char-range
* char-ranges
* either
* enclosed
* exhaustive
* literal
* map
* maybe
* pair
* right
* sep0 (alias: separated0)
* sep1 (alias: separated1)
* sep2 (alias: separated2)
* seq (alias: sequence)
* star
* times
* trim
* union
* utf8
* ws0
* ws1
* Input
* Invalid
* join
* ParserResult
* Rfc8259
* alpha
* bit
* char
* false
* null
* trim
* true
* ws
* dquote: Parser
* dquote2: Parser
* lf: Parser
* cr: Parser
* nl: Parser
* textdata: Parser
* comma: Parser
* nonEscaped: Parser
* escaped: Parser
* field: Parser
* record: Parser
* file: Parser
* parse: (inputString: string) => string[][]
* false: Parser
* null: Parser
* parse: (inputString: string) => unknown
* true: Parser
* valueSeparator: Parser
* charRange: (ranges: string) => Parser
Returns parser matching provided character ranges.
Example charRange('09azAZ') – equivalent to /[0-9a-zA-Z]/ regexp.
* Csv
* either: (a: Parser, b: Parser) => Parser
* exhaustive: (a: Parser) => (inputString: string) => A
Returns top level string to result parser asserting all input has been parsed.
Throws If parser fails or input is not fully exhausted.
* exhaustiveEmpty: (input: any) => Fail | Ok
Returns parser that matches empty string exhaustively.
* join: (a: Parser
Joins string (or undefined) result array into single string result.
* Json
* literal: (expected: string) => Parser
* map: (a: Parser, f: (_: A) => B) => Parser
* maybe: (a: Parser) => Parser
* pair: (a: Parser, b: Parser) => Parser<[A, B]>
* Rfc4180
* Rfc8259
* right: (a: Parser
Returns b after successful a and b sequence match.
* sep0: (s: Parser
* sep1: (s: Parser
* sep2: (s: Parser
* seq:
* sorrounded: (lhs: Parser
Returns a parser sorrounded by lhs and rhs.
* sorrounded1: (s: Parser
Returns a parser sorrounded by s at the beginning and at the end.
* star: (a: Parser, min?: number) => Parser
Returns parser matching at least min (default 0) times a parser.
* times: (n: number, a: Parser) => Parser
* trim: (a: Parser) => Parser
* union:
* utf8: (chars: string) => Parser
Returns parser matching one of provided chars.
* whileChar: (chars: string, min?: number) => Parser
Matches any char listed in chars at least min (default 0) times.
* ws0: Parser
* ws1: Parser
`
MIT License
Copyright 2021 Mirek Rusin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
``