Reuse error function throughout file

This commit is contained in:
jacquej96 2019-10-16 13:55:12 -04:00 committed by GitHub
parent 9efb79118f
commit 51527ae95b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,12 +54,7 @@ function checkForEQUInstruction(line, result, currentLine) {
result.labels.push(tokens[0]); result.labels.push(tokens[0]);
return true; return true;
} else { } else {
result.annotations.push({ produceError(result, currentLine, "Usage: constant_name EQU immediate_value");
row: currentLine,
column: 0,
text: "Usage: constant_name EQU immediate_value",
type: "error"
});
return true; return true;
} }
} else { } else {
@ -102,12 +97,7 @@ function checkForORGInstruction(line, result, currentLine) {
if (!isNaN(num) && num === Math.floor(num)) { if (!isNaN(num) && num === Math.floor(num)) {
return true; return true;
} else { } else {
result.annotations.push({ produceError(result, currentLine, "Invalid operand: " + tokens[1]);
row: currentLine,
column: 0,
text: "Invalid operand: " + tokens[1],
type: "error"
});
return true return true
} }
} }
@ -140,13 +130,7 @@ function parseDWInstruction(line, result, currentLine) {
var strText = values[i].substr(1, values[i].length - 2); var strText = values[i].substr(1, values[i].length - 2);
if (strText.match(MALFORMED_UTF16_RE) != null) { if (strText.match(MALFORMED_UTF16_RE) != null) {
produceError(result, currentLine, "Malformed UTF-16 escape sequence");
result.annotations.push({
row: currentLine,
column: 0,
text: "Malformed UTF-16 escape sequence",
type: "error"
});
return true; return true;
} }
@ -157,15 +141,8 @@ function parseDWInstruction(line, result, currentLine) {
// console.log("is Imm " + values[i]); // console.log("is Imm " + values[i]);
} else { } else {
produceError(result, currentLine, "Usage: DW IMM, IMM ...");
result.annotations.push({
row: currentLine,
column: 0,
text: "Usage: DW IMM, IMM ...",
type: "error"
});
return true; return true;
} }
} }