@@ -32,10 +32,33 @@ function lexer(input: string): Token[] {
3232 } ;
3333 } ;
3434
35+ /**
36+ * 过滤函数内容
37+ */
38+ const matchFunction = ( currentChar : string , validator : RegExp ) => {
39+ let value = currentChar ;
40+ const start = current ;
41+ do {
42+ if ( currentChar === '\n' ) {
43+ line ++ ;
44+ }
45+
46+ currentChar = input [ ++ current ] ;
47+ value += currentChar ;
48+ } while ( ! validator . test ( currentChar ) ) ; // 处理转义字符
49+ tokens . push ( {
50+ type : TokenType . FunctionArguments ,
51+ value,
52+ start : start ,
53+ lineNumber : line ,
54+ end : current ,
55+ } ) ;
56+ ++ current ;
57+ } ;
58+
3559 /**
3660 * 过滤(提取) 引号中的内容
3761 */
38- // eslint-disable-next-line
3962 const matchQuotation = ( currentChar : string , validator : RegExp , TokenType : TokenType ) => {
4063 do {
4164 if ( currentChar === '\n' ) {
@@ -50,7 +73,7 @@ function lexer(input: string): Token[] {
5073 while ( current < input . length ) {
5174 let char = input [ current ] ;
5275
53- // 按顺序处理 换行符 反引号 单引号 双引号 注释 分号
76+ // 按顺序处理 括号函数 换行符 反引号 单引号 双引号 注释 分号
5477 // 引号内 可能包含注释包含的符号以及分号 所以优先处理引号里面的内容 去除干扰信息
5578
5679 if ( char === '\n' ) {
@@ -59,6 +82,11 @@ function lexer(input: string): Token[] {
5982 continue ;
6083 }
6184
85+ if ( TokenReg . LeftSmallBracket . test ( char ) ) {
86+ matchFunction ( char , TokenReg . RightSmallBracket ) ;
87+ continue ;
88+ }
89+
6290 if ( TokenReg . BackQuotation . test ( char ) ) {
6391 // eslint-disable-next-line
6492 matchQuotation ( char , TokenReg . BackQuotation , TokenType . BackQuotation ) ;
0 commit comments