From 3e1068a33635e8d6ae46837dddec81c9490bb8a5 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 3 Jun 2022 22:04:28 +0200 Subject: [PATCH] Add built-in types Not sure why it seems like the 'is-not? local' is not working. Will investigate later --- queries/highlights.scm | 4 ++++ test/highlight/built-ins.tig | 12 ++++++++++++ test/highlight/identifiers.tig | 12 ++++++------ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/queries/highlights.scm b/queries/highlights.scm index f8969cd..cb4a85f 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -3,6 +3,10 @@ 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)) + +((type_identifier) @type.builtin + (#match? @type.builtin "^(int|string)$") + (#is-not? local)) ; }}} ; Keywords {{{ diff --git a/test/highlight/built-ins.tig b/test/highlight/built-ins.tig index d30cb20..dd23b30 100644 --- a/test/highlight/built-ins.tig +++ b/test/highlight/built-ins.tig @@ -3,11 +3,23 @@ let /* ^ function.builtin */ primitive exit(ret: int) /* Shadowing the prelude-included built-in */ + /* ^ type.builtin */ var b := exit(0) /* ^ function */ + type int = string /* Shadowing the built-in type */ + /* ^ type.builtin */ + + var c : int := "This is an \"int\"" + /* ^ type.builtin (not sure why it isn't 'type')*/ in + let + var c : int := "This is an int" + /* ^ type.builtin (not sure why it isn't 'type')*/ + in + end; + exit(1); /* <- function */ diff --git a/test/highlight/identifiers.tig b/test/highlight/identifiers.tig index 8a4bfef..f177a5a 100644 --- a/test/highlight/identifiers.tig +++ b/test/highlight/identifiers.tig @@ -1,15 +1,15 @@ type int = int /* ^ variable */ -/* ^ type */ +/* ^ type.builtin */ type int_array = array of int -/* ^ type */ +/* ^ type.builtin */ type record = {a: int, b: string} /* ^ property */ -/* ^ type */ +/* ^ type.builtin */ /* ^ property */ -/* ^ type */ +/* ^ type.builtin */ var record := record {a = 12, b = "27"} /* ^ variable */ @@ -23,7 +23,7 @@ var array := int_array[12] of 27; primitive func(a: int, b: string) : array /* ^ variable.parameter */ -/* ^ type */ +/* ^ type.builtin */ /* ^ variable.parameter */ -/* ^ type */ +/* ^ type.builtin */ /* ^ type */