|
@@ -1,17 +1,17 @@
|
|
|
-import * as LocalizedStringsService from "./../../services/localizedStringsService";
|
|
|
+import {getInstance as LocalizedStrings} from "./../../services/localizedStringsService.js";
|
|
|
import { SyntaxError } from "./syntaxError";
|
|
|
|
|
|
-const LocalizedStrings = LocalizedStringsService.getInstance();
|
|
|
|
|
|
function createError (message_id, context = []) {
|
|
|
+ const error_message = LocalizedStrings().getError(message_id, context);
|
|
|
return new SyntaxError(
|
|
|
- LocalizedStrings.getError(message_id, context),
|
|
|
+ error_message,
|
|
|
message_id
|
|
|
);
|
|
|
}
|
|
|
|
|
|
export const SyntaxErrorFactory = Object.freeze({
|
|
|
- extra_lines: () => new SyntaxError(LocalizedStrings.getError("extra_lines")),
|
|
|
+ extra_lines: () => new SyntaxError(LocalizedStrings().getError("extra_lines")),
|
|
|
token_missing_one: (expected, token) => {
|
|
|
const context = [expected, token.text, token.line, token.col];
|
|
|
const error = createError("token_missing_one", context);
|
|
@@ -19,7 +19,7 @@ export const SyntaxErrorFactory = Object.freeze({
|
|
|
return error;
|
|
|
},
|
|
|
token_missing_list: (expectedList, token) => {
|
|
|
- const line = expectedList.join(LocalizedStrings.getOR());
|
|
|
+ const line = expectedList.join(LocalizedStrings().getOR());
|
|
|
const error = SyntaxErrorFactory.token_missing_one(line, token);
|
|
|
error.context = { line: token.line, column: token.col};
|
|
|
return error;
|
|
@@ -73,7 +73,7 @@ export const SyntaxErrorFactory = Object.freeze({
|
|
|
return error;
|
|
|
},
|
|
|
invalid_type: (list, token) => {
|
|
|
- const line = list.join(LocalizedStrings.getOR());
|
|
|
+ const line = list.join(LocalizedStrings().getOR());
|
|
|
const context = [token.text, token.line, token.col, line];
|
|
|
const error = createError("invalid_type", context);
|
|
|
error.context = { line: token.line, column: token.col};
|