diff --git a/thrift-parser.js b/thrift-parser.js index 4aab9e7..46cf9fb 100644 --- a/thrift-parser.js +++ b/thrift-parser.js @@ -37,7 +37,7 @@ module.exports = (source, offset = 0) => { } } drop(); - throw 'Unexcepted Token'; + throw 'Unexcepted Token on readAnyOne'; }; const readUntilThrow = (transaction, key) => { @@ -59,7 +59,7 @@ module.exports = (source, offset = 0) => { const readKeyword = word => { for (let i = 0; i < word.length; i++) { if (source[offset + i] !== word[i]) { - throw 'Unexpected token "' + word + '"'; + throw 'Unexpected token on readKeyboard"' + word + '"'; } } offset += word.length; @@ -212,13 +212,13 @@ module.exports = (source, offset = 0) => { byte === 'X' || byte === 'x' || byte === '.' ) { - throw `Unexpected token ${byte} for integer value`; + throw `Unexpected token on readIntegerValue ${byte} for integer value`; } else { if (result.length) { readSpace(); return +result.join(''); } else { - throw 'Unexpected token ' + byte; + throw 'Unexpected token on readIntegerValue ' + byte; } } } @@ -239,7 +239,7 @@ module.exports = (source, offset = 0) => { readSpace(); return +result.join(''); } else { - throw 'Unexpected token ' + byte; + throw 'Unexpected token on readDecimalValue ' + byte; } } } @@ -262,7 +262,7 @@ module.exports = (source, offset = 0) => { } } - if (source[offset] !== 'e' && source[offset] !== 'E') throw 'Unexpected token'; + if (source[offset] !== 'e' && source[offset] !== 'E') throw 'Unexpected token on readEnotationValue'; result.push(source[offset]); offset++; @@ -276,7 +276,7 @@ module.exports = (source, offset = 0) => { readSpace(); return +result.join(''); } else { - throw 'Unexpected token ' + byte; + throw 'Unexpected token on readEnotationValue ' + byte; } } } @@ -289,11 +289,11 @@ module.exports = (source, offset = 0) => { offset++; } - if (source[offset] !== '0') throw 'Unexpected token'; + if (source[offset] !== '0') throw 'Unexpected token on readHexadecimalValue'; result.push(source[offset]); offset++; - if (source[offset] !== 'x' && source[offset] !== 'X') throw 'Unexpected token'; + if (source[offset] !== 'x' && source[offset] !== 'X') throw 'Unexpected token on readHexadecimalValue'; result.push(source[offset]); offset++; @@ -311,7 +311,7 @@ module.exports = (source, offset = 0) => { readSpace(); return +result.join(''); } else { - throw 'Unexpected token ' + byte; + throw 'Unexpected token on readHexadecimalValue ' + byte; } } } @@ -382,6 +382,7 @@ module.exports = (source, offset = 0) => { }; const readValue = () => readAnyOne( + readName, readHexadecimalValue, // This coming before readNumberValue is important, unfortunately readEnotationValue, // This also needs to come before readNumberValue readDecimalValue,