We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b45e73f commit 4ae08f0Copy full SHA for 4ae08f0
src/parser/parser_lib.ts
@@ -52,10 +52,15 @@ export function clearCache(): void {
52
export class Parser<T> {
53
readonly rawParser: InnerParser<T>;
54
constructor(parser: InnerParser<T>) {
55
+ // TODO: remove assertion
56
+ const ensureParser: InnerParser<T> = (source) => {
57
+ assert(source.source.length > source.position);
58
+ return parser(source);
59
+ };
60
const cache: SourceMemoResult<T> = new SourceMemo();
61
caches.add(new WeakRef(cache));
62
this.rawParser = memoize<InnerParser<T>, Source, SourceMemoResult<T>>(
- parser,
63
+ ensureParser,
64
{ cache },
65
);
66
}
0 commit comments