From fa7a4bd2457b6dde8ac434722c279df38a42c173 Mon Sep 17 00:00:00 2001 From: koniifer Date: Fri, 15 Nov 2024 21:20:50 +0000 Subject: [PATCH] update & improve grammar somewhat --- package.json | 5 +- syntaxes/hblang.tmLanguage.json | 121 ++++++++++++++++++-------------- webpack.config.js | 15 ++-- 3 files changed, 77 insertions(+), 64 deletions(-) diff --git a/package.json b/package.json index 6473478..cc4a753 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,15 @@ "publisher": "koniifer", "displayName": "hblang", "description": "Syntax highlighter and formatter for holey-bytes lang", - "version": "0.2.2", + "version": "0.2.3", "engines": { "vscode": "^1.75.0" }, "main": "./out/main.js", "categories": [ "Programming Languages", - "Formatters" + "Formatters", + "Linters" ], "activationEvents": [ "onCommand:extension.formatDocument" diff --git a/syntaxes/hblang.tmLanguage.json b/syntaxes/hblang.tmLanguage.json index b1da256..8b65d8b 100644 --- a/syntaxes/hblang.tmLanguage.json +++ b/syntaxes/hblang.tmLanguage.json @@ -24,23 +24,23 @@ { "include": "#keyword" }, - { - "include": "#function" - }, { "include": "#number" }, { - "include": "#type" + "include": "#punctuation" }, { - "include": "#variable" + "include": "#function" }, { "include": "#operator" }, { - "include": "#punctuation" + "include": "#variable" + }, + { + "include": "#type" }, { "include": "#array" @@ -51,19 +51,31 @@ "patterns": [ { "name": "variable.parameter.hblang", - "match": "\\b\\w+\\b" + "match": "\\b\\w+\\s*:\\s*(?:\\^)?[\\w\\$]+\\b" } ] }, "number": { "patterns": [ { - "name": "constant.numeric.hblang", - "match": "\\b\\d+(\\.\\d+)?\\b" + "name": "constant.numeric.float.hblang", + "match": "\\b\\d+\\.\\d+\\b" }, { "name": "constant.numeric.hex.hblang", "match": "0x[0-9A-Fa-f]+" + }, + { + "name": "constant.numeric.binary.hblang", + "match": "0b[0-1]+" + }, + { + "name": "constant.numeric.octal.hblang", + "match": "0o[0-7]+" + }, + { + "name": "constant.numeric.decimal.hblang", + "match": "\\b\\d+\\b" } ] }, @@ -87,20 +99,10 @@ "name": "string.quoted.double.hblang", "begin": "\"", "end": "\"", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.hblang" - } - }, - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.hblang" - } - }, "patterns": [ { "name": "constant.character.escape.hblang", - "match": "\\\\[\"'\\\\bfnrt]|\\\\(\\{[^}]+\\}|\\[[^]]+\\]|[a-zA-Z])" + "match": "\\\\(?:[\"'\\\\bfnrt]|[{\\[]\\w+[}\\]]|[a-zA-Z])" }, { "name": "invalid.illegal.escaped.hblang", @@ -114,7 +116,7 @@ "patterns": [ { "name": "keyword.control.hblang", - "match": "\\b(loop|break|if|else|return|packed|continue|true|false|struct|idk)\\b" + "match": "\\b(fn|loop|break|if|else|return|packed|continue|true|false|struct|idk|die|null)\\b" } ] }, @@ -122,31 +124,39 @@ "patterns": [ { "name": "storage.type.hblang", - "match": "\\b(uint|int|(u|i)(8|16|32)|void|bool|type|never|([A-Z]\\w+))\\b" + "match": "\\b(f(32|64))|(uint|int|(u|i)(8|16|32)|void|bool|type|never)\\b" } ] }, "variable": { "patterns": [ { - "name": "variable.parameter.hblang", - "match": "\\b\\w+\\s*:=\\b" + "name": "variable.declaration.hblang", + "match": "\\b\\w+\\b(?=\\s*:=)" }, { - "name": "variable.parameter.hblang", - "match": "\\b\\w+\\s*=\\b" + "name": "variable.assignment.hblang", + "match": "\\b\\w+\\b(?=\\s*=(?!=))" }, { - "name": "variable.parameter.hblang", - "match": "(?<=\\w+\\.)(\\w+)\\b" + "name": "variable.member.hblang", + "match": "(?<=\\.)\\w+\\b" } ] }, "operator": { "patterns": [ + { + "name": "keyword.operator.assignment.hblang", + "match": ":=" + }, + { + "name": "keyword.operator.assignment.hblang", + "match": "=(?!=)" + }, { "name": "keyword.operator.hblang", - "match": "(@|:=|<<=|>>=|>=|<=|^=|\\+=|-=|\\*=|\\/=|%=|\\|=|&=|\\^|\\*|&|&&|\\|\\||<<|>>|\\+|\\-|\\/|%|\\||!|==|!=|<|>|=)" + "match": "(\\$|\\?|@|<<=|>>=|>=|<=|\\^=|\\+=|-=|\\*=|\\/=|%=|\\|=|&=|\\^|\\*|&|<<|>>|\\+|\\-|\\/|%|\\||!|==|!=|<|>)" } ] }, @@ -162,36 +172,38 @@ "patterns": [ { "name": "punctuation.terminator.statement.hblang", - "match": ";|\\.|,|:" + "match": ";|\\.|,|(?