diff --git a/jaclang/compiler/parser.py b/jaclang/compiler/parser.py index 97d3a83b1..6af2add06 100644 --- a/jaclang/compiler/parser.py +++ b/jaclang/compiler/parser.py @@ -53,12 +53,10 @@ def transform(self, ir: ast.AstNode) -> ast.Module: catch_error.pos_start = e.pos_in_stream or 0 catch_error.pos_end = catch_error.pos_start + 1 - # TODO: Based on the lark error generate the message (consice). - # Example: - # Unexpected token, Unexpected End of File, - # Non terminated string literal, Invalid hex number (0x1zfk), - # Expected a semicollon, etc. - self.error("Syntax Error", node_override=catch_error) + error_msg = "Syntax Error" + if len(e.args) >= 1 and isinstance(e.args[0], str): + error_msg += e.args[0] + self.error(error_msg, node_override=catch_error) except Exception as e: self.error(f"Internal Error: {e}") diff --git a/jaclang/runtimelib/importer.py b/jaclang/runtimelib/importer.py index 06bf69fc2..21c899c1a 100644 --- a/jaclang/runtimelib/importer.py +++ b/jaclang/runtimelib/importer.py @@ -214,10 +214,6 @@ def get_codeobj( if result.errors_had or not result.ir.gen.py_bytecode: for alrt in result.errors_had: - # logger.error( - # f"While importing {len(result.errors_had)} errors" - # f" found in {full_target}" - # ) logger.error(alrt.pretty_print()) return None if result.ir.gen.py_bytecode is not None: diff --git a/jaclang/tests/test_language.py b/jaclang/tests/test_language.py index cc4219621..d3066529d 100644 --- a/jaclang/tests/test_language.py +++ b/jaclang/tests/test_language.py @@ -607,9 +607,12 @@ def test_pyfunc_3(self) -> None: py_out_path = os.path.join(self.fixture_abs_path("./"), "pyfunc_3.py") with open(py_out_path) as f: + file_source = f.read() output = PyastBuildPass( input_ir=ast.PythonModuleAst( - py_ast.parse(f.read()), mod_path=py_out_path + py_ast.parse(file_source), + mod_path=py_out_path, + file_source=file_source, ), ).ir.unparse() self.assertIn("if 0 <= x<= 5 {", output) @@ -726,9 +729,12 @@ def test_random_check(self) -> None: module_path + ".py", ) with open(file_path) as f: + file_source = f.read() jac_ast = PyastBuildPass( input_ir=ast.PythonModuleAst( - py_ast.parse(f.read()), mod_path=file_path + py_ast.parse(file_source), + mod_path=file_path, + file_source=file_source, ) ) ir = jac_pass_to_pass(jac_ast).ir