@@ -16,10 +16,9 @@ const enum MatcherType {
1616 CharacterSet ,
1717 CharacterClass ,
1818}
19-
20- let _flags : Flags ;
21-
2219export class Matcher {
20+ @lazy static _flags : Flags ;
21+
2322 constructor ( readonly type : MatcherType ) { }
2423
2524 matches ( code : u32 ) : bool {
@@ -47,20 +46,23 @@ export class Matcher {
4746 node : CharacterClassNode ,
4847 flags : Flags
4948 ) : CharacterClassMatcher {
50- _flags = flags ;
49+ Matcher . _flags = flags ;
5150 const matchers = node . expressions . map < Matcher > ( ( exp ) => {
5251 switch ( exp . type ) {
5352 case NodeType . CharacterRange :
5453 return Matcher . fromCharacterRangeNode (
5554 exp as CharacterRangeNode ,
56- _flags
55+ Matcher . _flags
5756 ) ;
5857 case NodeType . Character :
59- return Matcher . fromCharacterNode ( exp as CharacterNode , _flags ) ;
58+ return Matcher . fromCharacterNode (
59+ exp as CharacterNode ,
60+ Matcher . _flags
61+ ) ;
6062 case NodeType . CharacterSet :
6163 return Matcher . fromCharacterClassNode (
6264 exp as CharacterSetNode ,
63- _flags
65+ Matcher . _flags
6466 ) ;
6567 default :
6668 throw new Error ( "unsupported node type within character set" ) ;
@@ -93,9 +95,12 @@ export class CharacterMatcher extends Matcher {
9395 }
9496}
9597
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 ;
99104
100105export class CharacterRangeMatcher extends Matcher {
101106 private ranges : Range [ ] ;
0 commit comments