12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { LocalizedStrings } from './../../services/localizedStringsService';
- import { SyntaxError } from './syntaxError';
- export const SyntaxErrorFactory = Object.freeze({
- extra_lines: () => new SyntaxError(LocalizedStrings.getError("extra_lines")),
- token_missing_one: (expected, token) => {
- const context = [expected, token.text, token.line, token.column];
- return new SyntaxError(LocalizedStrings.getError("token_missing_one", context));
- },
- token_missing_list: (expectedList, token) => {
- const line = expectedList.join(LocalizedStrings.getOR());
- return SyntaxErrorFactory.token_missing_one(line, token);
- },
- id_missing: (token) => {
- const context = [token.text, token.line, token.column];
- return new SyntaxError(LocalizedStrings.getError("id_missing", context));
- },
- eos_missing: (token) => {
- const context = [token.line, token.column];
- return new SyntaxError(LocalizedStrings.getError("eos_missing", context));
- },
- invalid_array_dimension: (typeName, token) => {
- const context = [token.line, token.column, typeName];
- return new SyntaxError(LocalizedStrings.getError("invalid_array_dimension", context));
- },
- invalid_array_size: (token) => {
- const context = [token.line];
- return new SyntaxError(LocalizedStrings.getError("invalid_array_size", context));
- },
- invalid_main_return: (name, typeName, token) => {
- const context = [name, typeName, token.line];
- return new SyntaxError(LocalizedStrings.getError("invalid_main_return", context));
- },
- invalid_var_declaration: (token) => {
- const context = [token.line];
- return new SyntaxError(LocalizedStrings.getError("invalid_var_declaration", context));
- },
- invalid_break_command: (cmdName, token) => {
- const context = [token.line, cmdName];
- return new SyntaxError(LocalizedStrings.getError("invalid_break_command", context));
- },
- invalid_terminal: (token) => {
- const context = [token.text, token.line, token.column];
- return new SyntaxError(LocalizedStrings.getError('invalid_terminal', context));
- },
- invalid_type: (list, token) => {
- const line = list.join(LocalizedStrings.getOR());
- const context = [token.text, token.line, token.column, line]
- return new SyntaxError(LocalizedStrings.getError("invalid_type", context));
- },
- const_not_init: (token) => {
- const context = [token.line, token.column];
- return new SyntaxError(LocalizedStrings.getError("const_not_init", context));
- },
- invalid_id_format: (token) => {
- const context = [token.text, token.line, token.column];
- return new SyntaxError(LocalizedStrings.getError("invalid_id_format", context));
- },
- duplicate_function: (token) => {
- const context = [token.text, token.line, token.column];
- return new SyntaxError(LocalizedStrings.getError("duplicate_function", context));
- },
- main_parameters: () => {
- return new SyntaxError(LocalizedStrings.getError("main_parameters"));
- },
- duplicate_variable: (token) => {
- const context = [token.text, token.line, token.column];
- return new SyntaxError(LocalizedStrings.getError("duplicate_variable", context));
- }
- });
|