@@ -11,7 +11,7 @@ function parseLet(expression: string): Expression {
11
11
const content = expression . slice ( "(let " . length , - 1 ) ;
12
12
const list = parseList ( "(" + content + ")" ) ;
13
13
// console.log(list);
14
- if ( Array . isArray ( list ) && list . length < 3 ) {
14
+ if ( Array . isArray ( list ) && list . length < 3 ) {
15
15
throw Error ( "Invalid expression" ) ;
16
16
}
17
17
return buildExpression ( [ "let" , ...list ] ) ;
@@ -55,7 +55,7 @@ function buildExpression(list: string | number | ListArray): Expression {
55
55
} ;
56
56
}
57
57
if ( typeof list === "string" ) {
58
- return { type : "Identifier" , name : list } ;
58
+ return parseIdentifier ( list ) ;
59
59
}
60
60
if ( typeof list === "number" ) {
61
61
return parseNumeric ( list ) ;
@@ -89,7 +89,7 @@ function parseList(expression: string): ListArray {
89
89
. replaceAll ( "(" , "[" )
90
90
. replaceAll ( ")" , "]" )
91
91
. replaceAll ( " " , "," )
92
- . replaceAll ( / [ a - z ] ( [ a - z ] | \d ) * / g, ( a ) => '"' + a + '"' ) ,
92
+ . replaceAll ( / [ a - z ] ( [ a - z ] | \d ) * / g, ( a ) => '"' + a + '"' )
93
93
) ;
94
94
}
95
95
@@ -149,7 +149,7 @@ function calculate(expression: Expression, scope: ScopeList): number {
149
149
expression . declarations . forEach ( ( declaration ) => {
150
150
newScope . variables . set (
151
151
declaration . id . name ,
152
- calculate ( declaration . init , newScope ) ,
152
+ calculate ( declaration . init , newScope )
153
153
) ;
154
154
} ) ;
155
155
return calculate ( expression . return . argument , newScope ) ;
@@ -165,7 +165,7 @@ export type Expression =
165
165
export class ScopeList {
166
166
constructor (
167
167
public readonly variables : Map < string , number > = new Map ( ) ,
168
- public parent : ScopeList | null | undefined = null ,
168
+ public parent : ScopeList | null | undefined = null
169
169
) { }
170
170
}
171
171
export interface VariableDeclarator {
0 commit comments