tarsec 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/combinators/seq.js +1 -12
- package/dist/combinators.d.ts +23 -5
- package/dist/combinators.js +593 -600
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -30
- package/dist/parsers/within.d.ts +1 -1
- package/dist/parsers/within.js +31 -45
- package/dist/parsers.d.ts +65 -2
- package/dist/parsers.js +238 -170
- package/dist/trace.d.ts +8 -1
- package/dist/trace.js +177 -180
- package/dist/types.d.ts +1 -1
- package/dist/types.js +40 -59
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +53 -66
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,10 +40,14 @@ parser("hello there"); // failure
|
|
|
40
40
|
|
|
41
41
|
## Features
|
|
42
42
|
- tarsec is entirely TypeScript. There's nothing to compile.
|
|
43
|
+
- Derived types: tarsec will generate TypeScript types for your parser
|
|
43
44
|
- [Debug mode](/tutorials/debugging.md) that prints what's happening step-by-step
|
|
44
45
|
- Tools to debug your parser's [performance](/tutorials/performance.md)
|
|
45
|
-
- Derived types: tarsec will generate TypeScript types for your parser
|
|
46
46
|
- Partial [backtracking](/tutorials/backtracking.md) support
|
|
47
|
+
- A way to make your parser more [secure](/tutorials/security.md).
|
|
48
|
+
|
|
49
|
+
## Examples
|
|
50
|
+
- [A markdown parser](/tests/examples/markdown.ts)
|
|
47
51
|
|
|
48
52
|
Read more about [use cases for tarsec](/tutorials/use-case.md).
|
|
49
53
|
|
package/dist/combinators/seq.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
});
|
|
1
|
+
export {};
|
package/dist/combinators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CaptureParser, GeneralParser, InferManyReturnType, MergedCaptures, MergedResults, Parser, PickParserType, PlainObject } from "./types";
|
|
1
|
+
import { CaptureParser, GeneralParser, InferManyReturnType, MergedCaptures, MergedResults, Parser, PickParserType, PlainObject } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Takes a parser and runs it zero or more times, returning the results as an array.
|
|
4
4
|
* If the parser is a capture parser, it returns the captures as an array in this form:
|
|
@@ -24,7 +24,7 @@ export declare function many1<const T extends GeneralParser<any, any>>(parser: T
|
|
|
24
24
|
* @param parser - parser to run
|
|
25
25
|
* @returns - the number of times the parser succeeded.
|
|
26
26
|
*/
|
|
27
|
-
export declare function count<T>(parser: Parser<T>): Parser<
|
|
27
|
+
export declare function count<T>(parser: Parser<T>): Parser<number>;
|
|
28
28
|
/**
|
|
29
29
|
* Takes a parser, runs it n times, and returns the results as an array.
|
|
30
30
|
* If it cannot run the parser n times, it fails without consuming input.
|
|
@@ -154,6 +154,24 @@ export declare function manyTill<T>(parser: Parser<T>): Parser<string>;
|
|
|
154
154
|
* @returns a parser that consumes the input string until the stop parser succeeds.
|
|
155
155
|
*/
|
|
156
156
|
export declare function many1Till<T>(parser: Parser<T>): Parser<string>;
|
|
157
|
+
/**
|
|
158
|
+
* `manyTillOneOf` is an optimized version of `manyTill`.
|
|
159
|
+
* The `manyTill` combinator is slow because it runs the given parser
|
|
160
|
+
* on every character of the string until it succeeds. However, if you
|
|
161
|
+
* just want to consume input until you get to a substring,
|
|
162
|
+
* use `manyTillOneOf`. It uses `indexOf`, which is significantly faster
|
|
163
|
+
* than running a parser over every character.
|
|
164
|
+
*
|
|
165
|
+
* Given an array of strings, this parser consumes input until it hits one of those strings.
|
|
166
|
+
* If none of the strings is found, the parser will consume all input and return success.
|
|
167
|
+
*
|
|
168
|
+
* @param str - the string to stop at
|
|
169
|
+
* @param options - object of optional parameters. { insensitive: boolean }
|
|
170
|
+
* @returns a parser that consumes the input string until one of the given strings is found.
|
|
171
|
+
*/
|
|
172
|
+
export declare function manyTillOneOf(stops: string[], { insensitive }?: {
|
|
173
|
+
insensitive?: boolean;
|
|
174
|
+
}): Parser<string>;
|
|
157
175
|
/**
|
|
158
176
|
* `manyTillStr` is an optimized version of `manyTill`.
|
|
159
177
|
* The `manyTill` combinator is slow because it runs the given parser
|
|
@@ -163,11 +181,11 @@ export declare function many1Till<T>(parser: Parser<T>): Parser<string>;
|
|
|
163
181
|
* than running a parser over every character.
|
|
164
182
|
*
|
|
165
183
|
* @param str - the string to stop at
|
|
166
|
-
* @param options - object of optional parameters. {
|
|
184
|
+
* @param options - object of optional parameters. { insensitive: boolean }
|
|
167
185
|
* @returns a parser that consumes the input string until the given string is found.
|
|
168
186
|
*/
|
|
169
|
-
export declare function manyTillStr(str: string, {
|
|
170
|
-
|
|
187
|
+
export declare function manyTillStr(str: string, { insensitive }?: {
|
|
188
|
+
insensitive?: boolean;
|
|
171
189
|
}): Parser<string>;
|
|
172
190
|
/**
|
|
173
191
|
* Like `manyTillStr`, but case insensitive.
|