From 2d89ec8b20639884e223fc3f6097f8afb25a961d Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 3 Jun 2022 21:04:40 +0200 Subject: [PATCH] Add built-in functions This is a good proxy test to ensure that scope queries work correctly. --- queries/highlights.scm | 7 +++++++ test/highlight/built-ins.tig | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/highlight/built-ins.tig diff --git a/queries/highlights.scm b/queries/highlights.scm index e9e8536..f8969cd 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -1,3 +1,10 @@ +; Built-ins {{{ +((function_call + function: (identifier) @function.builtin) + (#match? @function.builtin "^(chr|concat|exit|flush|getchar|not|ord|print|print_err|print_int|size|strcmp|streq|substring)$") + (#is-not? local)) +; }}} + ; Keywords {{{ [ "function" diff --git a/test/highlight/built-ins.tig b/test/highlight/built-ins.tig new file mode 100644 index 0000000..d30cb20 --- /dev/null +++ b/test/highlight/built-ins.tig @@ -0,0 +1,19 @@ +let + var a := exit(0) + /* ^ function.builtin */ + + primitive exit(ret: int) /* Shadowing the prelude-included built-in */ + + var b := exit(0) + /* ^ function */ + +in + exit(1); + /* <- function */ + + print("shadowing is fun"); + /* <- function.builtin */ + + b := print + /* ^ variable */ +end