@@ -16,10 +16,9 @@ const enum MatcherType {
16
16
CharacterSet ,
17
17
CharacterClass ,
18
18
}
19
-
20
- let _flags : Flags ;
21
-
22
19
export class Matcher {
20
+ @lazy static _flags : Flags ;
21
+
23
22
constructor ( readonly type : MatcherType ) { }
24
23
25
24
matches ( code : u32 ) : bool {
@@ -47,20 +46,23 @@ export class Matcher {
47
46
node : CharacterClassNode ,
48
47
flags : Flags
49
48
) : CharacterClassMatcher {
50
- _flags = flags ;
49
+ Matcher . _flags = flags ;
51
50
const matchers = node . expressions . map < Matcher > ( ( exp ) => {
52
51
switch ( exp . type ) {
53
52
case NodeType . CharacterRange :
54
53
return Matcher . fromCharacterRangeNode (
55
54
exp as CharacterRangeNode ,
56
- _flags
55
+ Matcher . _flags
57
56
) ;
58
57
case NodeType . Character :
59
- return Matcher . fromCharacterNode ( exp as CharacterNode , _flags ) ;
58
+ return Matcher . fromCharacterNode (
59
+ exp as CharacterNode ,
60
+ Matcher . _flags
61
+ ) ;
60
62
case NodeType . CharacterSet :
61
63
return Matcher . fromCharacterClassNode (
62
64
exp as CharacterSetNode ,
63
- _flags
65
+ Matcher . _flags
64
66
) ;
65
67
default :
66
68
throw new Error ( "unsupported node type within character set" ) ;
@@ -93,9 +95,12 @@ export class CharacterMatcher extends Matcher {
93
95
}
94
96
}
95
97
96
- const LOWERCASE_LETTERS = new Range ( Char . a , Char . z ) ;
97
- const UPPERCASE_LETTERS = new Range ( Char . A , Char . Z ) ;
98
- const UPPER_LOWER_OFFSET = Char . a - Char . A ;
98
+ // @ts -ignore
99
+ @lazy const LOWERCASE_LETTERS = new Range ( Char . a , Char . z ) ;
100
+ // @ts -ignore
101
+ @lazy const UPPERCASE_LETTERS = new Range ( Char . A , Char . Z ) ;
102
+ // @ts -ignore
103
+ @lazy const UPPER_LOWER_OFFSET = Char . a - Char . A ;
99
104
100
105
export class CharacterRangeMatcher extends Matcher {
101
106
private ranges : Range [ ] ;
0 commit comments