Compare commits
35 commits
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | a7f11d946b | ||
Bruno BELANYI | 9806ad4267 | ||
Bruno BELANYI | 4a099243ed | ||
Bruno BELANYI | 5e1ac9da61 | ||
Bruno BELANYI | a233ebe360 | ||
Bruno BELANYI | 45eb3e860c | ||
Bruno BELANYI | 724abf12e8 | ||
Bruno BELANYI | 617e9adaeb | ||
Bruno BELANYI | 6c30591188 | ||
Bruno BELANYI | bc0f83fdeb | ||
Bruno BELANYI | 81d0730632 | ||
Bruno BELANYI | 2917939176 | ||
Bruno BELANYI | 268dd92906 | ||
Bruno BELANYI | 9d9238f284 | ||
Bruno BELANYI | 089a585a41 | ||
Bruno BELANYI | eb1d371499 | ||
Bruno BELANYI | 321560b029 | ||
Bruno BELANYI | d97857d25f | ||
Bruno BELANYI | 984e3c09d0 | ||
Bruno BELANYI | 7927a8cde7 | ||
Bruno BELANYI | 964c9a685d | ||
Bruno BELANYI | 59db3f195b | ||
Bruno BELANYI | e3b70d8880 | ||
Bruno BELANYI | 7e4aeebc0d | ||
Bruno BELANYI | 3b2796d9ad | ||
Bruno BELANYI | f6c2b4c65e | ||
Bruno BELANYI | d253cca017 | ||
Bruno BELANYI | c90d9d8212 | ||
Bruno BELANYI | 96edb1d0f7 | ||
Bruno BELANYI | c7a439c896 | ||
Bruno BELANYI | 6216812a33 | ||
Bruno BELANYI | 5545b9c926 | ||
Bruno BELANYI | 8a56748e88 | ||
Bruno BELANYI | 7975ca2486 | ||
Bruno BELANYI | bca103a393 |
31
.drone.yml
31
.drone.yml
|
@ -1,31 +0,0 @@
|
|||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: abacus checks
|
||||
|
||||
steps:
|
||||
- name: flake check
|
||||
commands:
|
||||
- nix flake check
|
||||
|
||||
- name: package check
|
||||
commands:
|
||||
- nix build
|
||||
|
||||
- name: notifiy
|
||||
commands:
|
||||
- nix run github:ambroisie/matrix-notifier
|
||||
environment:
|
||||
ADDRESS:
|
||||
from_secret: matrix_homeserver
|
||||
ROOM:
|
||||
from_secret: matrix_roomid
|
||||
USER:
|
||||
from_secret: matrix_username
|
||||
PASS:
|
||||
from_secret: matrix_password
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
- success
|
||||
...
|
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Let the forge know about generated files
|
||||
src/grammar.json linguist-generated=true
|
||||
src/node-types.json linguist-generated=true
|
||||
src/parser.c linguist-generated=true
|
||||
src/tree_sitter/parser.h linguist-generated=true
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@
|
|||
|
||||
# Tree-sitter artifact
|
||||
/tree-sitter-tiger.wasm
|
||||
# Rust bindings
|
||||
/target
|
||||
|
|
31
.woodpecker/check.yml
Normal file
31
.woodpecker/check.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
labels:
|
||||
backend: local
|
||||
|
||||
pipeline:
|
||||
- name: flake check
|
||||
image: bash
|
||||
commands:
|
||||
- nix flake check
|
||||
|
||||
- name: package check
|
||||
image: bash
|
||||
commands:
|
||||
- nix build
|
||||
|
||||
- name: notify
|
||||
image: bash
|
||||
secrets:
|
||||
- source: matrix_roomid
|
||||
target: room
|
||||
- source: matrix_username
|
||||
target: user
|
||||
- source: matrix_password
|
||||
target: pass
|
||||
- source: matrix_homeserver
|
||||
target: address
|
||||
commands:
|
||||
- nix run github:ambroisie/matrix-notifier
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
- success
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "tree-sitter-tiger"
|
||||
description = "Tiger grammar for the tree-sitter parsing library"
|
||||
version = "0.1.0"
|
||||
version = "0.3.0"
|
||||
keywords = ["incremental", "parsing", "tiger"]
|
||||
categories = ["parsing", "text-editors"]
|
||||
repository = "https://gitea.belanyi.fr/ambroisie/tree-sitter-tiger"
|
||||
|
|
16
Makefile
Normal file
16
Makefile
Normal file
|
@ -0,0 +1,16 @@
|
|||
.PHONE: all
|
||||
all:
|
||||
tree-sitter generate
|
||||
|
||||
.PHONE: test
|
||||
test: all
|
||||
tree-sitter test
|
||||
nvim-test
|
||||
|
||||
.PHONE: update-tests
|
||||
update-tests: all
|
||||
tree-sitter test -u
|
||||
|
||||
playground:
|
||||
nix shell pkgs#emscripten --command tree-sitter build-wasm
|
||||
tree-sitter playground
|
18
flake.lock
18
flake.lock
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -18,11 +18,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1654007547,
|
||||
"narHash": "sha256-G812EeXZeGeGjkAvbTleGwcKFCGxdLOQb9aViOWASPc=",
|
||||
"lastModified": 1669045945,
|
||||
"narHash": "sha256-BQxzijvZpLQ7R+KuQzCPcFgIS6OK0Onb29pYFe2pzJo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5643714dea562f0161529ab23058562afeff46d0",
|
||||
"rev": "6b5019a48f876f3288efc626fa8b70ad0c64eb46",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -42,11 +42,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1652714503,
|
||||
"narHash": "sha256-qQKVEfDe5FqvGgkZtg5Pc491foeiDPIOeycHMqnPDps=",
|
||||
"lastModified": 1669018323,
|
||||
"narHash": "sha256-/2Ixw4v5JbbhH+sE6huvyG+txhBGIcx5iWIZ4kWtilU=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "521a524771a8e93caddaa0ac1d67d03766a8b0b3",
|
||||
"rev": "46fb5634676994bd333a94c8bd322eb1854ff223",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
34
flake.nix
34
flake.nix
|
@ -54,6 +54,28 @@
|
|||
overlays = [ self.overlays.default ];
|
||||
};
|
||||
|
||||
nvim-test = pkgs.writeShellScriptBin "nvim-test" ''
|
||||
export NVIM_PLENARY='${pkgs.vimPlugins.plenary-nvim}'
|
||||
export NVIM_TREESITTER='${pkgs.vimPlugins.nvim-treesitter}'
|
||||
|
||||
${pkgs.neovim}/bin/nvim --headless --noplugin -u scripts/minimal_init.lua \
|
||||
-c "PlenaryBustedDirectory test/ { minimal_init = './scripts/minimal_init.lua' }"
|
||||
'';
|
||||
|
||||
bump-version = pkgs.writeShellScriptBin "bump-version" ''
|
||||
set -eu
|
||||
|
||||
NEW_VERSION="''${1}"
|
||||
|
||||
${pkgs.jq}/bin/jq ".version = \"''${NEW_VERSION}\"" package.json > package.json.tmp
|
||||
mv package.json.tmp package.json
|
||||
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" Cargo.toml
|
||||
|
||||
git add Cargo.toml package.json
|
||||
echo "Release ''${NEW_VERSION}" | git commit -eF -
|
||||
git tag -a "v''${NEW_VERSION}" -m "Release ''${NEW_VERSION}"
|
||||
'';
|
||||
|
||||
tree-sitter-env = pkgs.stdenv.mkDerivation {
|
||||
name = "tree-sitter-env";
|
||||
|
||||
|
@ -82,18 +104,22 @@
|
|||
hooks = {
|
||||
clang-format = {
|
||||
enable = true;
|
||||
name = "clang-format";
|
||||
entry = "${pkgs.clang-tools}/bin/clang-format -style=file -i";
|
||||
types = [ "text" "c" ];
|
||||
# I don't care for generated files' formatting
|
||||
excludes = [ "src/parser.c" "src/tree_sitter/parser.h" ];
|
||||
language = "system";
|
||||
};
|
||||
|
||||
nixpkgs-fmt = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
nvim-test = {
|
||||
enable = true;
|
||||
name = "nvim tests";
|
||||
entry = "${nvim-test}/bin/nvim-test";
|
||||
pass_filenames = false;
|
||||
};
|
||||
|
||||
tree-sitter = {
|
||||
enable = true;
|
||||
name = "tree-sitter tests";
|
||||
|
@ -114,7 +140,9 @@
|
|||
devShells = {
|
||||
default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
bump-version
|
||||
nodejs
|
||||
nvim-test
|
||||
(tree-sitter.override { webUISupport = true; })
|
||||
];
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tree-sitter-tiger",
|
||||
"version": "0.1.0",
|
||||
"version": "0.3.0",
|
||||
"description": "tiger grammar for tree-sitter",
|
||||
"main": "bindings/node",
|
||||
"keywords": [
|
||||
|
|
|
@ -9,14 +9,11 @@
|
|||
(function_declaration)
|
||||
(primitive_declaration)
|
||||
|
||||
(record_type)
|
||||
|
||||
(class_declaration)
|
||||
(class_type)
|
||||
(method_declaration)
|
||||
] @fold
|
||||
|
||||
[
|
||||
(comment)
|
||||
(string_literal)
|
||||
] @ignore
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
; Keywords {{{
|
||||
[
|
||||
"function"
|
||||
"method"
|
||||
"primitive"
|
||||
] @keyword.function
|
||||
|
||||
|
@ -30,34 +31,26 @@
|
|||
"new"
|
||||
] @keyword.constructor
|
||||
|
||||
|
||||
[
|
||||
"method"
|
||||
] @keyword.method
|
||||
"import"
|
||||
] @include
|
||||
|
||||
[
|
||||
"array"
|
||||
(break_expression)
|
||||
"do"
|
||||
"else"
|
||||
"end"
|
||||
"for"
|
||||
"function"
|
||||
"if"
|
||||
"import"
|
||||
"in"
|
||||
"let"
|
||||
"of"
|
||||
"primitive"
|
||||
"then"
|
||||
"to"
|
||||
"type"
|
||||
"var"
|
||||
"while"
|
||||
|
||||
"class"
|
||||
"extends"
|
||||
"method"
|
||||
"new"
|
||||
|
||||
"_cast"
|
||||
"_chunks"
|
||||
|
@ -101,7 +94,7 @@
|
|||
name: (identifier) @method)
|
||||
|
||||
(parameters
|
||||
name: (identifier) @variable.parameter)
|
||||
name: (identifier) @parameter)
|
||||
; }}}
|
||||
|
||||
; Declarations {{{
|
||||
|
|
|
@ -1,20 +1,64 @@
|
|||
; Control flow {{{
|
||||
(if_expression
|
||||
consequence: (_) @indent)
|
||||
(if_expression) @indent
|
||||
"then" @branch
|
||||
"else" @branch
|
||||
|
||||
(while_expression
|
||||
body: (_) @indent)
|
||||
(while_expression) @indent
|
||||
"do" @branch
|
||||
|
||||
(for_expression
|
||||
body: (_) @indent)
|
||||
(for_expression) @indent
|
||||
"to" @branch
|
||||
; }}}
|
||||
|
||||
; Class {{{
|
||||
(class_declaration
|
||||
fields: (_)* @indent)
|
||||
(class_type
|
||||
fields: (_)* @indent)
|
||||
(class_declaration) @indent
|
||||
(class_declaration "}" @indent_end)
|
||||
|
||||
(class_type) @indent
|
||||
(class_type "}" @indent_end)
|
||||
; }}}
|
||||
|
||||
; Groups {{{
|
||||
(let_expression) @indent
|
||||
"in" @branch
|
||||
"end" @branch
|
||||
(let_expression "end" @indent_end)
|
||||
|
||||
(sequence_expression) @indent
|
||||
")" @branch
|
||||
(sequence_expression ")" @indent_end)
|
||||
; }}}
|
||||
|
||||
; Functions and methods {{{
|
||||
(parameters) @indent
|
||||
(parameters ")" @indent_end)
|
||||
|
||||
(function_call) @indent
|
||||
(method_call) @indent
|
||||
")" @branch
|
||||
|
||||
(function_declaration) @indent
|
||||
(primitive_declaration) @indent
|
||||
(method_declaration) @indent
|
||||
; }}}
|
||||
|
||||
; Values and expressions {{{
|
||||
(array_value) @indent
|
||||
"]" @branch
|
||||
(array_value "]" @indent_end)
|
||||
|
||||
(array_expression) @indent
|
||||
"of" @branch
|
||||
|
||||
(record_expression) @indent
|
||||
"}" @branch
|
||||
(record_expression "}" @indent_end)
|
||||
|
||||
(record_type) @indent
|
||||
"}" @branch
|
||||
(record_type "}" @indent_end)
|
||||
|
||||
(variable_declaration) @indent
|
||||
; }}}
|
||||
|
||||
; Misc{{{
|
||||
|
|
|
@ -31,8 +31,9 @@
|
|||
; Class {{{
|
||||
(class_declaration
|
||||
fields: (_)* @class.inner) @class.outer
|
||||
(class_type
|
||||
fields: (_)* @class.inner) @class.outer
|
||||
(type_declaration
|
||||
(class_type
|
||||
fields: (_)* @class.inner)) @class.outer
|
||||
; }}}
|
||||
|
||||
; Misc {{{
|
||||
|
|
13
scripts/minimal_init.lua
Normal file
13
scripts/minimal_init.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
vim.cmd([[set runtimepath+=$NVIM_PLENARY]])
|
||||
vim.cmd([[set runtimepath+=$NVIM_TREESITTER]])
|
||||
|
||||
vim.cmd([[runtime! plugin/plenary.vim]])
|
||||
vim.cmd([[runtime! plugin/nvim-treesitter.lua]])
|
||||
|
||||
vim.o.swapfile = false
|
||||
vim.bo.swapfile = false
|
||||
|
||||
require("nvim-treesitter.configs").setup({
|
||||
indent = { enable = true },
|
||||
highlight = { enable = true },
|
||||
})
|
269
src/parser.c
generated
269
src/parser.c
generated
|
@ -5,7 +5,7 @@
|
|||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#endif
|
||||
|
||||
#define LANGUAGE_VERSION 13
|
||||
#define LANGUAGE_VERSION 14
|
||||
#define STATE_COUNT 263
|
||||
#define LARGE_STATE_COUNT 2
|
||||
#define SYMBOL_COUNT 109
|
||||
|
@ -1183,6 +1183,272 @@ static const uint16_t ts_non_terminal_alias_map[] = {
|
|||
0,
|
||||
};
|
||||
|
||||
static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
|
||||
[0] = 0,
|
||||
[1] = 1,
|
||||
[2] = 2,
|
||||
[3] = 3,
|
||||
[4] = 4,
|
||||
[5] = 5,
|
||||
[6] = 6,
|
||||
[7] = 7,
|
||||
[8] = 8,
|
||||
[9] = 9,
|
||||
[10] = 10,
|
||||
[11] = 11,
|
||||
[12] = 12,
|
||||
[13] = 13,
|
||||
[14] = 14,
|
||||
[15] = 15,
|
||||
[16] = 16,
|
||||
[17] = 17,
|
||||
[18] = 18,
|
||||
[19] = 19,
|
||||
[20] = 20,
|
||||
[21] = 21,
|
||||
[22] = 22,
|
||||
[23] = 23,
|
||||
[24] = 24,
|
||||
[25] = 25,
|
||||
[26] = 26,
|
||||
[27] = 27,
|
||||
[28] = 28,
|
||||
[29] = 29,
|
||||
[30] = 30,
|
||||
[31] = 31,
|
||||
[32] = 32,
|
||||
[33] = 33,
|
||||
[34] = 34,
|
||||
[35] = 35,
|
||||
[36] = 36,
|
||||
[37] = 37,
|
||||
[38] = 38,
|
||||
[39] = 39,
|
||||
[40] = 40,
|
||||
[41] = 41,
|
||||
[42] = 42,
|
||||
[43] = 43,
|
||||
[44] = 44,
|
||||
[45] = 45,
|
||||
[46] = 46,
|
||||
[47] = 47,
|
||||
[48] = 48,
|
||||
[49] = 49,
|
||||
[50] = 50,
|
||||
[51] = 51,
|
||||
[52] = 52,
|
||||
[53] = 53,
|
||||
[54] = 54,
|
||||
[55] = 55,
|
||||
[56] = 56,
|
||||
[57] = 57,
|
||||
[58] = 58,
|
||||
[59] = 59,
|
||||
[60] = 60,
|
||||
[61] = 61,
|
||||
[62] = 62,
|
||||
[63] = 63,
|
||||
[64] = 64,
|
||||
[65] = 65,
|
||||
[66] = 66,
|
||||
[67] = 67,
|
||||
[68] = 68,
|
||||
[69] = 69,
|
||||
[70] = 70,
|
||||
[71] = 71,
|
||||
[72] = 72,
|
||||
[73] = 73,
|
||||
[74] = 74,
|
||||
[75] = 75,
|
||||
[76] = 76,
|
||||
[77] = 77,
|
||||
[78] = 78,
|
||||
[79] = 79,
|
||||
[80] = 80,
|
||||
[81] = 81,
|
||||
[82] = 82,
|
||||
[83] = 83,
|
||||
[84] = 84,
|
||||
[85] = 85,
|
||||
[86] = 86,
|
||||
[87] = 87,
|
||||
[88] = 88,
|
||||
[89] = 89,
|
||||
[90] = 90,
|
||||
[91] = 91,
|
||||
[92] = 92,
|
||||
[93] = 93,
|
||||
[94] = 94,
|
||||
[95] = 95,
|
||||
[96] = 96,
|
||||
[97] = 97,
|
||||
[98] = 98,
|
||||
[99] = 99,
|
||||
[100] = 100,
|
||||
[101] = 101,
|
||||
[102] = 102,
|
||||
[103] = 103,
|
||||
[104] = 104,
|
||||
[105] = 105,
|
||||
[106] = 106,
|
||||
[107] = 107,
|
||||
[108] = 108,
|
||||
[109] = 109,
|
||||
[110] = 110,
|
||||
[111] = 111,
|
||||
[112] = 112,
|
||||
[113] = 113,
|
||||
[114] = 114,
|
||||
[115] = 115,
|
||||
[116] = 116,
|
||||
[117] = 117,
|
||||
[118] = 118,
|
||||
[119] = 119,
|
||||
[120] = 120,
|
||||
[121] = 121,
|
||||
[122] = 122,
|
||||
[123] = 123,
|
||||
[124] = 124,
|
||||
[125] = 125,
|
||||
[126] = 126,
|
||||
[127] = 127,
|
||||
[128] = 128,
|
||||
[129] = 129,
|
||||
[130] = 130,
|
||||
[131] = 131,
|
||||
[132] = 132,
|
||||
[133] = 133,
|
||||
[134] = 134,
|
||||
[135] = 135,
|
||||
[136] = 136,
|
||||
[137] = 137,
|
||||
[138] = 138,
|
||||
[139] = 139,
|
||||
[140] = 140,
|
||||
[141] = 141,
|
||||
[142] = 142,
|
||||
[143] = 143,
|
||||
[144] = 144,
|
||||
[145] = 145,
|
||||
[146] = 146,
|
||||
[147] = 147,
|
||||
[148] = 148,
|
||||
[149] = 149,
|
||||
[150] = 150,
|
||||
[151] = 151,
|
||||
[152] = 152,
|
||||
[153] = 153,
|
||||
[154] = 154,
|
||||
[155] = 155,
|
||||
[156] = 156,
|
||||
[157] = 157,
|
||||
[158] = 158,
|
||||
[159] = 159,
|
||||
[160] = 160,
|
||||
[161] = 161,
|
||||
[162] = 162,
|
||||
[163] = 163,
|
||||
[164] = 164,
|
||||
[165] = 165,
|
||||
[166] = 166,
|
||||
[167] = 167,
|
||||
[168] = 168,
|
||||
[169] = 169,
|
||||
[170] = 170,
|
||||
[171] = 171,
|
||||
[172] = 172,
|
||||
[173] = 173,
|
||||
[174] = 174,
|
||||
[175] = 175,
|
||||
[176] = 176,
|
||||
[177] = 177,
|
||||
[178] = 178,
|
||||
[179] = 179,
|
||||
[180] = 180,
|
||||
[181] = 181,
|
||||
[182] = 182,
|
||||
[183] = 183,
|
||||
[184] = 184,
|
||||
[185] = 185,
|
||||
[186] = 186,
|
||||
[187] = 187,
|
||||
[188] = 188,
|
||||
[189] = 189,
|
||||
[190] = 190,
|
||||
[191] = 191,
|
||||
[192] = 192,
|
||||
[193] = 193,
|
||||
[194] = 194,
|
||||
[195] = 195,
|
||||
[196] = 196,
|
||||
[197] = 197,
|
||||
[198] = 198,
|
||||
[199] = 199,
|
||||
[200] = 200,
|
||||
[201] = 201,
|
||||
[202] = 202,
|
||||
[203] = 203,
|
||||
[204] = 204,
|
||||
[205] = 205,
|
||||
[206] = 206,
|
||||
[207] = 207,
|
||||
[208] = 208,
|
||||
[209] = 209,
|
||||
[210] = 210,
|
||||
[211] = 211,
|
||||
[212] = 212,
|
||||
[213] = 213,
|
||||
[214] = 214,
|
||||
[215] = 215,
|
||||
[216] = 216,
|
||||
[217] = 217,
|
||||
[218] = 218,
|
||||
[219] = 219,
|
||||
[220] = 220,
|
||||
[221] = 221,
|
||||
[222] = 222,
|
||||
[223] = 223,
|
||||
[224] = 224,
|
||||
[225] = 225,
|
||||
[226] = 226,
|
||||
[227] = 227,
|
||||
[228] = 228,
|
||||
[229] = 229,
|
||||
[230] = 230,
|
||||
[231] = 231,
|
||||
[232] = 232,
|
||||
[233] = 233,
|
||||
[234] = 234,
|
||||
[235] = 235,
|
||||
[236] = 236,
|
||||
[237] = 237,
|
||||
[238] = 238,
|
||||
[239] = 239,
|
||||
[240] = 240,
|
||||
[241] = 241,
|
||||
[242] = 242,
|
||||
[243] = 243,
|
||||
[244] = 244,
|
||||
[245] = 245,
|
||||
[246] = 246,
|
||||
[247] = 247,
|
||||
[248] = 248,
|
||||
[249] = 249,
|
||||
[250] = 250,
|
||||
[251] = 251,
|
||||
[252] = 252,
|
||||
[253] = 253,
|
||||
[254] = 254,
|
||||
[255] = 255,
|
||||
[256] = 256,
|
||||
[257] = 257,
|
||||
[258] = 258,
|
||||
[259] = 259,
|
||||
[260] = 260,
|
||||
[261] = 261,
|
||||
[262] = 262,
|
||||
};
|
||||
|
||||
static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||
START_LEXER();
|
||||
eof = lexer->eof(lexer);
|
||||
|
@ -9205,6 +9471,7 @@ extern const TSLanguage *tree_sitter_tiger(void) {
|
|||
tree_sitter_tiger_external_scanner_serialize,
|
||||
tree_sitter_tiger_external_scanner_deserialize,
|
||||
},
|
||||
.primary_state_ids = ts_primary_state_ids,
|
||||
};
|
||||
return &language;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
primitive print(s: string)
|
||||
/* ^ function */
|
||||
/* ^ variable.parameter */
|
||||
/* ^ parameter */
|
||||
|
||||
function func(a: int) : int = (print("Hello World!"); a)
|
||||
/* ^ function */
|
||||
/* ^ variable.parameter */
|
||||
/* ^ parameter */
|
||||
/* ^ function */
|
||||
|
|
|
@ -22,8 +22,8 @@ var array := int_array[12] of 27;
|
|||
/* ^ type */
|
||||
|
||||
primitive func(a: int, b: string) : array
|
||||
/* ^ variable.parameter */
|
||||
/* ^ parameter */
|
||||
/* ^ type.builtin */
|
||||
/* ^ variable.parameter */
|
||||
/* ^ parameter */
|
||||
/* ^ type.builtin */
|
||||
/* ^ type */
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import "lib.tih"
|
||||
/* <- keyword */
|
||||
/* <- include */
|
||||
/* ^ string.special.path */
|
||||
|
|
|
@ -10,7 +10,7 @@ let
|
|||
/* <- keyword.function */
|
||||
|
||||
import "lib.tih"
|
||||
/* <- keyword */
|
||||
/* <- include */
|
||||
|
||||
type array_of_int = array of int
|
||||
/* <- keyword */
|
||||
|
|
|
@ -12,7 +12,7 @@ let
|
|||
var a := 12
|
||||
|
||||
method meth() : int = self.a
|
||||
/* <- keyword.method */
|
||||
/* <- keyword.function */
|
||||
/* ^ method */
|
||||
/* ^ variable.builtin */
|
||||
}
|
||||
|
|
14
test/indent/classes.tig
Normal file
14
test/indent/classes.tig
Normal file
|
@ -0,0 +1,14 @@
|
|||
class A {
|
||||
var a := 12
|
||||
|
||||
method method() : int = 1
|
||||
}
|
||||
|
||||
type B = class extends A {
|
||||
var b := 27
|
||||
|
||||
method another_method() = (
|
||||
print("called");
|
||||
self.b + self.method()
|
||||
)
|
||||
}
|
22
test/indent/control-flow.tig
Normal file
22
test/indent/control-flow.tig
Normal file
|
@ -0,0 +1,22 @@
|
|||
(
|
||||
if
|
||||
12
|
||||
then
|
||||
27
|
||||
else
|
||||
42
|
||||
;
|
||||
|
||||
for
|
||||
i := 12
|
||||
to
|
||||
27
|
||||
do
|
||||
42
|
||||
;
|
||||
|
||||
while
|
||||
0
|
||||
do
|
||||
break
|
||||
)
|
14
test/indent/functions.tig
Normal file
14
test/indent/functions.tig
Normal file
|
@ -0,0 +1,14 @@
|
|||
primitive long_parameter_list(
|
||||
a: int,
|
||||
b: string,
|
||||
c: type
|
||||
)
|
||||
|
||||
function f() =
|
||||
(
|
||||
long_parameter_list(
|
||||
1,
|
||||
"2",
|
||||
nil
|
||||
)
|
||||
)
|
10
test/indent/groupings.tig
Normal file
10
test/indent/groupings.tig
Normal file
|
@ -0,0 +1,10 @@
|
|||
let
|
||||
var a := 42
|
||||
in
|
||||
(
|
||||
12;
|
||||
27;
|
||||
42
|
||||
);
|
||||
a
|
||||
end
|
30
test/indent/values-and-expressions.tig
Normal file
30
test/indent/values-and-expressions.tig
Normal file
|
@ -0,0 +1,30 @@
|
|||
let
|
||||
type array_of_int = array of int
|
||||
|
||||
type record = {
|
||||
a: int,
|
||||
b: string,
|
||||
c: type
|
||||
}
|
||||
|
||||
var a :=
|
||||
"a string"
|
||||
in
|
||||
array[
|
||||
12
|
||||
]
|
||||
;
|
||||
|
||||
array_of_int[
|
||||
27
|
||||
]
|
||||
of
|
||||
42
|
||||
;
|
||||
|
||||
record {
|
||||
a = 1,
|
||||
b = "2",
|
||||
c = nil
|
||||
}
|
||||
end
|
86
test/indent_spec.lua
Normal file
86
test/indent_spec.lua
Normal file
|
@ -0,0 +1,86 @@
|
|||
package.path = package.path .. ";" .. vim.env.NVIM_TREESITTER .. "/?.lua"
|
||||
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
local runner = Runner:new(it, "./test/indent/", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent Tiger:", function()
|
||||
describe("whole file:", function()
|
||||
runner:whole_file("../highlight/", {
|
||||
expected_failures = {
|
||||
-- NOTE: none for now
|
||||
},
|
||||
})
|
||||
runner:whole_file("../tags/", {
|
||||
expected_failures = {
|
||||
-- NOTE: none for now
|
||||
},
|
||||
})
|
||||
runner:whole_file(".", {
|
||||
expected_failures = {
|
||||
-- NOTE: none for now
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
runner:new_line("classes.tig", { on_line = 1, text = "var a := 0", indent = 2 }, "class declaration beginning", XFAIL)
|
||||
runner:new_line("classes.tig", { on_line = 2, text = "var a := 0", indent = 2 }, "class declaration after field")
|
||||
runner:new_line("classes.tig", { on_line = 4, text = "var a := 0", indent = 2 }, "class declaration after method")
|
||||
runner:new_line("classes.tig", { on_line = 5, text = "var a := 0", indent = 0 }, "after class declaration")
|
||||
runner:new_line("classes.tig", { on_line = 7, text = "var a := 0", indent = 2 }, "class type beginning", XFAIL)
|
||||
runner:new_line("classes.tig", { on_line = 8, text = "var a := 0", indent = 2 }, "class type after field")
|
||||
runner:new_line("classes.tig", { on_line = 10, text = "self.a := 0", indent = 4 }, "inside method", XFAIL)
|
||||
runner:new_line("classes.tig", { on_line = 13, text = "var a := 0", indent = 2 }, "class type after method")
|
||||
runner:new_line("classes.tig", { on_line = 14, text = "var a := 0", indent = 0 }, "after class type")
|
||||
|
||||
runner:new_line("control-flow.tig", { on_line = 2, text = "true", indent = 4 }, "if condition", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 4, text = "true", indent = 4 }, "if consequence", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 4, text = "true", indent = 4 }, "if alternative", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 10, text = "start := 0", indent = 4 }, "for index start", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 12, text = "the_end", indent = 4 }, "for index end", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 14, text = "break", indent = 4 }, "for body", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 18, text = "true", indent = 4 }, "while condition", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 20, text = "break", indent = 4 }, "while body", XFAIL)
|
||||
|
||||
runner:new_line("functions.tig", { on_line = 1, text = "parameter: int,", indent = 2 }, "parameter list beginning", XFAIL)
|
||||
runner:new_line("functions.tig", { on_line = 2, text = "parameter: int,", indent = 2 }, "parameter list middle")
|
||||
runner:new_line("functions.tig", { on_line = 4, text = ",parameter: int", indent = 2 }, "parameter list end")
|
||||
runner:new_line("functions.tig", { on_line = 5, text = "var a := 0", indent = 0 }, "after parameter list")
|
||||
runner:new_line("functions.tig", { on_line = 7, text = "print(a)", indent = 2 }, "function body", XFAIL)
|
||||
runner:new_line("functions.tig", { on_line = 9, text = "a,", indent = 6 }, "function call beginning", XFAIL)
|
||||
runner:new_line("functions.tig", { on_line = 10, text = "a,", indent = 6 }, "function call middle")
|
||||
runner:new_line("functions.tig", { on_line = 12, text = ",a", indent = 6 }, "function call end")
|
||||
runner:new_line("functions.tig", { on_line = 13, text = "; print(a)", indent = 4 }, "after function call")
|
||||
runner:new_line("functions.tig", { on_line = 14, text = "var a := 12", indent = 0 }, "after function declaration", XFAIL)
|
||||
|
||||
runner:new_line("groupings.tig", { on_line = 2, text = "var b := 0", indent = 2 }, "let declarations")
|
||||
runner:new_line("groupings.tig", { on_line = 3, text = "a := a + 1", indent = 2 }, "after 'in'", XFAIL)
|
||||
runner:new_line("groupings.tig", { on_line = 4, text = "a := a + 1;", indent = 4 }, "sequence", XFAIL)
|
||||
runner:new_line("groupings.tig", { on_line = 8, text = "a := a + 1;", indent = 2 }, "after sequence")
|
||||
runner:new_line("groupings.tig", { on_line = 10, text = "+ 1", indent = 0 }, "after 'end'")
|
||||
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 4, text = "field: record,", indent = 4 }, "record type beginning", XFAIL)
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 5, text = "field: record,", indent = 4 }, "record type middle")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 7, text = ",field: record", indent = 4 }, "record type end")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 8, text = "var a := 0", indent = 2 }, "after record type")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 10, text = "0", indent = 4 }, "variable declaration init value", XFAIL)
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 11, text = "+ a", indent = 4 }, "variable declaration init follow-up")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 13, text = "a", indent = 4 }, "array index", XFAIL)
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 14, text = "+ a", indent = 4 }, "array index follow-up")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 15, text = "+ a", indent = 2 }, "after array value")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 18, text = "a", indent = 4 }, "array expression size", XFAIL)
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 20, text = "of", indent = 2 }, "array expression after size")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 21, text = "a", indent = 4 }, "array expression init value", XFAIL)
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 25, text = "field = 0,", indent = 4 }, "record expression beginning", XFAIL)
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 26, text = "field = 0,", indent = 4 }, "record expression middle")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 28, text = ",field = 0", indent = 4 }, "record expression end")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 29, text = "a := 0", indent = 2 }, "after record expression")
|
||||
end)
|
||||
end)
|
Loading…
Reference in a new issue