|
@@ -5,411 +5,508 @@ import { LanguageDefinedFunction } from '../definedFunctions';
|
|
|
|
|
|
const LocalizedStrings = LocalizedStringsService.getInstance();
|
|
|
|
|
|
+function createRuntimeError (i18n_id, context = []) {
|
|
|
+ return new RuntimeError(LocalizedStrings.getError(i18n_id, context))
|
|
|
+}
|
|
|
+
|
|
|
+function createSemanticError (i18n_id, context = []) {
|
|
|
+ return new SemanticError(LocalizedStrings.getError(i18n_id, context))
|
|
|
+}
|
|
|
+
|
|
|
export const ProcessorErrorFactory = Object.freeze({
|
|
|
symbol_not_found_full: (id, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [id, sourceInfo.line, sourceInfo.column];
|
|
|
- return new SemanticError(LocalizedStrings.getError("symbol_not_found_full", context));
|
|
|
+ return createSemanticError("symbol_not_found_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.symbol_not_found(id);
|
|
|
}
|
|
|
},
|
|
|
symbol_not_found: (id) => {
|
|
|
const context = [id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("symbol_not_found", context));
|
|
|
+ return createSemanticError("symbol_not_found", context);
|
|
|
},
|
|
|
function_missing_full: (id, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [id, sourceInfo.line, sourceInfo.column];
|
|
|
- return new SemanticError(LocalizedStrings.getError("function_missing_full", context));
|
|
|
+ return createSemanticError("function_missing_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.function_missing(id);
|
|
|
}
|
|
|
},
|
|
|
function_missing: (id) => {
|
|
|
const context = [id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("function_missing", context));
|
|
|
+ return createSemanticError("function_missing", context);
|
|
|
},
|
|
|
main_missing: () => {
|
|
|
- return new SemanticError(LocalizedStrings.getError("main_missing"));
|
|
|
- }, // TODO: better urgent error message
|
|
|
+ return createSemanticError("main_missing");
|
|
|
+ },
|
|
|
array_dimension_not_int_full: (sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line];
|
|
|
- return new SemanticError(LocalizedStrings.getError("array_dimension_not_int_full", context));
|
|
|
+ return createSemanticError("array_dimension_not_int_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.array_dimension_not_int();
|
|
|
}
|
|
|
},
|
|
|
array_dimension_not_int: () => {
|
|
|
- return new SemanticError(LocalizedStrings.getError("array_dimension_not_int"));
|
|
|
+ return createSemanticError("array_dimension_not_int");
|
|
|
},
|
|
|
unknown_command_full: (sourceInfo)=> {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("unknown_command_full", context));
|
|
|
+ return createRuntimeError("unknown_command_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.unknown_command();
|
|
|
}
|
|
|
|
|
|
},
|
|
|
unknown_command: ()=> {
|
|
|
- return new RuntimeError(LocalizedStrings.getError("unknown_command"));
|
|
|
+ return createRuntimeError("unknown_command");
|
|
|
},
|
|
|
- incompatible_types_full: (type, dim, sourceInfo) => {
|
|
|
- if(sourceInfo) {
|
|
|
- const context = [LocalizedStrings.translateType(type, dim), sourceInfo.line, sourceInfo.column];
|
|
|
- return new SemanticError(LocalizedStrings.getError("incompatible_types_full", context));
|
|
|
+ incompatible_types_full: (left_type, left_dim, right_type, right_dim, exp, source_info) => {
|
|
|
+ if(source_info) {
|
|
|
+ const context = [LocalizedStrings.translateType(left_type, left_dim), exp, source_info.line,
|
|
|
+ LocalizedStrings.translateType(right_type, right_dim)];
|
|
|
+ return createSemanticError("incompatible_types_full", context);
|
|
|
} else {
|
|
|
- return ProcessorErrorFactory.incompatible_types(type, dim);
|
|
|
+ return ProcessorErrorFactory.incompatible_types(left_type, left_dim, right_type, right_dim, exp);
|
|
|
}
|
|
|
},
|
|
|
- incompatible_types: (type, dim) => {
|
|
|
- const context = [LocalizedStrings.translateType(type, dim)];
|
|
|
- return new SemanticError(LocalizedStrings.getError("incompatible_types", context));
|
|
|
+ incompatible_types: (left_type, left_dim, right_type, right_dim, exp) => {
|
|
|
+ const context = [LocalizedStrings.translateType(left_type, left_dim), exp,
|
|
|
+ LocalizedStrings.translateType(right_type, right_dim)];
|
|
|
+ return createSemanticError("incompatible_types", context);
|
|
|
},
|
|
|
incompatible_types_array_full: (exp, type, dim, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [exp, LocalizedStrings.translateType(type, dim), sourceInfo.line, sourceInfo.column];
|
|
|
- return new SemanticError(LocalizedStrings.getError("incompatible_types_array_full", context));
|
|
|
+ return createSemanticError("incompatible_types_array_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.incompatible_types_array(exp, type, dim);
|
|
|
}
|
|
|
},
|
|
|
incompatible_types_array: (exp, type, dim) => {
|
|
|
const context = [exp, LocalizedStrings.translateType(type, dim)];
|
|
|
- return new SemanticError(LocalizedStrings.getError("incompatible_types_array", context));
|
|
|
+ return createSemanticError("incompatible_types_array", context);
|
|
|
},
|
|
|
loop_condition_type_full: (exp, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, sourceInfo.column, exp];
|
|
|
- return new SemanticError(LocalizedStrings.getError("loop_condition_type_full", context));
|
|
|
+ return createSemanticError("loop_condition_type_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.loop_condition_type(exp);
|
|
|
}
|
|
|
},
|
|
|
loop_condition_type: (exp) => {
|
|
|
const context = [exp];
|
|
|
- return new SemanticError(LocalizedStrings.getError("loop_condition_type", context));
|
|
|
+ return createSemanticError("loop_condition_type", context);
|
|
|
},
|
|
|
endless_loop_full: (sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line];
|
|
|
- return new SemanticError(LocalizedStrings.getError("endless_loop_full", context));
|
|
|
+ return createSemanticError("endless_loop_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.endless_loop();
|
|
|
}
|
|
|
},
|
|
|
endless_loop: () => {
|
|
|
- return new SemanticError(LocalizedStrings.getError("endless_loop"));
|
|
|
+ return createSemanticError("endless_loop");
|
|
|
},
|
|
|
for_condition_type_full: (exp, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, sourceInfo.column, exp];
|
|
|
- return new SemanticError(LocalizedStrings.getError("for_condition_type_full", context));
|
|
|
+ return createSemanticError("for_condition_type_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.for_condition_type(exp);
|
|
|
}
|
|
|
},
|
|
|
for_condition_type: (exp) => {
|
|
|
const context = [exp];
|
|
|
- return new SemanticError(LocalizedStrings.getError("for_condition_type", context));
|
|
|
+ return createSemanticError("for_condition_type", context);
|
|
|
},
|
|
|
if_condition_type_full: (exp, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, sourceInfo.column, exp];
|
|
|
- return new SemanticError(LocalizedStrings.getError("if_condition_type_full", context));
|
|
|
+ return createSemanticError("if_condition_type_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.if_condition_type(exp);
|
|
|
}
|
|
|
},
|
|
|
if_condition_type: (exp) => {
|
|
|
const context = [exp];
|
|
|
- return new SemanticError(LocalizedStrings.getError("if_condition_type", context));
|
|
|
+ return createSemanticError("if_condition_type", context);
|
|
|
},
|
|
|
invalid_global_var: () => {
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_global_var"))
|
|
|
+ return createRuntimeError("invalid_global_var")
|
|
|
},
|
|
|
not_implemented: (id) => {
|
|
|
const context = [id]
|
|
|
- return new RuntimeError(LocalizedStrings.getError("not_implemented", context))
|
|
|
+ return createRuntimeError("not_implemented", context)
|
|
|
},
|
|
|
invalid_case_type_full: (exp, type, dim, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [exp, LocalizedStrings.translateType(type, dim), sourceInfo.line, sourceInfo.column];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_case_type_full", context));
|
|
|
+ return createSemanticError("invalid_case_type_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_case_type(exp, type, dim);
|
|
|
}
|
|
|
},
|
|
|
invalid_case_type: (exp, type, dim) => {
|
|
|
const context = [exp, LocalizedStrings.translateType(type, dim)];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_case_type", context));
|
|
|
+ return createSemanticError("invalid_case_type", context);
|
|
|
},
|
|
|
void_in_expression_full: (id, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, sourceInfo.column, id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("void_in_expression_full", context));
|
|
|
+ return createSemanticError("void_in_expression_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.void_in_expression(id);
|
|
|
}
|
|
|
},
|
|
|
void_in_expression: (id) => {
|
|
|
const context = [id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("void_in_expression", context));
|
|
|
+ return createSemanticError("void_in_expression", context);
|
|
|
},
|
|
|
invalid_array_access_full: (id, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [id, sourceInfo.line, sourceInfo.column];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_array_access_full", context));
|
|
|
+ return createSemanticError("invalid_array_access_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_array_access(id);
|
|
|
}
|
|
|
},
|
|
|
invalid_array_access: (id) => {
|
|
|
const context = [id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_array_access", context));
|
|
|
+ return createSemanticError("invalid_array_access", context);
|
|
|
},
|
|
|
invalid_matrix_access_full: (id, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [id, sourceInfo.line, sourceInfo.column];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_matrix_access_full", context));
|
|
|
+ return createSemanticError("invalid_matrix_access_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_matrix_access(id);
|
|
|
}
|
|
|
},
|
|
|
invalid_matrix_access: (id) => {
|
|
|
const context = [id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_matrix_access", context));
|
|
|
+ return createSemanticError("invalid_matrix_access", context);
|
|
|
},
|
|
|
matrix_column_outbounds_full: (id, value, columns, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, value, id, columns];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("matrix_column_outbounds_full", context));
|
|
|
+ return createRuntimeError("matrix_column_outbounds_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.matrix_column_outbounds(id, value, columns);
|
|
|
}
|
|
|
},
|
|
|
matrix_column_outbounds: (id, value, columns) => {
|
|
|
const context = [value, id, columns];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("matrix_column_outbounds", context));
|
|
|
+ return createRuntimeError("matrix_column_outbounds", context);
|
|
|
},
|
|
|
matrix_line_outbounds_full: (id, value, lines, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, value, id, lines];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("matrix_line_outbounds_full", context));
|
|
|
+ return createRuntimeError("matrix_line_outbounds_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.matrix_line_outbounds(id, value, lines);
|
|
|
}
|
|
|
},
|
|
|
matrix_line_outbounds: (id, value, lines) => {
|
|
|
const context = [value, id, lines];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("matrix_line_outbounds", context));
|
|
|
+ return createRuntimeError("matrix_line_outbounds", context);
|
|
|
},
|
|
|
vector_line_outbounds_full: (id, value, lines, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, value, id, lines];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("vector_line_outbounds_full", context));
|
|
|
+ return createRuntimeError("vector_line_outbounds_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.vector_line_outbounds(id, value, lines);
|
|
|
}
|
|
|
},
|
|
|
vector_line_outbounds: (id, value, lines) => {
|
|
|
const context = [value, id, lines];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("vector_line_outbounds", context));
|
|
|
+ return createRuntimeError("vector_line_outbounds", context);
|
|
|
},
|
|
|
vector_not_matrix_full: (id, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, id];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("vector_not_matrix_full", context));
|
|
|
+ return createRuntimeError("vector_not_matrix_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.vector_not_matrix(id);
|
|
|
}
|
|
|
},
|
|
|
vector_not_matrix: (id) => {
|
|
|
const context = [id];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("vector_not_matrix", context));
|
|
|
+ return createRuntimeError("vector_not_matrix", context);
|
|
|
},
|
|
|
function_no_return: (id) => {
|
|
|
const context = [id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("function_no_return", context));
|
|
|
+ return createSemanticError("function_no_return", context);
|
|
|
},
|
|
|
invalid_void_return_full: (id, type, dim, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, id, LocalizedStrings.translateType(type, dim)];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_void_return_full", context));
|
|
|
+ return createSemanticError("invalid_void_return_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_void_return(id, type, dim);
|
|
|
}
|
|
|
},
|
|
|
invalid_void_return: (id, type, dim) => {
|
|
|
const context = [id, LocalizedStrings.translateType(type, dim)];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_void_return_full", context));
|
|
|
+ return createSemanticError("invalid_void_return_full", context);
|
|
|
},
|
|
|
invalid_return_type_full: (id, type, dim, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, id, LocalizedStrings.translateType(type, dim)];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_return_type_full", context));
|
|
|
+ return createSemanticError("invalid_return_type_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_return_type(id, type, dim);
|
|
|
}
|
|
|
},
|
|
|
invalid_return_type: (id, type, dim) => {
|
|
|
const context = [id, LocalizedStrings.translateType(type, dim)];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_return_type", context));
|
|
|
+ return createSemanticError("invalid_return_type", context);
|
|
|
},
|
|
|
invalid_parameters_size_full: (id, expected, actual, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, id, expected, actual];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_parameters_size_full", context));
|
|
|
+ return createSemanticError("invalid_parameters_size_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_parameters_size(id, expected, actual);
|
|
|
}
|
|
|
},
|
|
|
invalid_parameters_size: (id, expected, actual) => {
|
|
|
const context = [id, expected, actual];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_parameters_size", context));
|
|
|
+ return createSemanticError("invalid_parameters_size", context);
|
|
|
},
|
|
|
invalid_parameter_type_full: (fun_name, exp, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [exp, LanguageDefinedFunction.getLocalName(fun_name), sourceInfo.line];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_parameter_type_full", context));
|
|
|
+ return createSemanticError("invalid_parameter_type_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_parameter_type(fun_name, exp);
|
|
|
}
|
|
|
},
|
|
|
invalid_parameter_type: (fun_name, exp) => {
|
|
|
const context = [exp, LanguageDefinedFunction.getLocalName(fun_name)];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_parameter_type_full", context));
|
|
|
+ return createSemanticError("invalid_parameter_type_full", context);
|
|
|
},
|
|
|
invalid_ref_full: (id, exp, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [exp, id , sourceInfo.line];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_ref_full", context));
|
|
|
+ return createSemanticError("invalid_ref_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_ref(id, exp);
|
|
|
}
|
|
|
},
|
|
|
invalid_ref: (id, exp) => {
|
|
|
const context = [exp, id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_ref", context));
|
|
|
+ return createSemanticError("invalid_ref", context);
|
|
|
},
|
|
|
unexpected_break_command_full: (sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("unexpected_break_command_full", context));
|
|
|
+ return createRuntimeError("unexpected_break_command_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.unexpected_break_command();
|
|
|
}
|
|
|
},
|
|
|
unexpected_break_command: () => {
|
|
|
- return new RuntimeError(LocalizedStrings.getError("unexpected_break_command"));
|
|
|
+ return createRuntimeError("unexpected_break_command");
|
|
|
},
|
|
|
invalid_array_literal_type_full: (exp, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, exp];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_array_literal_type_full", context));
|
|
|
+ return createRuntimeError("invalid_array_literal_type_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_array_literal_type(exp);
|
|
|
}
|
|
|
},
|
|
|
invalid_array_literal_type: (exp) => {
|
|
|
const context = [exp];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_array_literal_type", context));
|
|
|
+ return createRuntimeError("invalid_array_literal_type", context);
|
|
|
},
|
|
|
invalid_array_literal_line_full: (expected, actual, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, expected, actual];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_array_literal_line_full", context));
|
|
|
+ return createRuntimeError("invalid_array_literal_line_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_array_literal_type(expected, actual);
|
|
|
}
|
|
|
},
|
|
|
invalid_array_literal_line: (expected, actual) => {
|
|
|
const context = [expected, actual];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_array_literal_line", context));
|
|
|
+ return createRuntimeError("invalid_array_literal_line", context);
|
|
|
},
|
|
|
invalid_array_literal_column_full: (expected, actual, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, expected, actual];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_array_literal_column_full", context));
|
|
|
+ return createRuntimeError("invalid_array_literal_column_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_array_literal_column(expected, actual);
|
|
|
}
|
|
|
},
|
|
|
invalid_array_literal_column: (expected, actual) => {
|
|
|
const context = [expected, actual];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_array_literal_column", context));
|
|
|
+ return createRuntimeError("invalid_array_literal_column", context);
|
|
|
},
|
|
|
invalid_unary_op_full: (expString, opName, type, dim, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, expString, LocalizedStrings.translateOp(opName), LocalizedStrings.translateType(type, dim)];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_unary_op_full", context));
|
|
|
+ return createRuntimeError("invalid_unary_op_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_unary_op(opName, type, dim);
|
|
|
}
|
|
|
},
|
|
|
invalid_unary_op: (expString, opName, type, dim) => {
|
|
|
const context = [expString, LocalizedStrings.translateOp(opName), LocalizedStrings.translateType(type, dim)];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_unary_op", context));
|
|
|
+ return createRuntimeError("invalid_unary_op", context);
|
|
|
},
|
|
|
invalid_infix_op_full: (expString, opName, typeLeft, dimLeft, typeRight, dimRight, sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line, expString, LocalizedStrings.translateOp(opName), LocalizedStrings.translateType(typeLeft, dimLeft), LocalizedStrings.translateType(typeRight, dimRight)];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_infix_op_full", context));
|
|
|
+ return createRuntimeError("invalid_infix_op_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_infix_op(opName, typeLeft, dimLeft, typeRight, dimRight);
|
|
|
}
|
|
|
},
|
|
|
invalid_infix_op: (expString, opName, typeLeft, dimLeft, typeRight, dimRight) => {
|
|
|
const context = [expString, LocalizedStrings.translateOp(opName), LocalizedStrings.translateType(typeLeft, dimLeft), LocalizedStrings.translateType(typeRight, dimRight)];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_infix_op", context));
|
|
|
+ return createRuntimeError("invalid_infix_op", context);
|
|
|
},
|
|
|
array_dimension_not_positive_full: (sourceInfo) => {
|
|
|
if(sourceInfo) {
|
|
|
const context = [sourceInfo.line];
|
|
|
- return new SemanticError(LocalizedStrings.getError("array_dimension_not_positive_full", context));
|
|
|
+ return createSemanticError("array_dimension_not_positive_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.array_dimension_not_positive();
|
|
|
}
|
|
|
},
|
|
|
array_dimension_not_positive: () => {
|
|
|
- return new SemanticError(LocalizedStrings.getError("array_dimension_not_positive"));
|
|
|
+ return createSemanticError("array_dimension_not_positive");
|
|
|
},
|
|
|
invalid_type_conversion: (value, type, dim) => {
|
|
|
const context = [value, LocalizedStrings.translateType(type, dim)];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_type_conversion", context));
|
|
|
+ return createRuntimeError("invalid_type_conversion", context);
|
|
|
},
|
|
|
- invalid_read_type: (exp, type, dim, name) => {
|
|
|
- const context = [exp, LocalizedStrings.translateType(type, dim), name];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_read_type", context))
|
|
|
+ invalid_read_type: (exp, type, dim, name, source_info) => {
|
|
|
+ const context = [source_info.line, exp, LocalizedStrings.translateType(type, dim), name];
|
|
|
+ return createRuntimeError("invalid_read_type", context)
|
|
|
},
|
|
|
- invalid_read_type_array: (exp, typePos, dimPos, name, typeArray, dimArray) => {
|
|
|
- const context = [exp, LocalizedStrings.translateType(typePos, dimPos), name,LocalizedStrings.translateType(typeArray, dimArray)];
|
|
|
- return new RuntimeError(LocalizedStrings.getError("invalid_read_type_array", context))
|
|
|
+ invalid_read_type_array: (exp, typePos, dimPos, name, typeArray, dimArray, sourceInfo) => {
|
|
|
+ const context = [sourceInfo.line, exp, LocalizedStrings.translateType(typePos, dimPos), name,LocalizedStrings.translateType(typeArray, dimArray)];
|
|
|
+ return createRuntimeError("invalid_read_type_array", context)
|
|
|
},
|
|
|
invalid_const_ref_full: (fun_name, exp, sourceInfo)=> {
|
|
|
if(sourceInfo) {
|
|
|
const context = [exp, LanguageDefinedFunction.getLocalName(fun_name), sourceInfo.line];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_const_ref_full", context));
|
|
|
+ return createSemanticError("invalid_const_ref_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_const_ref(fun_name, exp);
|
|
|
}
|
|
|
},
|
|
|
invalid_const_ref: (fun_name, exp) => {
|
|
|
const context = [exp, LanguageDefinedFunction.getLocalName(fun_name)];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_const_ref", context));
|
|
|
+ return createSemanticError("invalid_const_ref", context);
|
|
|
},
|
|
|
invalid_const_assignment_full: (var_id, source_info) => {
|
|
|
if(source_info) {
|
|
|
const context = [source_info.line, var_id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_const_assignment_full", context));
|
|
|
+ return createSemanticError("invalid_const_assignment_full", context);
|
|
|
} else {
|
|
|
return ProcessorErrorFactory.invalid_const_assignment(var_id);
|
|
|
}
|
|
|
},
|
|
|
invalid_const_assignment: (var_id) => {
|
|
|
const context = [var_id];
|
|
|
- return new SemanticError(LocalizedStrings.getError("invalid_const_assignment", context));
|
|
|
+ return createSemanticError("invalid_const_assignment", context);
|
|
|
+ },
|
|
|
+ invalid_vector_assignment_full: (left_id, left_size, right_id, right_size, source_info) => {
|
|
|
+ if(source_info) {
|
|
|
+ const context = [source_info.line, left_id, left_size, right_id, right_size]
|
|
|
+ return createRuntimeError("invalid_vector_assignment_full", context);
|
|
|
+ } else {
|
|
|
+ return ProcessorErrorFactory.invalid_vector_assignment(left_id, left_size, right_id, right_size);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ invalid_vector_assignment: (left_id, left_size, right_id, right_size) => {
|
|
|
+ const context = [left_id, left_size, right_id, right_size]
|
|
|
+ return createRuntimeError("invalid_vector_assignment", context);
|
|
|
+ },
|
|
|
+ invalid_matrix_assignment_full: (left_id, left_line, left_column, right_id, right_line, right_column, source_info) => {
|
|
|
+ if(source_info) {
|
|
|
+ const context = [source_info.line, left_id, left_line, left_column, right_id, right_line, right_column]
|
|
|
+ return createRuntimeError("invalid_matrix_assignment_full", context);
|
|
|
+ } else {
|
|
|
+ return ProcessorErrorFactory.invalid_matrix_assignment(left_id, left_line, left_column, right_id, right_line, right_column);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ invalid_matrix_assignment: (left_id, left_line, left_column, right_id, right_line, right_column) => {
|
|
|
+ const context = [left_id, left_line, left_column, right_id, right_line, right_column]
|
|
|
+ return createRuntimeError("invalid_matrix_assignment", context);
|
|
|
+ },
|
|
|
+ matrix_to_vector_attr: (left_id, right_id, source_info) => {
|
|
|
+ // SourceInfo have to be valid...
|
|
|
+ const context = [source_info.line, right_id, left_id];
|
|
|
+ return createSemanticError("matrix_to_vector_attr", context);
|
|
|
+ },
|
|
|
+ vector_to_matrix_attr: (left_id, right_id, source_info) => {
|
|
|
+ // SourceInfo have to be valid...
|
|
|
+ const context = [source_info.line, right_id, left_id];
|
|
|
+ return createSemanticError("vector_to_matrix_attr", context);
|
|
|
+ },
|
|
|
+ invalid_matrix_index_assign_full: (mat_id, mat_line, mat_size, exp, exp_size, source_info) => {
|
|
|
+ if(source_info){
|
|
|
+ const context = [source_info.line, mat_line, mat_id, mat_size, exp, exp_size];
|
|
|
+ return createRuntimeError("invalid_matrix_index_assign_full", context);
|
|
|
+ } else {
|
|
|
+ return ProcessorErrorFactory.invalid_matrix_index_assign(mat_id, mat_line, mat_size, exp, exp_size)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ invalid_matrix_index_assign: (mat_id, mat_line, mat_size, exp, exp_size) =>{
|
|
|
+ const context = [mat_line, mat_id, mat_size, exp, exp_size];
|
|
|
+ return createRuntimeError("invalid_matrix_index_assign", context);
|
|
|
+ },
|
|
|
+ invalid_number_elements_vector: (expected_num, exp, actual_num, source_info) => {
|
|
|
+ // SourceInfo have to be valid...
|
|
|
+ const context = [expected_num, source_info.line, exp, actual_num];
|
|
|
+ return createRuntimeError("invalid_number_elements_vector", context);
|
|
|
+ },
|
|
|
+ invalid_number_lines_matrix: (expected_num, exp, actual_num, source_info) => {
|
|
|
+ // SourceInfo have to be valid...
|
|
|
+ const context = [expected_num, source_info.line, exp, actual_num];
|
|
|
+ return createRuntimeError("invalid_number_lines_matrix", context);
|
|
|
+ },
|
|
|
+ divsion_by_zero_full: (exp, source_info) => {
|
|
|
+ if(source_info) {
|
|
|
+ const context = [source_info.line, exp];
|
|
|
+ return createRuntimeError("divsion_by_zero_full", context);
|
|
|
+ } else {
|
|
|
+ return ProcessorErrorFactory.divsion_by_zero(exp);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ divsion_by_zero: (exp) => {
|
|
|
+ const context = [exp];
|
|
|
+ return createRuntimeError("divsion_by_zero", context);
|
|
|
+ },
|
|
|
+ undefined_tanget_value: (value, source_info) => {
|
|
|
+ const context = [source_info.line, value];
|
|
|
+ return createRuntimeError("undefined_tanget_value", context);
|
|
|
+ },
|
|
|
+ negative_log_value: (source_info) => {
|
|
|
+ return createRuntimeError("negative_log_value",[source_info.line]);
|
|
|
+ },
|
|
|
+ invalid_string_index: (index, str, source_info) => {
|
|
|
+ const local_fun_name = LanguageDefinedFunction.getLocalName("$charAt");
|
|
|
+ const context = [source_info.line, local_fun_name, index, str, str.length - 1];
|
|
|
+ return createRuntimeError("invalid_string_index", context);
|
|
|
+ },
|
|
|
+ negative_sqrt_value: (source_info) => {
|
|
|
+ return createRuntimeError("negative_sqrt_value",[source_info.line]);
|
|
|
+ },
|
|
|
+ exceeded_recursive_calls: (source_info) => {
|
|
|
+ const context = [source_info.line];
|
|
|
+ return createRuntimeError("exceeded_recursive_calls", context);
|
|
|
}
|
|
|
});
|