Modules
Type Aliases
Failure
Ƭ Failure: Object
Failure result type
Type declaration
Name | Type |
---|---|
index | number |
success | false |
Defined in
LazyContext
Ƭ LazyContext<U
>: () => Parser
<U
>
Type parameters
Name |
---|
U |
Type declaration
▸ (): Parser
<U
>
Returns
Parser
<U
>
Defined in
LazyParserOpts
Ƭ LazyParserOpts<U
>: Object
Type parameters
Name |
---|
U |
Type declaration
Name | Type |
---|---|
children? | undefined |
handler? | undefined |
lazy | LazyContext <U > |
name? | string |
Defined in
ParserContext
Ƭ ParserContext<U
>: Object
Type parameters
Name |
---|
U |
Type declaration
Name | Type |
---|---|
children | Parser <any >[] |
handler | ParserHandler <U > |
Defined in
ParserHandler
Ƭ ParserHandler<U
>: (input
: string
, index
: number
, children
: Parser
<any
>[], state
: any
) => Result
<U
>
Type parameters
Name |
---|
U |
Type declaration
▸ (input
, index
, children
, state
): Result
<U
>
Type of parser handler
Parameters
Name | Type |
---|---|
input | string |
index | number |
children | Parser <any >[] |
state | any |
Returns
Result
<U
>
Defined in
Result
Ƭ Result<U
>: Success
<U
> | Failure
Parser result
Type parameters
Name |
---|
U |
Defined in
ResultType
Ƭ ResultType<U
>: U
extends Parser
<infer R> ? R
: never
Get result type of Parser.
Type parameters
Name |
---|
U |
Defined in
ResultTypes
Ƭ ResultTypes<U
>: U
extends [infer Head, ...(infer Tail)] ? [ResultType
<Head
>, ...ResultTypes<Tail>] : []
Get result types of Parsers.
Type parameters
Name |
---|
U |
Defined in
StrictParserOpts
Ƭ StrictParserOpts<U
>: Object
Type parameters
Name |
---|
U |
Type declaration
Name | Type |
---|---|
children? | Parser <any >[] |
handler | ParserHandler <U > |
lazy? | undefined |
name? | string |
Defined in
Success
Ƭ Success<U
>: Object
Success result type
Type parameters
Name |
---|
U |
Type declaration
Name | Type |
---|---|
index | number |
success | true |
value | U |
Defined in
Variables
char
• Const
char: Parser
<string
>
any char
Defined in
cr
• Const
cr: Parser
<"\r"
>
Defined in
crlf
• Const
crlf: Parser
<"\r\n"
>
Defined in
eof
• Const
eof: Parser
<null
>
Match the end of the input string.
Defined in
lf
• Const
lf: Parser
<"\n"
>
Defined in
lineBegin
• Const
lineBegin: Parser
<null
>
Match lineBegin
Defined in
lineEnd
• Const
lineEnd: Parser
<null
>
Match lineEnd
Defined in
newline
• Const
newline: Parser
<"\r"
| "\n"
| "\r\n"
>
newline
Defined in
sof
• Const
sof: Parser
<null
>
Match the begin of the input string.
Defined in
Functions
alt
▸ alt<U
>(parsers
): Parser
<ResultTypes
<U
>[number
]>
alt
Type parameters
Name | Type |
---|---|
U | extends Parser <unknown >[] |
Parameters
Name | Type |
---|---|
parsers | [...U[]] |
Returns
Parser
<ResultTypes
<U
>[number
]>
Defined in
failure
▸ failure(index
): Failure
Make a failure result.
Parameters
Name | Type |
---|---|
index | number |
Returns
Defined in
language
▸ language<U
>(syntaxes
): U
Create a language
Type parameters
Name |
---|
U |
Parameters
Name | Type |
---|---|
syntaxes | { [K in string | number | symbol]: Function } |
Returns
U
Defined in
lazy
▸ lazy<U
>(fn
, name?
): Parser
<U
>
Create a lazy parser.
Type parameters
Name |
---|
U |
Parameters
Name | Type |
---|---|
fn | () => Parser <U > |
name? | string |
Returns
Parser
<U
>
Defined in
match
▸ match<U
>(parser
): Parser
<U
>
match
Type parameters
Name |
---|
U |
Parameters
Name | Type |
---|---|
parser | Parser <U > |
Returns
Parser
<U
>
Defined in
notMatch
▸ notMatch(parser
): Parser
<null
>
notMatch
Parameters
Name | Type |
---|---|
parser | Parser <unknown > |
Returns
Parser
<null
>
Defined in
parser
▸ parser<U
>(handler
, children?
, name?
): Parser
<U
>
Create a custom parser.
Type parameters
Name |
---|
U |
Parameters
Name | Type |
---|---|
handler | ParserHandler <U > |
children? | Parser <any >[] |
name? | string |
Returns
Parser
<U
>
Defined in
seq
▸ seq<U
>(parsers
): Parser
<ResultTypes
<[...U]>>
Create a new parser that sequentially applies an array of parser.
Type parameters
Name | Type |
---|---|
U | extends Parser <any >[] |
Parameters
Name | Type |
---|---|
parsers | [...U[]] |
Returns
Parser
<ResultTypes
<[...U]>>
Defined in
▸ seq<U
, V
>(parsers
, select
): U
[V
]
Create a new parser that sequentially applies an array of parser.
Type parameters
Name | Type |
---|---|
U | extends Parser <any >[] |
V | extends number |
Parameters
Name | Type | Description |
---|---|---|
parsers | [...U[]] | - |
select | V | The index of the data returned in the result. |
Returns
U
[V
]
Defined in
str
▸ str<U
>(value
): Parser
<U
>
Create a new parser that matches the given string.
Type parameters
Name | Type |
---|---|
U | extends string |
Parameters
Name | Type |
---|---|
value | U |
Returns
Parser
<U
>
Defined in
▸ str(pattern
): Parser
<string
>
Create a new parser that matches the given regular expression.
Parameters
Name | Type |
---|---|
pattern | RegExp |
Returns
Parser
<string
>
Defined in
succeeded
▸ succeeded<U
>(value
): Parser
<U
>
Create a new parser that already succeeds.
Type parameters
Name |
---|
U |
Parameters
Name | Type |
---|---|
value | U |
Returns
Parser
<U
>
Defined in
success
▸ success<U
>(index
, value
): Success
<U
>
Make a success result.
Type parameters
Name |
---|
U |
Parameters
Name | Type |
---|---|
index | number |
value | U |
Returns
Success
<U
>
Defined in
where
▸ where<U
>(condition
, parser
): Parser
<U
>
where
Type parameters
Name |
---|
U |
Parameters
Name | Type |
---|---|
condition | (state : any ) => boolean |
parser | Parser <U > |
Returns
Parser
<U
>