Compare commits

..

No commits in common. "2d89ec8b20639884e223fc3f6097f8afb25a961d" and "752f941589cbacf431d68021c2fb5056587a515c" have entirely different histories.

9 changed files with 23 additions and 121 deletions

3
.gitignore vendored
View file

@ -1,6 +1,3 @@
# Nix files
/result
/.pre-commit-config.yaml
# Tree-sitter artifact
/tree-sitter-tiger.wasm

View file

@ -115,7 +115,7 @@
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nodejs
(tree-sitter.override { webUISupport = true; })
tree-sitter
];
inherit (checks.pre-commit) shellHook;

View file

@ -1,23 +1,12 @@
; 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))
; Misc {{{
(comment) @comment
(type_identifier) @type
(field_identifier) @property
(identifier) @variable
; }}}
; Keywords {{{
[
"function"
"primitive"
] @keyword.function
[
"do"
"for"
"to"
"while"
] @keyword.repeat
[
"array"
(break_expression)
@ -40,6 +29,13 @@
] @keyword
; }}}
; Literals {{{
(nil_literal) @constant.builtin
(integer_literal) @number
(string_literal) @string
(escape_sequence) @string.escape
; }}}
; Operators {{{
(operator) @operator
@ -60,36 +56,4 @@
] @punctuation.bracket
; }}}
; Functions {{{
(function_call
function: (identifier) @function)
(function_declaration
name: (identifier) @function)
(primitive_declaration
name: (identifier) @function)
(parameters
name: (identifier) @variable.parameter)
; }}}
; Declarations {{{
(import_declaration
file: (string_literal) @string.special.path)
; }}}
; Literals {{{
(nil_literal) @constant.builtin
(integer_literal) @number
(string_literal) @string
(escape_sequence) @string.escape
; }}}
; Misc {{{
(comment) @comment
(type_identifier) @type
(field_identifier) @property
(identifier) @variable
; }}}
; vim: sw=2 foldmethod=marker

View file

@ -1,29 +0,0 @@
; Scopes {{{
[
(for_expression)
(let_expression)
(function_declaration)
] @local.scope
; }}}
; Definitions {{{
(type_declaration
name: (identifier) @local.definition)
(parameters
name: (identifier) @local.definition)
(function_declaration
name: (identifier) @local.definition)
(primitive_declaration
name: (identifier) @local.definition)
(variable_declaration
name: (identifier) @local.definition)
; }}}
; References {{{
(identifier) @local.reference
; }}}
; vim: sw=2 foldmethod=marker

View file

@ -1,19 +0,0 @@
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

View file

@ -1,8 +0,0 @@
primitive print(s: string)
/* ^ function */
/* ^ variable.parameter */
function func(a: int) : int = (print("Hello World!"); a)
/* ^ function */
/* ^ variable.parameter */
/* ^ function */

View file

@ -22,8 +22,8 @@ var array := int_array[12] of 27;
/* ^ type */
primitive func(a: int, b: string) : array
/* ^ variable.parameter */
/* ^ variable */
/* ^ type */
/* ^ variable.parameter */
/* ^ variable */
/* ^ type */
/* ^ type */

View file

@ -1,3 +0,0 @@
import "lib.tih"
/* <- keyword */
/* ^ string.special.path */

View file

@ -5,9 +5,9 @@ let
/* <- keyword */
function f() : int = a
/* <- keyword.function */
/* <- keyword */
primitive g()
/* <- keyword.function */
/* <- keyword */
import "lib.tih"
/* <- keyword */
@ -28,13 +28,13 @@ in
/* ^ keyword */
for i := 12 to 27 do 42;
/* <- keyword.repeat */
/* ^ keyword.repeat */
/* ^ keyword.repeat */
/* <- keyword */
/* ^ keyword */
/* ^ keyword */
while 12 do break
/* <- keyword.repeat */
/* ^ keyword.repeat */
/* <- keyword */
/* ^ keyword */
/* ^ keyword */
end