diff options
Diffstat (limited to '')
7 files changed, 44 insertions, 4 deletions
diff --git a/src/mds-kbdc/compile-layout.c b/src/mds-kbdc/compile-layout.c index e6b6ced..574f818 100644 --- a/src/mds-kbdc/compile-layout.c +++ b/src/mds-kbdc/compile-layout.c @@ -19,8 +19,6 @@ /* TODO add call stack */ /* TODO fix so that for-loops do not generate the same errors/warnings in all iterations [loopy_error]. */ /* TODO test set/3 and get/2 */ -/* TODO test function- and macro-overloading */ -/* TODO test same-named macros and functions */ #include "include-stack.h" #include "builtin-functions.h" @@ -521,7 +519,7 @@ static size_t check_function_calls_in_literal_(const mds_kbdc_tree_t* restrict t while ((c = *raw++)) { - if ((c != ' ') && space) + if (space && !strchr(" )", c)) space = 0, count++; if (escape) @@ -2556,7 +2554,7 @@ static int compile_subtree(mds_kbdc_tree_t* restrict tree) case C(STRING): c (string); break; case C(ARRAY): c (array); break; case C(MAP): c (map); break; - case C(MACRO_CALL): c (macro_call); break;/* TODO test */ + case C(MACRO_CALL): c (macro_call); break; case C(RETURN): break_level = 3; break;/* TODO test */ case C(BREAK): break_level = 2; break; case C(CONTINUE): break_level = 1; break; diff --git a/test-files/mds-kbdc/compile-layout/invalid/call_function_as_macro b/test-files/mds-kbdc/compile-layout/invalid/call_function_as_macro new file mode 100644 index 0000000..deedfd1 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/invalid/call_function_as_macro @@ -0,0 +1,4 @@ +function f/0 +end function +f() + diff --git a/test-files/mds-kbdc/compile-layout/invalid/call_macro_as_function b/test-files/mds-kbdc/compile-layout/invalid/call_macro_as_function new file mode 100644 index 0000000..b4a90c2 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/invalid/call_macro_as_function @@ -0,0 +1,4 @@ +macro m/0 +end macro +"" : "\m()" + diff --git a/test-files/mds-kbdc/compile-layout/valid/overloaded_builtin_function b/test-files/mds-kbdc/compile-layout/valid/overloaded_builtin_function new file mode 100644 index 0000000..e13d291 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/valid/overloaded_builtin_function @@ -0,0 +1,7 @@ +function add/3 + \add(\1 \add(\2 \3)) +end function +if \not(\equals(\add(1 2 3) 6)) + "" : 0 +end if + diff --git a/test-files/mds-kbdc/compile-layout/valid/overloaded_function b/test-files/mds-kbdc/compile-layout/valid/overloaded_function new file mode 100644 index 0000000..70bc5b0 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/valid/overloaded_function @@ -0,0 +1,10 @@ +function f/0 + 1 +end function +function f/1 + \1 +end function +if \equals(\f() \f(2)) + "" : 0 +end if + diff --git a/test-files/mds-kbdc/compile-layout/valid/overloaded_macro b/test-files/mds-kbdc/compile-layout/valid/overloaded_macro new file mode 100644 index 0000000..d9bdd41 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/valid/overloaded_macro @@ -0,0 +1,9 @@ +macro m/1 + "" : \1 +end macro +macro m/2 + \add(1 \1) : 2 +end macro +m(1) +m(0 1) + diff --git a/test-files/mds-kbdc/compile-layout/valid/samenamed_macro_and_function b/test-files/mds-kbdc/compile-layout/valid/samenamed_macro_and_function new file mode 100644 index 0000000..8703e7a --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/valid/samenamed_macro_and_function @@ -0,0 +1,8 @@ +function c/0 + "a" +end function +macro c/0 + \c() : \c() +end macro +c() + |