1
1
import { memoize } from "@std/cache/memoize" ;
2
2
import { ArrayResult , ArrayResultError } from "../array_result.ts" ;
3
- import { ClearableCache , Clearable , Lazy } from "../cache.ts" ;
3
+ import { ClearableCacheSet , Clearable , Lazy } from "../cache.ts" ;
4
4
import { throwError } from "../misc.ts" ;
5
5
6
6
export type ValueRest < T > = Readonly < { rest : string ; value : T } > ;
@@ -9,7 +9,7 @@ export type ParserResult<T> = ArrayResult<ValueRest<T>>;
9
9
export class Parser < T > {
10
10
readonly unmemoizedParser : ( src : string ) => ParserResult < T > ;
11
11
readonly rawParser : ( src : string ) => ParserResult < T > ;
12
- static cache : null | ClearableCache = null ;
12
+ static cache : null | ClearableCacheSet = null ;
13
13
constructor ( parser : ( src : string ) => ParserResult < T > ) {
14
14
this . unmemoizedParser = parser ;
15
15
if ( Parser . cache != null ) {
@@ -65,16 +65,16 @@ export class Parser<T> {
65
65
static addToCache ( cache : Clearable ) : void {
66
66
Parser . cache ?. add ( cache ) ;
67
67
}
68
- static startCache ( cache : ClearableCache = new ClearableCache ( ) ) : void {
68
+ static startCache ( cache : ClearableCacheSet = new ClearableCacheSet ( ) ) : void {
69
69
Parser . cache = cache ;
70
70
}
71
71
static endCache ( ) : void {
72
72
Parser . cache = null ;
73
73
}
74
- static startOrEndCache ( cache : null | ClearableCache = null ) : void {
74
+ static startOrEndCache ( cache : null | ClearableCacheSet = null ) : void {
75
75
Parser . cache = cache ;
76
76
}
77
- static inContext < T > ( fn : ( ) => T , cache : null | ClearableCache = null ) : T {
77
+ static inContext < T > ( fn : ( ) => T , cache : null | ClearableCacheSet = null ) : T {
78
78
const previousCache = Parser . cache ;
79
79
Parser . startOrEndCache ( cache ) ;
80
80
const value = fn ( ) ;
0 commit comments