(errors: any[], parseInfo: {blockId: string, blockStart: number, spans: any[], extraInfo: any, tokens: Token[]})
| 74 | //-------------------------------------------------------------- |
| 75 | |
| 76 | export function parserErrors(errors: any[], parseInfo: {blockId: string, blockStart: number, spans: any[], extraInfo: any, tokens: Token[]}) { |
| 77 | let {blockId, blockStart, spans, extraInfo} = parseInfo; |
| 78 | let normalized = []; |
| 79 | let errorIx = 1; |
| 80 | |
| 81 | for(let error of errors) { |
| 82 | let {token, context, message, resyncedTokens, name} = error; |
| 83 | |
| 84 | let eveError: EveError; |
| 85 | if(name === "MismatchedTokenException") { |
| 86 | eveError = mismatchedToken(error, parseInfo); |
| 87 | } else if(name === "NotAllInputParsedException") { |
| 88 | eveError = notAllInputParsed(error, parseInfo); |
| 89 | } else { |
| 90 | console.log("UNHANDLED ERROR TYPE", name); |
| 91 | let start = token.startOffset; |
| 92 | let stop = token.startOffset + token.image.length; |
| 93 | eveError = new EveError(blockId, start, stop, message, context); |
| 94 | } |
| 95 | |
| 96 | eveError.injectSpan(spans, extraInfo); |
| 97 | normalized.push(eveError); |
| 98 | } |
| 99 | return normalized; |
| 100 | } |
| 101 | |
| 102 | //-------------------------------------------------------------- |
| 103 | // MismatchedToken parse error |
no test coverage detected