From 13a9b4f89b6c117d9f3e1ad34f8f839d38ff795a Mon Sep 17 00:00:00 2001 From: nub31 Date: Thu, 16 Oct 2025 20:24:39 +0200 Subject: [PATCH] maintenance --- compiler/NubLang/Diagnostics/Diagnostic.cs | 2 -- compiler/NubLang/Syntax/Token.cs | 23 ++++++++++++---------- compiler/NubLang/Syntax/Tokenizer.cs | 3 --- examples/raylib/main.nub | 2 ++ vscode/LICENSE | 9 +++++++++ vscode/syntaxes/nub.tmLanguage.json | 12 +++++++---- 6 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 vscode/LICENSE diff --git a/compiler/NubLang/Diagnostics/Diagnostic.cs b/compiler/NubLang/Diagnostics/Diagnostic.cs index 0135bf5..43c8cdb 100644 --- a/compiler/NubLang/Diagnostics/Diagnostic.cs +++ b/compiler/NubLang/Diagnostics/Diagnostic.cs @@ -277,8 +277,6 @@ public class Diagnostic case Symbol.Continue: case Symbol.Struct: case Symbol.Let: - case Symbol.Calls: - case Symbol.For: case Symbol.Extern: { return ConsoleColors.Colorize(tokenText, ConsoleColors.Bold + ConsoleColors.Blue); diff --git a/compiler/NubLang/Syntax/Token.cs b/compiler/NubLang/Syntax/Token.cs index b1842d8..aa7aaa4 100644 --- a/compiler/NubLang/Syntax/Token.cs +++ b/compiler/NubLang/Syntax/Token.cs @@ -4,13 +4,24 @@ namespace NubLang.Syntax; public enum Symbol { - Func, - Return, + // Control If, Else, While, Break, Continue, + Return, + Let, + Defer, + + // Declaration + Func, + Struct, + + // Modifier + Extern, + Export, + Colon, DoubleColon, OpenParen, @@ -33,14 +44,8 @@ public enum Symbol Minus, Star, ForwardSlash, - Struct, Caret, Ampersand, - Let, - Calls, - For, - In, - Extern, Semi, Percent, LeftShift, @@ -50,8 +55,6 @@ public enum Symbol Or, Module, Import, - Export, - Defer, At, } diff --git a/compiler/NubLang/Syntax/Tokenizer.cs b/compiler/NubLang/Syntax/Tokenizer.cs index 7760cfc..2391e3a 100644 --- a/compiler/NubLang/Syntax/Tokenizer.cs +++ b/compiler/NubLang/Syntax/Tokenizer.cs @@ -15,9 +15,6 @@ public sealed class Tokenizer ["return"] = Symbol.Return, ["struct"] = Symbol.Struct, ["let"] = Symbol.Let, - ["calls"] = Symbol.Calls, - ["for"] = Symbol.For, - ["in"] = Symbol.In, ["extern"] = Symbol.Extern, ["module"] = Symbol.Module, ["export"] = Symbol.Export, diff --git a/examples/raylib/main.nub b/examples/raylib/main.nub index 90710f8..e55de47 100644 --- a/examples/raylib/main.nub +++ b/examples/raylib/main.nub @@ -22,6 +22,8 @@ extern "main" func main(args: []cstring): i64 while !raylib::WindowShouldClose() { + defer puts("test") + if x <= 0 { direction.x = 1 diff --git a/vscode/LICENSE b/vscode/LICENSE new file mode 100644 index 0000000..f59480d --- /dev/null +++ b/vscode/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025 nub31 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vscode/syntaxes/nub.tmLanguage.json b/vscode/syntaxes/nub.tmLanguage.json index 4a4780c..ad335f6 100644 --- a/vscode/syntaxes/nub.tmLanguage.json +++ b/vscode/syntaxes/nub.tmLanguage.json @@ -56,11 +56,11 @@ "patterns": [ { "name": "keyword.control.nub", - "match": "\\b(if|else|while|break|continue|return|let)\\b" + "match": "\\b(if|else|while|break|continue|return|let|defer)\\b" }, { "name": "keyword.other.nub", - "match": "\\b(namespace|func|struct|interface)\\b" + "match": "\\b(func|struct|module|import)\\b" } ] }, @@ -68,7 +68,7 @@ "patterns": [ { "name": "storage.modifier.nub", - "match": "\\b(export|extern|calls)\\b" + "match": "\\b(export|extern)\\b" } ] }, @@ -212,13 +212,17 @@ { "name": "keyword.operator.member-access.nub", "match": "\\." + }, + { + "name": "keyword.operator.module-access.nub", + "match": "::" } ] }, "function-definition": { "patterns": [ { - "begin": "\\b(global\\s+|extern\\s+)?(func)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(", + "begin": "\\b(export\\s+|extern\\s+)?(func)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(", "beginCaptures": { "1": { "name": "storage.modifier.nub"