diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index d8c28941..707c46e9 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -8,6 +8,7 @@ | astro | ✓ | | | | | `astro-ls` | | awk | ✓ | ✓ | | | | `awk-language-server` | | bash | ✓ | ✓ | ✓ | ✓ | ✓ | `bash-language-server` | +| basic | ✓ | ✓ | ✓ | ✓ | | | | bass | ✓ | | | | | `bass` | | beancount | ✓ | | | | | `beancount-language-server` | | bibtex | ✓ | | | | | `texlab` | @@ -75,6 +76,7 @@ | flatbuffers | ✓ | | | | | | | forth | ✓ | | | | | `forth-lsp` | | fortran | ✓ | | ✓ | | | `fortls` | +| freebasic | ✓ | ✓ | ✓ | ✓ | | | | fsharp | ✓ | | | | | `fsautocomplete` | | gas | ✓ | ✓ | | | | `asm-lsp` | | gdscript | ✓ | ✓ | ✓ | ✓ | | | diff --git a/languages.toml b/languages.toml index 58b1e813..812fb1d8 100644 --- a/languages.toml +++ b/languages.toml @@ -5010,3 +5010,27 @@ persistent-diagnostic-sources = ["haxe"] [[grammar]] name = "haxe" source = { git = "https://github.com/vantreeseba/tree-sitter-haxe", rev = "a55f3e2cf1e4449200fd089a80d3af642bcf5f94" } + +[[language]] +name = "basic" +scope = "source.basic" +injection-regex = "basic" +file-types = ["bas"] +comment-token = "REM" +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "basic" +source = { git = "https://github.com/Ra77a3l3-jar/tree-sitter-basic", rev = "a98449c11d6c688b54c1ca132148a62d7e586a2a" } + +[[language]] +name = "freebasic" +scope = "source.freebasic" +injection-regex = "freebasic" +file-types = ["bas", "bi"] +comment-tokens = ["'", "REM"] +indent = { tab-width = 4, unit = " " } + +[[grammar]] +name = "freebasic" +source = { git = "https://github.com/Ra77a3l3-jar/tree-sitter-freebasic", rev = "dbf696adb4c0b9c020074e75043c90592981ee7f" } diff --git a/runtime/queries/basic/highlights.scm b/runtime/queries/basic/highlights.scm new file mode 100644 index 00000000..49a75c7f --- /dev/null +++ b/runtime/queries/basic/highlights.scm @@ -0,0 +1,72 @@ +; Keywords +[ + "PRINT" + "LET" + "IF" + "THEN" + "GOTO" + "GOSUB" + "RETURN" + "FOR" + "TO" + "STEP" + "NEXT" + "INPUT" + "END" + "REM" + "DATA" + "READ" + "DIM" +] @keyword + +; Logical operators +[ + "AND" + "and" + "OR" + "or" + "NOT" +] @keyword.operator + +; Comments +(comment) @comment +(rem_statement) @comment + +; Function calls +(function_call) @function.call + +; Numbers +(line_number) @constant.numeric +(number) @constant.numeric + +; Strings +(string) @string + +; Operators +[ + "=" + "<>" + "<" + ">" + "<=" + ">=" + "+" + "-" + "*" + "/" + "^" +] @operator + +; Punctuation +[ + "(" + ")" +] @punctuation.bracket + +[ + "," + ";" +] @punctuation.delimiter + +; Variables +(identifier) @variable diff --git a/runtime/queries/basic/indents.scm b/runtime/queries/basic/indents.scm new file mode 100644 index 00000000..86f9eb13 --- /dev/null +++ b/runtime/queries/basic/indents.scm @@ -0,0 +1,7 @@ +[ + (for_statement) +] @indent + +[ + "NEXT" +] @outdent diff --git a/runtime/queries/basic/tags.scm b/runtime/queries/basic/tags.scm new file mode 100644 index 00000000..7971a8d5 --- /dev/null +++ b/runtime/queries/basic/tags.scm @@ -0,0 +1,5 @@ +(for_statement + variable: (identifier) @definition.variable) + +(let_statement + variable: (identifier) @definition.variable) diff --git a/runtime/queries/basic/textobjects.scm b/runtime/queries/basic/textobjects.scm new file mode 100644 index 00000000..b613273f --- /dev/null +++ b/runtime/queries/basic/textobjects.scm @@ -0,0 +1,4 @@ +(for_statement) @function.around + +(comment) @comment.inside +(comment)+ @comment.around diff --git a/runtime/queries/freebasic/highlights.scm b/runtime/queries/freebasic/highlights.scm new file mode 100644 index 00000000..5a4991cf --- /dev/null +++ b/runtime/queries/freebasic/highlights.scm @@ -0,0 +1,96 @@ +; Keywords +[ + "DIM" + "IF" + "THEN" + "ELSE" + "END IF" + "WHILE" + "WEND" + "FOR" + "TO" + "STEP" + "NEXT" + "DO" + "LOOP" + "UNTIL" + "SUB" + "END SUB" + "FUNCTION" + "END FUNCTION" + "RETURN" + "PRINT" + "INPUT" + "SLEEP" + "AS" +] @keyword + +; Logical operators +[ + "AND" + "OR" + "NOT" + "MOD" +] @keyword.operator + +; Types +[ + "INTEGER" + "LONG" + "SINGLE" + "DOUBLE" + "STRING" + "BYTE" +] @type + +(type_identifier) @type + +; Function and sub declarations +(sub_declaration + name: (identifier) @function) +(function_declaration + name: (identifier) @function) + +; Function calls +(call_expression + function: (identifier) @function.call) + +; Built-in functions +((identifier) @function.builtin + (#match? @function.builtin "^(?i)(ABS|SIN|COS|TAN|SQR|LEN|VAL|ASC|CHR|LEFT|RIGHT|MID|STR|INT|RND|INSTR|UCASE|LCASE|LTRIM|RTRIM|SPACE|TIME|DATE|TIMER)$")) + +; Literals +(number_literal) @constant.numeric +(string_literal) @string + +; Comments +(comment) @comment + +; Operators +[ + "=" + "+" + "-" + "*" + "/" + "^" + "<>" + "<" + ">" + "<=" + ">=" +] @operator + +; Punctuation +[ + "(" + ")" +] @punctuation.bracket + +[ + "," + ";" +] @punctuation.delimiter + +; Variables +(identifier) @variable diff --git a/runtime/queries/freebasic/indents.scm b/runtime/queries/freebasic/indents.scm new file mode 100644 index 00000000..d7637b93 --- /dev/null +++ b/runtime/queries/freebasic/indents.scm @@ -0,0 +1,17 @@ +[ + (for_statement) + (if_statement) + (while_statement) + (do_statement) + (function_declaration) + (sub_declaration) +] @indent + +[ + "NEXT" + "END IF" + "WEND" + "LOOP" + "END FUNCTION" + "END SUB" +] @outdent diff --git a/runtime/queries/freebasic/tags.scm b/runtime/queries/freebasic/tags.scm new file mode 100644 index 00000000..36535794 --- /dev/null +++ b/runtime/queries/freebasic/tags.scm @@ -0,0 +1,3 @@ +(sub_declaration name: (identifier) @definition.function) + +(function_declaration name: (identifier) @definition.function) diff --git a/runtime/queries/freebasic/textobjects.scm b/runtime/queries/freebasic/textobjects.scm new file mode 100644 index 00000000..149e36d8 --- /dev/null +++ b/runtime/queries/freebasic/textobjects.scm @@ -0,0 +1,8 @@ +(function_declaration) @function.around + +(sub_declaration) @function.around + +(for_statement) @function.around + +(comment) @comment.inside +(comment)+ @comment.around