From 10e056d3744384a029f05de5903c489898722fc3 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 17 Jul 2022 23:21:03 +0200 Subject: compiler: add support for import/export statements This commit introduces syntax level support for ES6 style module import and export statements. Imports are resolved at compile time and the corresponding module code is compiled into the main program. Also add testcases to cover import and export statement semantics. Signed-off-by: Jo-Philipp Wich --- tests/custom/99_bugs/25_lexer_shifted_offsets | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/custom/99_bugs/25_lexer_shifted_offsets (limited to 'tests/custom/99_bugs/25_lexer_shifted_offsets') diff --git a/tests/custom/99_bugs/25_lexer_shifted_offsets b/tests/custom/99_bugs/25_lexer_shifted_offsets new file mode 100644 index 0000000..db10121 --- /dev/null +++ b/tests/custom/99_bugs/25_lexer_shifted_offsets @@ -0,0 +1,21 @@ +When lexing a source buffer with a non-zero offset, e.g. due to a +skipped interpreter line, lexical tokens reported a wrong offset +to the compiler, causing error locations and source context lines +to be incorrectly shifted. + +-- Testcase -- +#!/usr/bin/env ucode +{% + die("Error"); +%} +-- End -- + +-- Expect stderr -- +Error +In line 3, byte 12: + + ` die("Error");` + Near here -----^ + + +-- End -- -- cgit v1.2.3