From 4ea1b74c515f752101db793cae93d55ef6784e39 Mon Sep 17 00:00:00 2001 From: Stef Busking Date: Fri, 8 Nov 2019 11:10:58 +0100 Subject: [PATCH] Update devDependencies --- api/prsc.api.json | 2 +- docs/index.md | 24 +++++------ docs/prsc.complete.md | 48 ++++++++++----------- docs/prsc.cut.md | 48 ++++++++++----------- docs/prsc.delimited.md | 58 +++++++++++++------------- docs/prsc.end.md | 26 ++++++------ docs/prsc.error.md | 52 +++++++++++------------ docs/prsc.filter.md | 52 +++++++++++------------ docs/prsc.first.md | 50 +++++++++++----------- docs/prsc.followed.md | 54 ++++++++++++------------ docs/prsc.map.md | 50 +++++++++++----------- docs/prsc.md | 90 ++++++++++++++++++++-------------------- docs/prsc.not.md | 50 +++++++++++----------- docs/prsc.ok.md | 48 ++++++++++----------- docs/prsc.okwithvalue.md | 50 +++++++++++----------- docs/prsc.optional.md | 52 +++++++++++------------ docs/prsc.or.md | 48 ++++++++++----------- docs/prsc.parser.md | 26 ++++++------ docs/prsc.parseresult.md | 48 ++++++++++----------- docs/prsc.peek.md | 52 +++++++++++------------ docs/prsc.plus.md | 52 +++++++++++------------ docs/prsc.preceded.md | 54 ++++++++++++------------ docs/prsc.recognize.md | 48 ++++++++++----------- docs/prsc.second.md | 50 +++++++++++----------- docs/prsc.star.md | 52 +++++++++++------------ docs/prsc.then.md | 52 +++++++++++------------ docs/prsc.token.md | 48 ++++++++++----------- package.json | 10 ++--- 28 files changed, 647 insertions(+), 647 deletions(-) diff --git a/api/prsc.api.json b/api/prsc.api.json index eba7dca..d4e6835 100644 --- a/api/prsc.api.json +++ b/api/prsc.api.json @@ -1,7 +1,7 @@ { "metadata": { "toolPackage": "@microsoft/api-extractor", - "toolVersion": "7.5.2", + "toolVersion": "7.5.5", "schemaVersion": 1003, "oldestForwardsCompatibleVersion": 1001 }, diff --git a/docs/index.md b/docs/index.md index aa93e4c..7e39fb2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,12 +1,12 @@ - - -[Home](./index.md) - -## API Reference - -## Packages - -| Package | Description | -| --- | --- | -| [prsc](./prsc.md) | | - + + +[Home](./index.md) + +## API Reference + +## Packages + +| Package | Description | +| --- | --- | +| [prsc](./prsc.md) | | + diff --git a/docs/prsc.complete.md b/docs/prsc.complete.md index 76df7cd..30c8918 100644 --- a/docs/prsc.complete.md +++ b/docs/prsc.complete.md @@ -1,24 +1,24 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [complete](./prsc.complete.md) - -## complete() function - -Creates a parser that applies the given parser and only succeeds (returning the inner parser's result) if parsing concludes at the end of the input string. - -Signature: - -```typescript -export declare function complete(parser: Parser): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | The parser to wrap | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [complete](./prsc.complete.md) + +## complete() function + +Creates a parser that applies the given parser and only succeeds (returning the inner parser's result) if parsing concludes at the end of the input string. + +Signature: + +```typescript +export declare function complete(parser: Parser): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | The parser to wrap | + +Returns: + +`Parser` + diff --git a/docs/prsc.cut.md b/docs/prsc.cut.md index 8507ab5..ed69b4d 100644 --- a/docs/prsc.cut.md +++ b/docs/prsc.cut.md @@ -1,24 +1,24 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [cut](./prsc.cut.md) - -## cut() function - -Creates a parser that turns errors returned by the inner parser into fatal errors. Parsers such as `or` and `star` will not continue to attempt additional matches if a parser returns a fatal error, and will usually return the error instead. - -Signature: - -```typescript -export declare function cut(parser: Parser): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | The parser to wrap | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [cut](./prsc.cut.md) + +## cut() function + +Creates a parser that turns errors returned by the inner parser into fatal errors. Parsers such as `or` and `star` will not continue to attempt additional matches if a parser returns a fatal error, and will usually return the error instead. + +Signature: + +```typescript +export declare function cut(parser: Parser): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | The parser to wrap | + +Returns: + +`Parser` + diff --git a/docs/prsc.delimited.md b/docs/prsc.delimited.md index 22a119b..f3589f5 100644 --- a/docs/prsc.delimited.md +++ b/docs/prsc.delimited.md @@ -1,29 +1,29 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [delimited](./prsc.delimited.md) - -## delimited() function - -Creates a Parser that applies the given parsers in sequence, returning the result value of the middle parser at the offset of the third if all are successful. If any parser fails, the error is returned as-is. - -Optionally makes errors by the second and third parsers fatal if `cutAfterOpen` is `true`. - -Signature: - -```typescript -export declare function delimited(open: Parser, inner: Parser, close: Parser, cutAfterOpen?: boolean): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| open | Parser<TOpen> | First parser to apply, value is discarded | -| inner | Parser<T> | Second parser to apply, value is kept | -| close | Parser<TClose> | Third parser to apply, value is discarded | -| cutAfterOpen | boolean | If true, errors returned by the second and third parsers are considered fatal, causing parsers using this to stop trying other branches. | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [delimited](./prsc.delimited.md) + +## delimited() function + +Creates a Parser that applies the given parsers in sequence, returning the result value of the middle parser at the offset of the third if all are successful. If any parser fails, the error is returned as-is. + +Optionally makes errors by the second and third parsers fatal if `cutAfterOpen` is `true`. + +Signature: + +```typescript +export declare function delimited(open: Parser, inner: Parser, close: Parser, cutAfterOpen?: boolean): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| open | Parser<TOpen> | First parser to apply, value is discarded | +| inner | Parser<T> | Second parser to apply, value is kept | +| close | Parser<TClose> | Third parser to apply, value is discarded | +| cutAfterOpen | boolean | If true, errors returned by the second and third parsers are considered fatal, causing parsers using this to stop trying other branches. | + +Returns: + +`Parser` + diff --git a/docs/prsc.end.md b/docs/prsc.end.md index 23fb5d7..1f0c79b 100644 --- a/docs/prsc.end.md +++ b/docs/prsc.end.md @@ -1,13 +1,13 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [end](./prsc.end.md) - -## end variable - -A parser that only succeeds if the end of the input string is reached. - -Signature: - -```typescript -end: Parser -``` + + +[Home](./index.md) > [prsc](./prsc.md) > [end](./prsc.end.md) + +## end variable + +A parser that only succeeds if the end of the input string is reached. + +Signature: + +```typescript +end: Parser +``` diff --git a/docs/prsc.error.md b/docs/prsc.error.md index 22f0527..f43b9ba 100644 --- a/docs/prsc.error.md +++ b/docs/prsc.error.md @@ -1,26 +1,26 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [error](./prsc.error.md) - -## error() function - -Creates an unsuccessful ParseResult (parse error) at the given offset. - -Signature: - -```typescript -export declare function error(offset: number, expected: string[], fatal?: boolean): ParseResult; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| offset | number | The offset in the input at which matching failed | -| expected | string[] | An array of strings indicating things that were expected at offset | -| fatal | boolean | If true, no other branches should be tried as a result of this error | - -Returns: - -`ParseResult` - + + +[Home](./index.md) > [prsc](./prsc.md) > [error](./prsc.error.md) + +## error() function + +Creates an unsuccessful ParseResult (parse error) at the given offset. + +Signature: + +```typescript +export declare function error(offset: number, expected: string[], fatal?: boolean): ParseResult; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| offset | number | The offset in the input at which matching failed | +| expected | string[] | An array of strings indicating things that were expected at offset | +| fatal | boolean | If true, no other branches should be tried as a result of this error | + +Returns: + +`ParseResult` + diff --git a/docs/prsc.filter.md b/docs/prsc.filter.md index 2afc821..563dcff 100644 --- a/docs/prsc.filter.md +++ b/docs/prsc.filter.md @@ -1,26 +1,26 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [filter](./prsc.filter.md) - -## filter() function - -Creates a Parser that uses the given filter predicate to check values generated by the given parser. Values that pass the predicate are passed through, those that don't return a parse error instead. - -Signature: - -```typescript -export declare function filter(parser: Parser, filter: (v: T) => boolean, expected: string[]): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | Parser to filter | -| filter | (v: T) => boolean | Predicate function over the inner parser's values | -| expected | string[] | Expected values for parse errors generated when the filter rejects a value | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [filter](./prsc.filter.md) + +## filter() function + +Creates a Parser that uses the given filter predicate to check values generated by the given parser. Values that pass the predicate are passed through, those that don't return a parse error instead. + +Signature: + +```typescript +export declare function filter(parser: Parser, filter: (v: T) => boolean, expected: string[]): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | Parser to filter | +| filter | (v: T) => boolean | Predicate function over the inner parser's values | +| expected | string[] | Expected values for parse errors generated when the filter rejects a value | + +Returns: + +`Parser` + diff --git a/docs/prsc.first.md b/docs/prsc.first.md index 8a1e22b..ef0a140 100644 --- a/docs/prsc.first.md +++ b/docs/prsc.first.md @@ -1,25 +1,25 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [first](./prsc.first.md) - -## first() function - -Returns the first of the given two arguments. Useful as a `join` function for `then`. See also `followed`. - -Signature: - -```typescript -export declare function first(x: T1, y: T2): T1; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| x | T1 | Argument to return | -| y | T2 | Argument to ignore | - -Returns: - -`T1` - + + +[Home](./index.md) > [prsc](./prsc.md) > [first](./prsc.first.md) + +## first() function + +Returns the first of the given two arguments. Useful as a `join` function for `then`. See also `followed`. + +Signature: + +```typescript +export declare function first(x: T1, y: T2): T1; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| x | T1 | Argument to return | +| y | T2 | Argument to ignore | + +Returns: + +`T1` + diff --git a/docs/prsc.followed.md b/docs/prsc.followed.md index cad3207..2a7eb5d 100644 --- a/docs/prsc.followed.md +++ b/docs/prsc.followed.md @@ -1,27 +1,27 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [followed](./prsc.followed.md) - -## followed() function - -Creates a Parser that applies the given two parsers in sequence, returning the result value of the first at the offset of the second if both succeed. If either parser fails the error is returned as-is. - -Equivalent to `then(parser, after, first)`. - -Signature: - -```typescript -export declare function followed(parser: Parser, after: Parser): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | First parser to apply, value is kept | -| after | Parser<TAfter> | | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [followed](./prsc.followed.md) + +## followed() function + +Creates a Parser that applies the given two parsers in sequence, returning the result value of the first at the offset of the second if both succeed. If either parser fails the error is returned as-is. + +Equivalent to `then(parser, after, first)`. + +Signature: + +```typescript +export declare function followed(parser: Parser, after: Parser): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | First parser to apply, value is kept | +| after | Parser<TAfter> | | + +Returns: + +`Parser` + diff --git a/docs/prsc.map.md b/docs/prsc.map.md index bd3bd56..f0b256e 100644 --- a/docs/prsc.map.md +++ b/docs/prsc.map.md @@ -1,25 +1,25 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [map](./prsc.map.md) - -## map() function - -Creates a Parser that applies the given function to each value generated by the given parser. - -Signature: - -```typescript -export declare function map(parser: Parser, map: (v: T) => U): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | Parser to map over | -| map | (v: T) => U | Function to transform values generated by parser | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [map](./prsc.map.md) + +## map() function + +Creates a Parser that applies the given function to each value generated by the given parser. + +Signature: + +```typescript +export declare function map(parser: Parser, map: (v: T) => U): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | Parser to map over | +| map | (v: T) => U | Function to transform values generated by parser | + +Returns: + +`Parser` + diff --git a/docs/prsc.md b/docs/prsc.md index e047a5f..6c1ca65 100644 --- a/docs/prsc.md +++ b/docs/prsc.md @@ -1,45 +1,45 @@ - - -[Home](./index.md) > [prsc](./prsc.md) - -## prsc package - -## Functions - -| Function | Description | -| --- | --- | -| [complete(parser)](./prsc.complete.md) | Creates a parser that applies the given parser and only succeeds (returning the inner parser's result) if parsing concludes at the end of the input string. | -| [cut(parser)](./prsc.cut.md) | Creates a parser that turns errors returned by the inner parser into fatal errors. Parsers such as or and star will not continue to attempt additional matches if a parser returns a fatal error, and will usually return the error instead. | -| [delimited(open, inner, close, cutAfterOpen)](./prsc.delimited.md) | Creates a Parser that applies the given parsers in sequence, returning the result value of the middle parser at the offset of the third if all are successful. If any parser fails, the error is returned as-is.Optionally makes errors by the second and third parsers fatal if cutAfterOpen is true. | -| [error(offset, expected, fatal)](./prsc.error.md) | Creates an unsuccessful ParseResult (parse error) at the given offset. | -| [filter(parser, filter, expected)](./prsc.filter.md) | Creates a Parser that uses the given filter predicate to check values generated by the given parser. Values that pass the predicate are passed through, those that don't return a parse error instead. | -| [first(x, y)](./prsc.first.md) | Returns the first of the given two arguments. Useful as a join function for then. See also followed. | -| [followed(parser, after)](./prsc.followed.md) | Creates a Parser that applies the given two parsers in sequence, returning the result value of the first at the offset of the second if both succeed. If either parser fails the error is returned as-is.Equivalent to then(parser, after, first). | -| [map(parser, map)](./prsc.map.md) | Creates a Parser that applies the given function to each value generated by the given parser. | -| [not(parser, expected)](./prsc.not.md) | Creates a parser that succeeds at the starting offset if the given parser fails and vice-versa. | -| [ok(offset)](./prsc.ok.md) | Creates a successful ParseResult with an undefined value. Use this to signal success in cases where no value is required. | -| [okWithValue(offset, value)](./prsc.okwithvalue.md) | Creates a successful ParseResult containing the given value. | -| [optional(parser)](./prsc.optional.md) | Creates a parser that tries to apply the given parser optionally. It returns the inner parser's result if succesful, and otherwise indicates success at the starting offset with a null value.If the inner parser returns a fatal failure, the error is returned as-is. | -| [or(parsers)](./prsc.or.md) | Creates a parser that applies each of the given parsers in turn until one matches, then returns that parser's result. If no parser matches, an error is returned reflecting the furthest offset reached in the input string. If any parser returns a fatal error, no further branches are tried. | -| [peek(parser)](./prsc.peek.md) | Creates a parser that applies the given parser without consuming any input. That is, if the inner parser is successful, success is returned (with the resulting value) at the starting offset, effectively making the parser consume no input.Errors returned by the inner parser are returned as-is. | -| [plus(parser)](./prsc.plus.md) | Creates a parser that tries to apply the given parser one or more times in sequence. Values for successful matches are collected in an array. Once the inner parser no longer matches, success is returned at the offset reached with the accumulated values. The parser is required to match at least once, so an initial failure is returned as-is.If the inner parser returns a fatal failure, the error is returned as-is. | -| [preceded(before, parser)](./prsc.preceded.md) | Creates a Parser that applies the given two parsers in sequence, returning the result of the second if the first succeeds.Equivalent to then(before, parser, second). | -| [recognize(parser)](./prsc.recognize.md) | Creates a parser that applies the given parser. If successful, the inner parser's value is discarded and the substring that was consumed from the input is returned as value instead. Errors are returned as-is. | -| [second(x, y)](./prsc.second.md) | Returns the second of the given two arguments. Useful as a join function for then. See also preceded. | -| [star(parser)](./prsc.star.md) | Creates a parser that tries to apply the given parser zero or more times in sequence. Values for successful matches are collected in an array. Once the inner parser no longer matches, success is returned at the offset reached with the accumulated values.If the inner parser returns a fatal failure, the error is returned as-is. | -| [then(parser1, parser2, join)](./prsc.then.md) | Creates a parser that applies the given two parsers in sequence, returning success only if both succeed. The given join function is used to combine the values from both parsers into the single value to return. If either parser fails, the failure is returned as-is. | -| [token(token)](./prsc.token.md) | Creates a Parser that matches the given string. | - -## Variables - -| Variable | Description | -| --- | --- | -| [end](./prsc.end.md) | A parser that only succeeds if the end of the input string is reached. | - -## Type Aliases - -| Type Alias | Description | -| --- | --- | -| [Parser](./prsc.parser.md) | A parser is a function that tries to match whatever it expects at the given offset in the input string. Returns a ParseResult. | -| [ParseResult](./prsc.parseresult.md) | The result of parsing - either success (with an offset at which to resume parsing the next thing) or failure. If a failure is fatal, parsing should not continue to try alternative options.A ParseResult may contain a value that represents the parsed input. | - + + +[Home](./index.md) > [prsc](./prsc.md) + +## prsc package + +## Functions + +| Function | Description | +| --- | --- | +| [complete(parser)](./prsc.complete.md) | Creates a parser that applies the given parser and only succeeds (returning the inner parser's result) if parsing concludes at the end of the input string. | +| [cut(parser)](./prsc.cut.md) | Creates a parser that turns errors returned by the inner parser into fatal errors. Parsers such as or and star will not continue to attempt additional matches if a parser returns a fatal error, and will usually return the error instead. | +| [delimited(open, inner, close, cutAfterOpen)](./prsc.delimited.md) | Creates a Parser that applies the given parsers in sequence, returning the result value of the middle parser at the offset of the third if all are successful. If any parser fails, the error is returned as-is.Optionally makes errors by the second and third parsers fatal if cutAfterOpen is true. | +| [error(offset, expected, fatal)](./prsc.error.md) | Creates an unsuccessful ParseResult (parse error) at the given offset. | +| [filter(parser, filter, expected)](./prsc.filter.md) | Creates a Parser that uses the given filter predicate to check values generated by the given parser. Values that pass the predicate are passed through, those that don't return a parse error instead. | +| [first(x, y)](./prsc.first.md) | Returns the first of the given two arguments. Useful as a join function for then. See also followed. | +| [followed(parser, after)](./prsc.followed.md) | Creates a Parser that applies the given two parsers in sequence, returning the result value of the first at the offset of the second if both succeed. If either parser fails the error is returned as-is.Equivalent to then(parser, after, first). | +| [map(parser, map)](./prsc.map.md) | Creates a Parser that applies the given function to each value generated by the given parser. | +| [not(parser, expected)](./prsc.not.md) | Creates a parser that succeeds at the starting offset if the given parser fails and vice-versa. | +| [ok(offset)](./prsc.ok.md) | Creates a successful ParseResult with an undefined value. Use this to signal success in cases where no value is required. | +| [okWithValue(offset, value)](./prsc.okwithvalue.md) | Creates a successful ParseResult containing the given value. | +| [optional(parser)](./prsc.optional.md) | Creates a parser that tries to apply the given parser optionally. It returns the inner parser's result if succesful, and otherwise indicates success at the starting offset with a null value.If the inner parser returns a fatal failure, the error is returned as-is. | +| [or(parsers)](./prsc.or.md) | Creates a parser that applies each of the given parsers in turn until one matches, then returns that parser's result. If no parser matches, an error is returned reflecting the furthest offset reached in the input string. If any parser returns a fatal error, no further branches are tried. | +| [peek(parser)](./prsc.peek.md) | Creates a parser that applies the given parser without consuming any input. That is, if the inner parser is successful, success is returned (with the resulting value) at the starting offset, effectively making the parser consume no input.Errors returned by the inner parser are returned as-is. | +| [plus(parser)](./prsc.plus.md) | Creates a parser that tries to apply the given parser one or more times in sequence. Values for successful matches are collected in an array. Once the inner parser no longer matches, success is returned at the offset reached with the accumulated values. The parser is required to match at least once, so an initial failure is returned as-is.If the inner parser returns a fatal failure, the error is returned as-is. | +| [preceded(before, parser)](./prsc.preceded.md) | Creates a Parser that applies the given two parsers in sequence, returning the result of the second if the first succeeds.Equivalent to then(before, parser, second). | +| [recognize(parser)](./prsc.recognize.md) | Creates a parser that applies the given parser. If successful, the inner parser's value is discarded and the substring that was consumed from the input is returned as value instead. Errors are returned as-is. | +| [second(x, y)](./prsc.second.md) | Returns the second of the given two arguments. Useful as a join function for then. See also preceded. | +| [star(parser)](./prsc.star.md) | Creates a parser that tries to apply the given parser zero or more times in sequence. Values for successful matches are collected in an array. Once the inner parser no longer matches, success is returned at the offset reached with the accumulated values.If the inner parser returns a fatal failure, the error is returned as-is. | +| [then(parser1, parser2, join)](./prsc.then.md) | Creates a parser that applies the given two parsers in sequence, returning success only if both succeed. The given join function is used to combine the values from both parsers into the single value to return. If either parser fails, the failure is returned as-is. | +| [token(token)](./prsc.token.md) | Creates a Parser that matches the given string. | + +## Variables + +| Variable | Description | +| --- | --- | +| [end](./prsc.end.md) | A parser that only succeeds if the end of the input string is reached. | + +## Type Aliases + +| Type Alias | Description | +| --- | --- | +| [Parser](./prsc.parser.md) | A parser is a function that tries to match whatever it expects at the given offset in the input string. Returns a ParseResult. | +| [ParseResult](./prsc.parseresult.md) | The result of parsing - either success (with an offset at which to resume parsing the next thing) or failure. If a failure is fatal, parsing should not continue to try alternative options.A ParseResult may contain a value that represents the parsed input. | + diff --git a/docs/prsc.not.md b/docs/prsc.not.md index dfb3098..19863e7 100644 --- a/docs/prsc.not.md +++ b/docs/prsc.not.md @@ -1,25 +1,25 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [not](./prsc.not.md) - -## not() function - -Creates a parser that succeeds at the starting offset if the given parser fails and vice-versa. - -Signature: - -```typescript -export declare function not(parser: Parser, expected: string[]): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | The parser to apply | -| expected | string[] | Expected values for parse errors generated when the inner parser succeeds | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [not](./prsc.not.md) + +## not() function + +Creates a parser that succeeds at the starting offset if the given parser fails and vice-versa. + +Signature: + +```typescript +export declare function not(parser: Parser, expected: string[]): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | The parser to apply | +| expected | string[] | Expected values for parse errors generated when the inner parser succeeds | + +Returns: + +`Parser` + diff --git a/docs/prsc.ok.md b/docs/prsc.ok.md index 4d051d2..ce17339 100644 --- a/docs/prsc.ok.md +++ b/docs/prsc.ok.md @@ -1,24 +1,24 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [ok](./prsc.ok.md) - -## ok() function - -Creates a successful ParseResult with an undefined value. Use this to signal success in cases where no value is required. - -Signature: - -```typescript -export declare function ok(offset: number): ParseResult; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| offset | number | The offset in the input at which to continue parsing | - -Returns: - -`ParseResult` - + + +[Home](./index.md) > [prsc](./prsc.md) > [ok](./prsc.ok.md) + +## ok() function + +Creates a successful ParseResult with an undefined value. Use this to signal success in cases where no value is required. + +Signature: + +```typescript +export declare function ok(offset: number): ParseResult; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| offset | number | The offset in the input at which to continue parsing | + +Returns: + +`ParseResult` + diff --git a/docs/prsc.okwithvalue.md b/docs/prsc.okwithvalue.md index f98880f..1e56120 100644 --- a/docs/prsc.okwithvalue.md +++ b/docs/prsc.okwithvalue.md @@ -1,25 +1,25 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [okWithValue](./prsc.okwithvalue.md) - -## okWithValue() function - -Creates a successful ParseResult containing the given value. - -Signature: - -```typescript -export declare function okWithValue(offset: number, value: T): ParseResult; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| offset | number | The offset in the input at which to continue parsing | -| value | T | The value resulting from applying the parser | - -Returns: - -`ParseResult` - + + +[Home](./index.md) > [prsc](./prsc.md) > [okWithValue](./prsc.okwithvalue.md) + +## okWithValue() function + +Creates a successful ParseResult containing the given value. + +Signature: + +```typescript +export declare function okWithValue(offset: number, value: T): ParseResult; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| offset | number | The offset in the input at which to continue parsing | +| value | T | The value resulting from applying the parser | + +Returns: + +`ParseResult` + diff --git a/docs/prsc.optional.md b/docs/prsc.optional.md index e941b5e..1a8aecc 100644 --- a/docs/prsc.optional.md +++ b/docs/prsc.optional.md @@ -1,26 +1,26 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [optional](./prsc.optional.md) - -## optional() function - -Creates a parser that tries to apply the given parser optionally. It returns the inner parser's result if succesful, and otherwise indicates success at the starting offset with a `null` value. - -If the inner parser returns a fatal failure, the error is returned as-is. - -Signature: - -```typescript -export declare function optional(parser: Parser): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | Parser to attempt to apply | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [optional](./prsc.optional.md) + +## optional() function + +Creates a parser that tries to apply the given parser optionally. It returns the inner parser's result if succesful, and otherwise indicates success at the starting offset with a `null` value. + +If the inner parser returns a fatal failure, the error is returned as-is. + +Signature: + +```typescript +export declare function optional(parser: Parser): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | Parser to attempt to apply | + +Returns: + +`Parser` + diff --git a/docs/prsc.or.md b/docs/prsc.or.md index 2c2528f..0f4624d 100644 --- a/docs/prsc.or.md +++ b/docs/prsc.or.md @@ -1,24 +1,24 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [or](./prsc.or.md) - -## or() function - -Creates a parser that applies each of the given parsers in turn until one matches, then returns that parser's result. If no parser matches, an error is returned reflecting the furthest offset reached in the input string. If any parser returns a fatal error, no further branches are tried. - -Signature: - -```typescript -export declare function or(parsers: Parser[]): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parsers | Parser<T>[] | Parsers to attempt to apply | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [or](./prsc.or.md) + +## or() function + +Creates a parser that applies each of the given parsers in turn until one matches, then returns that parser's result. If no parser matches, an error is returned reflecting the furthest offset reached in the input string. If any parser returns a fatal error, no further branches are tried. + +Signature: + +```typescript +export declare function or(parsers: Parser[]): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parsers | Parser<T>[] | Parsers to attempt to apply | + +Returns: + +`Parser` + diff --git a/docs/prsc.parser.md b/docs/prsc.parser.md index e3d7a22..e5054cc 100644 --- a/docs/prsc.parser.md +++ b/docs/prsc.parser.md @@ -1,13 +1,13 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [Parser](./prsc.parser.md) - -## Parser type - -A parser is a function that tries to match whatever it expects at the given offset in the input string. Returns a ParseResult. - -Signature: - -```typescript -export declare type Parser = (input: string, offset: number) => ParseResult; -``` + + +[Home](./index.md) > [prsc](./prsc.md) > [Parser](./prsc.parser.md) + +## Parser type + +A parser is a function that tries to match whatever it expects at the given offset in the input string. Returns a ParseResult. + +Signature: + +```typescript +export declare type Parser = (input: string, offset: number) => ParseResult; +``` diff --git a/docs/prsc.parseresult.md b/docs/prsc.parseresult.md index ff4d992..f930f25 100644 --- a/docs/prsc.parseresult.md +++ b/docs/prsc.parseresult.md @@ -1,24 +1,24 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [ParseResult](./prsc.parseresult.md) - -## ParseResult type - -The result of parsing - either success (with an offset at which to resume parsing the next thing) or failure. If a failure is fatal, parsing should not continue to try alternative options. - -A ParseResult may contain a value that represents the parsed input. - -Signature: - -```typescript -export declare type ParseResult = { - success: true; - offset: number; - value: T; -} | { - success: false; - offset: number; - expected: string[]; - fatal: boolean; -}; -``` + + +[Home](./index.md) > [prsc](./prsc.md) > [ParseResult](./prsc.parseresult.md) + +## ParseResult type + +The result of parsing - either success (with an offset at which to resume parsing the next thing) or failure. If a failure is fatal, parsing should not continue to try alternative options. + +A ParseResult may contain a value that represents the parsed input. + +Signature: + +```typescript +export declare type ParseResult = { + success: true; + offset: number; + value: T; +} | { + success: false; + offset: number; + expected: string[]; + fatal: boolean; +}; +``` diff --git a/docs/prsc.peek.md b/docs/prsc.peek.md index 69e1675..7f2eb3d 100644 --- a/docs/prsc.peek.md +++ b/docs/prsc.peek.md @@ -1,26 +1,26 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [peek](./prsc.peek.md) - -## peek() function - -Creates a parser that applies the given parser without consuming any input. That is, if the inner parser is successful, success is returned (with the resulting value) at the starting offset, effectively making the parser consume no input. - -Errors returned by the inner parser are returned as-is. - -Signature: - -```typescript -export declare function peek(parser: Parser): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | The parser to apply, value is discarded and any progress made in input is reset. | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [peek](./prsc.peek.md) + +## peek() function + +Creates a parser that applies the given parser without consuming any input. That is, if the inner parser is successful, success is returned (with the resulting value) at the starting offset, effectively making the parser consume no input. + +Errors returned by the inner parser are returned as-is. + +Signature: + +```typescript +export declare function peek(parser: Parser): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | The parser to apply, value is discarded and any progress made in input is reset. | + +Returns: + +`Parser` + diff --git a/docs/prsc.plus.md b/docs/prsc.plus.md index 57a7aa8..ae00876 100644 --- a/docs/prsc.plus.md +++ b/docs/prsc.plus.md @@ -1,26 +1,26 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [plus](./prsc.plus.md) - -## plus() function - -Creates a parser that tries to apply the given parser one or more times in sequence. Values for successful matches are collected in an array. Once the inner parser no longer matches, success is returned at the offset reached with the accumulated values. The parser is required to match at least once, so an initial failure is returned as-is. - -If the inner parser returns a fatal failure, the error is returned as-is. - -Signature: - -```typescript -export declare function plus(parser: Parser): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | The parser to apply repeatedly | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [plus](./prsc.plus.md) + +## plus() function + +Creates a parser that tries to apply the given parser one or more times in sequence. Values for successful matches are collected in an array. Once the inner parser no longer matches, success is returned at the offset reached with the accumulated values. The parser is required to match at least once, so an initial failure is returned as-is. + +If the inner parser returns a fatal failure, the error is returned as-is. + +Signature: + +```typescript +export declare function plus(parser: Parser): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | The parser to apply repeatedly | + +Returns: + +`Parser` + diff --git a/docs/prsc.preceded.md b/docs/prsc.preceded.md index eb0e6b5..cdf0338 100644 --- a/docs/prsc.preceded.md +++ b/docs/prsc.preceded.md @@ -1,27 +1,27 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [preceded](./prsc.preceded.md) - -## preceded() function - -Creates a Parser that applies the given two parsers in sequence, returning the result of the second if the first succeeds. - -Equivalent to `then(before, parser, second)`. - -Signature: - -```typescript -export declare function preceded(before: Parser, parser: Parser): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| before | Parser<TBefore> | First parser to apply, value is discarded | -| parser | Parser<T> | Second parser to apply, value is kept | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [preceded](./prsc.preceded.md) + +## preceded() function + +Creates a Parser that applies the given two parsers in sequence, returning the result of the second if the first succeeds. + +Equivalent to `then(before, parser, second)`. + +Signature: + +```typescript +export declare function preceded(before: Parser, parser: Parser): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| before | Parser<TBefore> | First parser to apply, value is discarded | +| parser | Parser<T> | Second parser to apply, value is kept | + +Returns: + +`Parser` + diff --git a/docs/prsc.recognize.md b/docs/prsc.recognize.md index 6e43586..fb07616 100644 --- a/docs/prsc.recognize.md +++ b/docs/prsc.recognize.md @@ -1,24 +1,24 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [recognize](./prsc.recognize.md) - -## recognize() function - -Creates a parser that applies the given parser. If successful, the inner parser's value is discarded and the substring that was consumed from the input is returned as value instead. Errors are returned as-is. - -Signature: - -```typescript -export declare function recognize(parser: Parser): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | The parser to apply, value is discarded and replaced by the consumed input. | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [recognize](./prsc.recognize.md) + +## recognize() function + +Creates a parser that applies the given parser. If successful, the inner parser's value is discarded and the substring that was consumed from the input is returned as value instead. Errors are returned as-is. + +Signature: + +```typescript +export declare function recognize(parser: Parser): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | The parser to apply, value is discarded and replaced by the consumed input. | + +Returns: + +`Parser` + diff --git a/docs/prsc.second.md b/docs/prsc.second.md index 9934efe..236fc95 100644 --- a/docs/prsc.second.md +++ b/docs/prsc.second.md @@ -1,25 +1,25 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [second](./prsc.second.md) - -## second() function - -Returns the second of the given two arguments. Useful as a `join` function for `then`. See also `preceded`. - -Signature: - -```typescript -export declare function second(x: T1, y: T2): T2; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| x | T1 | Argument to ignore | -| y | T2 | Argument to return | - -Returns: - -`T2` - + + +[Home](./index.md) > [prsc](./prsc.md) > [second](./prsc.second.md) + +## second() function + +Returns the second of the given two arguments. Useful as a `join` function for `then`. See also `preceded`. + +Signature: + +```typescript +export declare function second(x: T1, y: T2): T2; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| x | T1 | Argument to ignore | +| y | T2 | Argument to return | + +Returns: + +`T2` + diff --git a/docs/prsc.star.md b/docs/prsc.star.md index f85b1e3..3a17d4f 100644 --- a/docs/prsc.star.md +++ b/docs/prsc.star.md @@ -1,26 +1,26 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [star](./prsc.star.md) - -## star() function - -Creates a parser that tries to apply the given parser zero or more times in sequence. Values for successful matches are collected in an array. Once the inner parser no longer matches, success is returned at the offset reached with the accumulated values. - -If the inner parser returns a fatal failure, the error is returned as-is. - -Signature: - -```typescript -export declare function star(parser: Parser): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser | Parser<T> | Parser to apply repeatedly | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [star](./prsc.star.md) + +## star() function + +Creates a parser that tries to apply the given parser zero or more times in sequence. Values for successful matches are collected in an array. Once the inner parser no longer matches, success is returned at the offset reached with the accumulated values. + +If the inner parser returns a fatal failure, the error is returned as-is. + +Signature: + +```typescript +export declare function star(parser: Parser): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser | Parser<T> | Parser to apply repeatedly | + +Returns: + +`Parser` + diff --git a/docs/prsc.then.md b/docs/prsc.then.md index fc67150..1652f2b 100644 --- a/docs/prsc.then.md +++ b/docs/prsc.then.md @@ -1,26 +1,26 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [then](./prsc.then.md) - -## then() function - -Creates a parser that applies the given two parsers in sequence, returning success only if both succeed. The given join function is used to combine the values from both parsers into the single value to return. If either parser fails, the failure is returned as-is. - -Signature: - -```typescript -export declare function then(parser1: Parser, parser2: Parser, join: (value1: T1, value2: T2) => T): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| parser1 | Parser<T1> | First parser to apply | -| parser2 | Parser<T2> | Parser to apply after the first one is successful | -| join | (value1: T1, value2: T2) => T | Function used to combine the values of both parsers | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [then](./prsc.then.md) + +## then() function + +Creates a parser that applies the given two parsers in sequence, returning success only if both succeed. The given join function is used to combine the values from both parsers into the single value to return. If either parser fails, the failure is returned as-is. + +Signature: + +```typescript +export declare function then(parser1: Parser, parser2: Parser, join: (value1: T1, value2: T2) => T): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| parser1 | Parser<T1> | First parser to apply | +| parser2 | Parser<T2> | Parser to apply after the first one is successful | +| join | (value1: T1, value2: T2) => T | Function used to combine the values of both parsers | + +Returns: + +`Parser` + diff --git a/docs/prsc.token.md b/docs/prsc.token.md index b7cf62b..318708f 100644 --- a/docs/prsc.token.md +++ b/docs/prsc.token.md @@ -1,24 +1,24 @@ - - -[Home](./index.md) > [prsc](./prsc.md) > [token](./prsc.token.md) - -## token() function - -Creates a Parser that matches the given string. - -Signature: - -```typescript -export declare function token(token: string): Parser; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| token | string | The expected string | - -Returns: - -`Parser` - + + +[Home](./index.md) > [prsc](./prsc.md) > [token](./prsc.token.md) + +## token() function + +Creates a Parser that matches the given string. + +Signature: + +```typescript +export declare function token(token: string): Parser; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| token | string | The expected string | + +Returns: + +`Parser` + diff --git a/package.json b/package.json index 9c0f7c0..1bc8e69 100644 --- a/package.json +++ b/package.json @@ -28,20 +28,20 @@ "url": "https://github.com/bwrrp/prsc.js" }, "devDependencies": { - "@microsoft/api-documenter": "^7.5.4", - "@microsoft/api-extractor": "^7.5.2", - "@types/jest": "^24.0.19", + "@microsoft/api-documenter": "^7.5.7", + "@microsoft/api-extractor": "^7.5.5", + "@types/jest": "^24.0.22", "copyfiles": "^2.1.1", "jest": "^24.9.0", "mkdirp": "^0.5.1", "npm-run-all": "^4.1.5", "prettier": "^1.18.2", "rimraf": "^3.0.0", - "rollup": "^1.25.1", + "rollup": "^1.26.3", "rollup-plugin-sourcemaps": "^0.4.2", "rollup-plugin-terser": "^5.1.2", "ts-jest": "^24.1.0", - "typescript": "^3.6.4" + "typescript": "^3.7.2" }, "jest": { "transform": {