Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions thrift-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = (source, offset = 0) => {
}
}
drop();
throw 'Unexcepted Token';
throw 'Unexcepted Token on readAnyOne';
};

const readUntilThrow = (transaction, key) => {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
Expand All @@ -239,7 +239,7 @@ module.exports = (source, offset = 0) => {
readSpace();
return +result.join('');
} else {
throw 'Unexpected token ' + byte;
throw 'Unexpected token on readDecimalValue ' + byte;
}
}
}
Expand All @@ -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++;

Expand All @@ -276,7 +276,7 @@ module.exports = (source, offset = 0) => {
readSpace();
return +result.join('');
} else {
throw 'Unexpected token ' + byte;
throw 'Unexpected token on readEnotationValue ' + byte;
}
}
}
Expand All @@ -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++;

Expand All @@ -311,7 +311,7 @@ module.exports = (source, offset = 0) => {
readSpace();
return +result.join('');
} else {
throw 'Unexpected token ' + byte;
throw 'Unexpected token on readHexadecimalValue ' + byte;
}
}
}
Expand Down Expand Up @@ -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,
Expand Down