(expr: Expression)
| 279 | if (typeof expr === 'number') return expr; |
| 280 | if (typeof expr === 'string') { |
| 281 | if (expr[0] === "'" && expr[expr.length - 1] === "'") { |
| 282 | return { str: expr.slice(1, -1) }; |
| 283 | } |
| 284 | return expr; |
| 285 | } |
| 286 | if (Array.isArray(expr)) |
| 287 | return expr.map( |
| 288 | (x) => strip(x ?? 'Nothing') ?? 'Nothing' |
| 289 | ) as any as Expression; |
| 290 | |
| 291 | if (typeof expr === 'object') { |
| 292 | if ('num' in expr) return validJSONNumber(expr.num); |
| 293 | if ('sym' in expr) return expr.sym; |
| 294 | if ('fn' in expr) { |
| 295 | return expr.fn.map( |
| 296 | (x) => strip(x ?? 'Nothing') ?? 'Nothing' |
| 297 | ) as any as Expression; |
| 298 | } |
| 299 | |
| 300 | if ('str' in expr) return { str: expr.str }; |
| 301 | |
| 302 | console.log('Unexpected object literal as an Expression'); |
| 303 | } |
| 304 | |
| 305 | return null; |
| 306 | } |
| 307 | |
| 308 | function formatError(errors: ParsingDiagnostic[]): Expression { |
| 309 | return [ |
| 310 | 'Error', |
| 311 | [ |
| 312 | 'String', |
no test coverage detected