@@ -4,6 +4,18 @@ import { Token, TokenName } from './token';
44
55type ReaderEntry = string | null ;
66
7+ const beforeFunctionExpressionTokens = [
8+ '(' , '{' , '[' , 'in' , 'typeof' , 'instanceof' , 'new' ,
9+ 'return' , 'case' , 'delete' , 'throw' , 'void' ,
10+ // assignment operators
11+ '=' , '+=' , '-=' , '*=' , '**=' , '/=' , '%=' , '<<=' , '>>=' , '>>>=' ,
12+ '&=' , '|=' , '^=' , ',' ,
13+ // binary/unary operators
14+ '+' , '-' , '*' , '**' , '/' , '%' , '++' , '--' , '<<' , '>>' , '>>>' , '&' ,
15+ '|' , '^' , '!' , '~' , '&&' , '||' , '??' , '?' , ':' , '===' , '==' , '>=' ,
16+ '<=' , '<' , '>' , '!=' , '!=='
17+ ] ;
18+
719interface BufferEntry {
820 type : string ;
921 value : string ;
@@ -27,15 +39,7 @@ class Reader {
2739
2840 // A function following one of those tokens is an expression.
2941 beforeFunctionExpression ( t : string ) : boolean {
30- return [ '(' , '{' , '[' , 'in' , 'typeof' , 'instanceof' , 'new' ,
31- 'return' , 'case' , 'delete' , 'throw' , 'void' ,
32- // assignment operators
33- '=' , '+=' , '-=' , '*=' , '**=' , '/=' , '%=' , '<<=' , '>>=' , '>>>=' ,
34- '&=' , '|=' , '^=' , ',' ,
35- // binary/unary operators
36- '+' , '-' , '*' , '**' , '/' , '%' , '++' , '--' , '<<' , '>>' , '>>>' , '&' ,
37- '|' , '^' , '!' , '~' , '&&' , '||' , '??' , '?' , ':' , '===' , '==' , '>=' ,
38- '<=' , '<' , '>' , '!=' , '!==' ] . indexOf ( t ) >= 0 ;
42+ return beforeFunctionExpressionTokens . includes ( t ) ;
3943 }
4044
4145 // Determine if forward slash (/) is an operator or part of a regular expression
0 commit comments