(errors: ParsingDiagnostic[])
| 309 | |
| 310 | function formatError(errors: ParsingDiagnostic[]): Expression { |
| 311 | return [ |
| 312 | 'Error', |
| 313 | [ |
| 314 | 'String', |
| 315 | ...(errors.map((x) => { |
| 316 | // If we have an array as the last element, it's the trace. Remove it. |
| 317 | if ( |
| 318 | Array.isArray(x.message) && |
| 319 | Array.isArray(x.message[x.message.length - 1]) |
| 320 | ) { |
| 321 | return x.message.slice(0, -1); |
| 322 | } |
| 323 | |
| 324 | return x.message; |
| 325 | }) as Expression[]), |
| 326 | ], |
| 327 | ]; |
| 328 | } |
| 329 | |
| 330 | export function validEpsil(s: string): Expression | null { |
| 331 | const [value, errors] = parseEpsil(s); |
| 332 | if (errors && errors.length > 0) return formatError(errors); |
no test coverage detected