Add error message for unhandled states and actions
This commit is contained in:
19
asm.js
19
asm.js
@@ -754,9 +754,15 @@ class Parser {
|
|||||||
*handle(src) {
|
*handle(src) {
|
||||||
let action;
|
let action;
|
||||||
for (const token of this.tokenizer.handle(src)) {
|
for (const token of this.tokenizer.handle(src)) {
|
||||||
if (action = this.handlers[this.state](token)) {
|
const handler = this.handlers[this.state];
|
||||||
yield action;
|
if (handler == undefined) {
|
||||||
|
console.error(`ERROR: Unhandled state ${this.state}`);
|
||||||
|
this.state = State.TOP;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action = handler(token))
|
||||||
|
yield action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -955,8 +961,13 @@ export class Assembler {
|
|||||||
|
|
||||||
push(chunk) {
|
push(chunk) {
|
||||||
const text = this.decoder.decode(chunk, { stream: true });
|
const text = this.decoder.decode(chunk, { stream: true });
|
||||||
for (const action of this.parser.handle(text))
|
for (const action of this.parser.handle(text)) {
|
||||||
this.handlers[action.type](action);
|
const handler = this.handlers[action.type];
|
||||||
|
if (handler == undefined)
|
||||||
|
console.error("ERROR: Unhandled action", action);
|
||||||
|
else
|
||||||
|
handler(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lookup_block(symbol) {
|
lookup_block(symbol) {
|
||||||
|
|||||||
Reference in New Issue
Block a user