From 504cf5f549855729d9d07c1994de455e90646ee8 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Wed, 13 Mar 2024 17:13:58 +0100 Subject: [PATCH 01/55] Added pattern for java constants. --- plugins/language_java.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 30c12491..b44b0c51 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -10,15 +10,16 @@ syntax.add { { pattern = { "/%*", "%*/" }, type = "comment" }, { pattern = { '"', '"', '\\' }, type = "string" }, { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal { pattern = "-?0x%x+", type = "number" }, { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, { pattern = "-?%.?%d+f?", type = "number" }, { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = "[%a_][%w_]*", type = "symbol" }, + { regex = "[A-Z]+_?[A-Z]+", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" } }, symbols = { ["abstract"] = "keyword", From 948d5f18d0a6cd93fae096ee0b794d53b2697277 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Thu, 14 Mar 2024 00:45:31 +0100 Subject: [PATCH 02/55] Added regex pattern for java constants in language_java. --- plugins/language_java.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index b44b0c51..f95efa46 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -20,6 +20,7 @@ syntax.add { { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { regex = "[A-Z]+_?[A-Z]+", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" } + --{ regex = "(?<=\s)([A-Z]+[a-z]+)+(?=\s[a-z])", type = "function" }, -- Class name in instance (WIP: Lite XL needs to add support for look-behind) }, symbols = { ["abstract"] = "keyword", From 25cf77f4b65ac42df6c9bc1ef4e48fd4314c840b Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 13 Apr 2024 13:46:42 +0200 Subject: [PATCH 03/55] Updated constants pattern. --- plugins/language_java.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index f95efa46..2092f379 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -18,9 +18,9 @@ syntax.add { { pattern = "-?%.?%d+f?", type = "number" }, { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "[A-Z]+_?[A-Z]+", type = "keyword2" }, -- Constants + { regex = "[A-Z][A-Z_]*", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" } - --{ regex = "(?<=\s)([A-Z]+[a-z]+)+(?=\s[a-z])", type = "function" }, -- Class name in instance (WIP: Lite XL needs to add support for look-behind) + --{ regex = "(?<=\s)([A-Z]+[a-z]+)+(?=\s[a-z])", type = "function" }, -- Class name in class instance }, symbols = { ["abstract"] = "keyword", From aba7f5a2ac2d1b329f23dabfe2989fa153649c7b Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sun, 21 Apr 2024 20:14:17 +0200 Subject: [PATCH 04/55] Fixed class name pattern and tidied up some things. --- plugins/language_java.lua | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 2092f379..116e3480 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,21 +6,21 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.-\n", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "[A-Z][A-Z_]*", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" } - --{ regex = "(?<=\s)([A-Z]+[a-z]+)+(?=\s[a-z])", type = "function" }, -- Class name in class instance + { pattern = "//.-\n", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "[A-Za-z]+(?=\\s[a-z0-9]+\\s\\=\\s[new])", type = "function" }, -- Class name in class instance + { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { ["abstract"] = "keyword", @@ -82,6 +82,6 @@ syntax.add { ["true"] = "literal", ["false"] = "literal", - ["null"] = "literal", - }, + ["null"] = "literal" + } } From 82eaff205304a98d865285c9e44837f5ffd54a89 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Mon, 22 Apr 2024 19:03:09 +0200 Subject: [PATCH 05/55] Fixed redundant pattern. --- plugins/language_java.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 116e3480..032b6022 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,21 +6,21 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.-\n", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "[A-Za-z]+(?=\\s[a-z0-9]+\\s\\=\\s[new])", type = "function" }, -- Class name in class instance - { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.-\n", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "[A-Za-z]+(?=\\s[a-z0-9]+\\s\\=\\s)", type = "function" }, -- Class name in class instance + { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { ["abstract"] = "keyword", From f5a9f1431db4e57fc040b2b217583a8b6e9141e8 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Mon, 22 Apr 2024 19:06:01 +0200 Subject: [PATCH 06/55] Updated single-line comment pattern. --- plugins/language_java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 032b6022..46e277f1 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,7 +6,7 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.-\n", type = "comment" }, + { pattern = "//.*", type = "comment" }, { pattern = { "/%*", "%*/" }, type = "comment" }, { pattern = { '"', '"', '\\' }, type = "string" }, { pattern = { "'", "'", '\\' }, type = "string" }, From df0df4b1a655a1247bbe3fd1c459059d98e21f18 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Mon, 22 Apr 2024 22:43:01 +0200 Subject: [PATCH 07/55] Bumped language_java version. --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 334a2525..c4df8a0b 100644 --- a/manifest.json +++ b/manifest.json @@ -921,7 +921,7 @@ }, { "description": "Syntax for the [Java](https://en.wikipedia.org/wiki/Java_\\(programming_language\\)) programming language", - "version": "0.1", + "version": "0.1.1", "path": "plugins/language_java.lua", "id": "language_java", "mod_version": "3", From 58034d8edabb20eacf2ddb19932f11986e0da64d Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Mon, 22 Apr 2024 23:22:41 +0200 Subject: [PATCH 08/55] Updated some patterns. --- plugins/language_java.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 46e277f1..eca82a12 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,21 +6,21 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "[A-Za-z]+(?=\\s[a-z0-9]+\\s\\=\\s)", type = "function" }, -- Class name in class instance - { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "\\w+(?=\\s+\\w++\\s+\\=\\s+)", type = "function" }, -- Class name in class instance + { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { ["abstract"] = "keyword", From aa8ad17f7f5fb403af91d3b54b5daef937b9de51 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 11 May 2024 17:17:32 +0200 Subject: [PATCH 09/55] Updated class name for object instance syntax. --- plugins/language_java.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index eca82a12..e4340952 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,21 +6,21 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "\\w+(?=\\s+\\w++\\s+\\=\\s+)", type = "function" }, -- Class name in class instance - { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "(?:\\w+\\.?)+(?=\\s+\\w++\\s+\\=\\s+)", type = "function" }, -- Class name in class instance + { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { ["abstract"] = "keyword", From 8f424a31636434fb4eabb670db17801ac7b7ae45 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 20 Jul 2024 01:01:19 +0200 Subject: [PATCH 10/55] Removed limit on number of spaces before/after the = . --- plugins/language_java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index e4340952..b7d7ce75 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -18,7 +18,7 @@ syntax.add { { pattern = "-?%.?%d+f?", type = "number" }, { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "(?:\\w+\\.?)+(?=\\s+\\w++\\s+\\=\\s+)", type = "function" }, -- Class name in class instance + { regex = "(?:\\w+\\.?)+(?=\\s+\\w++\\s+?\\=\\s+?)", type = "function" }, -- Class name when creating an object { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, }, From 0bba1173d764a3829a80ea75442a01b2ff6f8d3e Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 20 Jul 2024 01:12:00 +0200 Subject: [PATCH 11/55] Fixed previous commit. --- plugins/language_java.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index b7d7ce75..9fc5b7d1 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,21 +6,21 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "(?:\\w+\\.?)+(?=\\s+\\w++\\s+?\\=\\s+?)", type = "function" }, -- Class name when creating an object - { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "(?:\\w+\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object + { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { ["abstract"] = "keyword", From b3791aadd6ce02caa2c037b11615d65c23401ea5 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 10 Aug 2024 09:06:45 +0200 Subject: [PATCH 12/55] WIP: fixing constants pattern. --- plugins/language_java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index d49472f9..927b0d62 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -19,7 +19,7 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { regex = "(?:\\w++\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object - { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants + { regex = "[A-Z][A-Z_]+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=])", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { From f4d18dd0ce7723cb7ca27f0951257ad11bc4b9a3 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Tue, 22 Oct 2024 08:23:00 +0200 Subject: [PATCH 13/55] Updated pattern. --- plugins/language_java.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 927b0d62..eab8f446 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,21 +6,21 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "(?:\\w++\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object - { regex = "[A-Z][A-Z_]+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=])", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "(?:\\w++\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object + { regex = "[A-Z][A-Z_]+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=]|[\\.])", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { ["abstract"] = "keyword", From 1a7e1bec4dfe9581ac7fb81e7152f1ea5d8d8114 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Tue, 22 Oct 2024 08:30:12 +0200 Subject: [PATCH 14/55] Updated constants pattern. --- plugins/language_java.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index eab8f446..c3abb4be 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,21 +6,21 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "(?:\\w++\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object - { regex = "[A-Z][A-Z_]+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=]|[\\.])", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "(?:\\w++\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object + { regex = "[A-Z][A-Z_\\d?]+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=]|[\\.])", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { ["abstract"] = "keyword", From d207d8adb88f273f712e22a2ce88b1d933d54735 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sun, 27 Oct 2024 13:08:24 +0100 Subject: [PATCH 15/55] Fixed REDOs vulnerability for class pattern. --- plugins/language_java.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index c3abb4be..6375be96 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -19,8 +19,8 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { regex = "(?:\\w++\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object - { regex = "[A-Z][A-Z_\\d?]+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=]|[\\.])", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, + { regex = "[A-Z](?:A-Z_\\d?)+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=]|[\\.])", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" } }, symbols = { ["abstract"] = "keyword", From 322983c7bcfb6c87f3e5cb9f3678df0267680df8 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sun, 27 Oct 2024 17:48:15 +0100 Subject: [PATCH 16/55] version bump. --- manifest.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/manifest.json b/manifest.json index 668f8c93..46cfb91a 100644 --- a/manifest.json +++ b/manifest.json @@ -1149,11 +1149,7 @@ "tags": [ "language" ], -<<<<<<< HEAD - "version": "0.1.2" -======= - "version": "0.1.1" ->>>>>>> 0bba1173d764a3829a80ea75442a01b2ff6f8d3e + "version": "0.1.3" }, { "description": "Syntax for the [jiyu](https://github.com/machinamentum/jiyu) programming language", From 5c2820256fa9c0b7494e17a4608d3ad496934c0c Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Fri, 29 Nov 2024 20:49:35 +0100 Subject: [PATCH 17/55] Fixed constants pattern (for real this time). --- plugins/language_java.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index d842e390..0ce95cd3 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,21 +6,21 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "(?>\\w+\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object - { regex = "[A-Z](?:A-Z_\\d?)+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=]|[\\.])", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "(?>\\w+\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object + { regex = "[A-Z](?:[A-Z_][\\d]*)+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=]|[\\.])", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, -- TODO: annotation syntax -- FIX: constant pattern matches also inside the import statements }, From fa37fd8a474ae1296d257960b96e89739b52d87c Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Fri, 29 Nov 2024 20:50:10 +0100 Subject: [PATCH 18/55] Removed some comments. --- plugins/language_java.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 0ce95cd3..f7246f89 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -21,8 +21,6 @@ syntax.add { { regex = "(?>\\w+\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object { regex = "[A-Z](?:[A-Z_][\\d]*)+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=]|[\\.])", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, - -- TODO: annotation syntax - -- FIX: constant pattern matches also inside the import statements }, symbols = { ["abstract"] = "keyword", From 73f2677b16d237963502737528fac0caecc3e000 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 30 Nov 2024 12:35:36 +0100 Subject: [PATCH 19/55] Updated Groovy syntax. --- plugins/language_groovy.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/language_groovy.lua b/plugins/language_groovy.lua index 2886e106..507e5f70 100644 --- a/plugins/language_groovy.lua +++ b/plugins/language_groovy.lua @@ -1,15 +1,18 @@ -- mod-version:3 local syntax = require "core.syntax" +-- Language Syntax References +-- https://groovy-lang.org/syntax.html + syntax.add { name = "Groovy", - files = { "%.groovy$" }, + files = { "%.groovy$", "%.gvy$", "%.gy$", "%.gsh$" }, comment = "//", block_comment = { "/*", "*/" }, patterns = { { pattern = "//.*", type = "comment" }, -- Single-line comment { pattern = { "/%*", "%*/" }, type = "comment" }, -- Multi-line comment - { pattern = { '"', '"', '\\' }, type = "string" }, -- String, double quotes + { pattern = { '"', '"', '\\' }, type = "string" }, -- String, double quotes (also matches triple quotes for multi-line string) { pattern = { "'", "'", '\\' }, type = "string" }, -- String, apices { pattern = { "%/", "%/", '\\' }, type = "string" }, -- Slashy string { pattern = { "%$%/", "%/%$", '\\' }, type = "string" }, -- Dollar slashy string @@ -23,11 +26,10 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operators { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Function/Class/Method/... { pattern = "[%a_][%w_]*%f[%[]", type = "function" }, -- Custom Type - { regex = "[A-Z]+_?[A-Z]+", type = "keyword2" }, -- Constants + { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? - { pattern = "[a-zA-Z]+%.+", type = "function" }, -- Lib path - -- TODO: .class. + -- TODO: .class }, symbols = { -- Reserved keywords From ef8cb19a111c6a403fb32887da7d233bd4276ee0 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 30 Nov 2024 12:36:41 +0100 Subject: [PATCH 20/55] Updated Kotlin syntax. --- plugins/language_kotlin.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index c3d6b4f6..776de58b 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -1,9 +1,13 @@ -- mod-version:3 local syntax = require "core.syntax" +-- Language Syntax References +-- https://kotlinlang.org/docs/basic-syntax.html +-- https://kotlinlang.org/docs/keyword-reference.html + syntax.add { name = "Kotlin", - files = { "%.kt$" }, + files = { "%.kts?$", "%.klib$" }, comment = "//", block_comment = { "/*", "*/" }, patterns = { @@ -26,10 +30,10 @@ syntax.add { { regex = [[let(?=\s\{)]], type = "function" }, -- ? operator { regex = [[\?\:(?=\s?)]], type = "operator" }, -- elvis operator { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - { regex = "\\@\\w+", type = "keyword2" }, -- Annotations + { regex = "\\@.+", type = "keyword2" }, -- Annotations { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) - { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants, FULL UPPERCASE { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, + { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? }, symbols = { From e9e0f952e0c84bb332873e41a12a103808e557b5 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 30 Nov 2024 12:39:31 +0100 Subject: [PATCH 21/55] WIP: updating Java syntax. --- manifest.json | 12 ++++++------ plugins/language_java.lua | 39 ++++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/manifest.json b/manifest.json index 900e5674..6afa56be 100644 --- a/manifest.json +++ b/manifest.json @@ -1063,14 +1063,14 @@ "version": "0.1" }, { - "description": "Syntax for the [Groovy](https://en.wikipedia.org/wiki/Apache_Groovy) programming language", + "description": "Syntax for the [Groovy](https://en.wikipedia.org/wiki/Apache_Groovy) programming language.", "id": "language_groovy", "mod_version": "3", "path": "plugins/language_groovy.lua", "tags": [ "language" ], - "version": "0.2" + "version": "0.3" }, { "description": "Syntax for the [Hare](https://harelang.org) programming language", @@ -1143,14 +1143,14 @@ "version": "0.1" }, { - "description": "Syntax for the [Java](https://en.wikipedia.org/wiki/Java_\\(programming_language\\)) programming language", + "description": "Syntax for the [Java](https://en.wikipedia.org/wiki/Java_\\(programming_language\\)) programming language.", "id": "language_java", "mod_version": "3", "path": "plugins/language_java.lua", "tags": [ "language" ], - "version": "0.1.3" + "version": "0.1.4" }, { "description": "Syntax for the [jiyu](https://github.com/machinamentum/jiyu) programming language", @@ -1203,14 +1203,14 @@ "version": "0.1" }, { - "description": "Syntax for the [Kotlin](https://kotlinlang.org/docs/home.html) programming language", + "description": "Syntax for the [Kotlin](https://kotlinlang.org/docs/home.html) programming language.", "id": "language_kotlin", "mod_version": "3", "path": "plugins/language_kotlin.lua", "tags": [ "language" ], - "version": "0.2" + "version": "0.3" }, { "checksum": "08a9f8635b09a98cec9dfca8bb65f24fd7b6585c7e8308773e7ddff9a3e5a60f", diff --git a/plugins/language_java.lua b/plugins/language_java.lua index f7246f89..83e4e176 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -1,26 +1,35 @@ -- mod-version:3 local syntax = require "core.syntax" +-- Language Syntax References +-- https://docs.oracle.com/javase/specs/jls/se8/html/index.html + syntax.add { name = "Java", files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "(?>\\w+\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object - { regex = "[A-Z](?:[A-Z_][\\d]*)+(?=\\s*[)]|[\\;]|[\\,]|[\\s\\=]|[\\.])", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "(?>\\w+\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object + { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword + { regex = "^\\@.+", type = "keyword2" }, -- Annotations + { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) + { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, + { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, + -- TODO: generic class instance pattern + -- FIX: class instance pattern like "ForgeConfigSpec.IntValue" }, symbols = { ["abstract"] = "keyword", From 545a6ae21037efaccf222e98fcc89110e128686b Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 30 Nov 2024 22:31:06 +0100 Subject: [PATCH 22/55] WIP: updating/fixing patterns. --- plugins/language_java.lua | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 83e4e176..f7cccbf9 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -9,27 +9,27 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { regex = "(?>\\w+\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object - { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - { regex = "^\\@.+", type = "keyword2" }, -- Annotations - { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) - { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, - { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, - -- TODO: generic class instance pattern - -- FIX: class instance pattern like "ForgeConfigSpec.IntValue" + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "(?>\\w+\\.?)+\\<.+?\\>(?=\\s+\\w+\\s*)?", type = "function" }, -- Generic class name reference + { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)", type = "function" }, -- Class name reference + { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)?(?=\\s*\\{)", type = "function" }, -- Class name + { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword + { regex = "^\\s*\\@.+", type = "keyword2" }, -- Annotations + { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import + { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, + -- TODO: method reference operator (https://www.geeksforgeeks.org/double-colon-operator-in-java/) }, symbols = { ["abstract"] = "keyword", From fdede88c60acc47fc230c2e4d4668becec9c9721 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sun, 1 Dec 2024 11:03:52 +0100 Subject: [PATCH 23/55] Fixed constants pattern interference in import statements. --- plugins/language_java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index f7cccbf9..9bbe1917 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -21,12 +21,12 @@ syntax.add { { pattern = "-?%.?%d+f?", type = "number" }, { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import { regex = "(?>\\w+\\.?)+\\<.+?\\>(?=\\s+\\w+\\s*)?", type = "function" }, -- Generic class name reference { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)", type = "function" }, -- Class name reference { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)?(?=\\s*\\{)", type = "function" }, -- Class name { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { regex = "^\\s*\\@.+", type = "keyword2" }, -- Annotations - { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, -- TODO: method reference operator (https://www.geeksforgeeks.org/double-colon-operator-in-java/) From 92d91a481ffef75e3a7cc362758eb81db046adc8 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Tue, 3 Dec 2024 09:47:59 +0100 Subject: [PATCH 24/55] Added method reference pattern and WIP: fixing patterns. --- plugins/language_java.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 9bbe1917..88b78702 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -28,8 +28,9 @@ syntax.add { { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { regex = "^\\s*\\@.+", type = "keyword2" }, -- Annotations { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants + { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "[%a_][%w_]*", type = "symbol" }, - -- TODO: method reference operator (https://www.geeksforgeeks.org/double-colon-operator-in-java/) + -- TODO: check all regex patterns for REDOs vulnerability }, symbols = { ["abstract"] = "keyword", From 4746bd1bf73dee7eaf27b883b5caf5208c7c6de5 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 14 Dec 2024 13:39:20 +0100 Subject: [PATCH 25/55] Replaced regex pattern with lua pattern and other things. --- plugins/language_java.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 88b78702..b226b6a7 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -26,11 +26,10 @@ syntax.add { { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)", type = "function" }, -- Class name reference { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)?(?=\\s*\\{)", type = "function" }, -- Class name { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - { regex = "^\\s*\\@.+", type = "keyword2" }, -- Annotations + { pattern = "^%s*%@.+", type = "keyword2" }, -- Annotations { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "[%a_][%w_]*", type = "symbol" }, - -- TODO: check all regex patterns for REDOs vulnerability }, symbols = { ["abstract"] = "keyword", From 6a51acbed0a34c46fbc15f633619f4b4a264c59e Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 14 Dec 2024 13:48:15 +0100 Subject: [PATCH 26/55] Updated basic annotations pattern. --- plugins/language_kotlin.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index 776de58b..acf22694 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -30,7 +30,7 @@ syntax.add { { regex = [[let(?=\s\{)]], type = "function" }, -- ? operator { regex = [[\?\:(?=\s?)]], type = "operator" }, -- elvis operator { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - { regex = "\\@.+", type = "keyword2" }, -- Annotations + { pattern = "^%s*%@.+", type = "keyword2" }, -- Annotations { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants From 861443fa030ae682b694115bd60197595c796b60 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 14 Dec 2024 14:03:00 +0100 Subject: [PATCH 27/55] Fixed redundant % from a few lua patterns. --- plugins/language_java.lua | 2 +- plugins/language_kotlin.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index b226b6a7..ffff4c13 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -26,7 +26,7 @@ syntax.add { { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)", type = "function" }, -- Class name reference { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)?(?=\\s*\\{)", type = "function" }, -- Class name { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - { pattern = "^%s*%@.+", type = "keyword2" }, -- Annotations + { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "[%a_][%w_]*", type = "symbol" }, diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index acf22694..591b9270 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -30,7 +30,7 @@ syntax.add { { regex = [[let(?=\s\{)]], type = "function" }, -- ? operator { regex = [[\?\:(?=\s?)]], type = "operator" }, -- elvis operator { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - { pattern = "^%s*%@.+", type = "keyword2" }, -- Annotations + { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants From 37ac183730eeb3af2d070e7c10620c0358889d0a Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Mon, 23 Dec 2024 09:55:58 +0100 Subject: [PATCH 28/55] WIP: fixing constants pattern --- plugins/language_java.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index ffff4c13..708b3dc6 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -27,6 +27,7 @@ syntax.add { { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)?(?=\\s*\\{)", type = "function" }, -- Class name { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations + -- FIX: IEvent, IE should not be matched { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "[%a_][%w_]*", type = "symbol" }, From 34f1b50d53fb9c8367d5f6d77f05ec168e2a4562 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sun, 29 Dec 2024 15:19:46 +0100 Subject: [PATCH 29/55] Fixed constants and generic class name reference patterns. --- plugins/language_java.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 708b3dc6..c9001a5d 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -22,13 +22,12 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - { regex = "(?>\\w+\\.?)+\\<.+?\\>(?=\\s+\\w+\\s*)?", type = "function" }, -- Generic class name reference + { regex = "(?>\\w+\\.?)+\\<.+?\\>\\>*(?=\\s+\\w+\\s*)?", type = "function" }, -- Generic class name reference (?>\w+\.?)+\<.+?\>\>*(?=\s+\w+\s*)? { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)", type = "function" }, -- Class name reference { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)?(?=\\s*\\{)", type = "function" }, -- Class name { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations - -- FIX: IEvent, IE should not be matched - { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants + { regex = "[A-Z](?:[A-Z_][\\d]*)+(?!\\w)", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "[%a_][%w_]*", type = "symbol" }, }, From 44ddc325a107bdf3e05302f653852e4322d4cd44 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Fri, 3 Jan 2025 16:25:52 +0100 Subject: [PATCH 30/55] Fixed class name pattern. --- plugins/language_java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index c9001a5d..8173c9ba 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -24,7 +24,7 @@ syntax.add { { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import { regex = "(?>\\w+\\.?)+\\<.+?\\>\\>*(?=\\s+\\w+\\s*)?", type = "function" }, -- Generic class name reference (?>\w+\.?)+\<.+?\>\>*(?=\s+\w+\s*)? { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)", type = "function" }, -- Class name reference - { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)?(?=\\s*\\{)", type = "function" }, -- Class name + { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)?(?=\\s*\\{|\\,)", type = "function" }, -- Class name { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { regex = "[A-Z](?:[A-Z_][\\d]*)+(?!\\w)", type = "keyword2" }, -- Constants From 717f927d61ddf0b13c3c001343b1c2e3c3b35372 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sun, 5 Jan 2025 11:16:11 +0100 Subject: [PATCH 31/55] Updated constants patterns for groovy and kotlin. --- plugins/language_groovy.lua | 2 +- plugins/language_kotlin.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/language_groovy.lua b/plugins/language_groovy.lua index 507e5f70..b227c5dd 100644 --- a/plugins/language_groovy.lua +++ b/plugins/language_groovy.lua @@ -26,7 +26,7 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operators { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Function/Class/Method/... { pattern = "[%a_][%w_]*%f[%[]", type = "function" }, -- Custom Type - { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants + { regex = "[A-Z](?:[A-Z_][\\d]*)+(?!\\w)", type = "keyword2" }, -- Constants { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? -- TODO: .class diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index 591b9270..d161953f 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -33,7 +33,7 @@ syntax.add { { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, - { regex = "[A-Z](?:[A-Z_][\\d]*)+", type = "keyword2" }, -- Constants + { regex = "[A-Z](?:[A-Z_][\\d]*)+(?!\\w)", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? }, symbols = { From 6e4209a0d2fad29f105b7dd50a5c3bd831bc7c57 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Tue, 7 Jan 2025 21:18:22 +0100 Subject: [PATCH 32/55] WIP: Tidying some things up and fixing class name reference patterns for Java and constants pattern for Java and Kotlin. --- plugins/language_groovy.lua | 38 ++++++++++++++++++------------------- plugins/language_java.lua | 11 ++++++----- plugins/language_kotlin.lua | 7 ++++--- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/plugins/language_groovy.lua b/plugins/language_groovy.lua index b227c5dd..e07d79c3 100644 --- a/plugins/language_groovy.lua +++ b/plugins/language_groovy.lua @@ -10,25 +10,25 @@ syntax.add { comment = "//", block_comment = { "/*", "*/" }, patterns = { - { pattern = "//.*", type = "comment" }, -- Single-line comment - { pattern = { "/%*", "%*/" }, type = "comment" }, -- Multi-line comment - { pattern = { '"', '"', '\\' }, type = "string" }, -- String, double quotes (also matches triple quotes for multi-line string) - { pattern = { "'", "'", '\\' }, type = "string" }, -- String, apices - { pattern = { "%/", "%/", '\\' }, type = "string" }, -- Slashy string - { pattern = { "%$%/", "%/%$", '\\' }, type = "string" }, -- Dollar slashy string - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, -- ? - { pattern = "-?%d+[%d%.eE]*[a-zA-Z]?", type = "number" }, -- ? - { pattern = "-?%.?%d+", type = "number" }, -- ? - { pattern = "-?[%d_+]+[a-zA-Z]?", type = "number" }, -- ? - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operators - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Function/Class/Method/... - { pattern = "[%a_][%w_]*%f[%[]", type = "function" }, -- Custom Type - { regex = "[A-Z](?:[A-Z_][\\d]*)+(?!\\w)", type = "keyword2" }, -- Constants - { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, - { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? + { pattern = "//.*", type = "comment" }, -- Single-line comment + { pattern = { "/%*", "%*/" }, type = "comment" }, -- Multi-line comment + { pattern = { '"', '"', '\\' }, type = "string" }, -- String, double quotes (also matches triple quotes for multi-line string) + { pattern = { "'", "'", '\\' }, type = "string" }, -- String, apices + { pattern = { "%/", "%/", '\\' }, type = "string" }, -- Slashy string + { pattern = { "%$%/", "%/%$", '\\' }, type = "string" }, -- Dollar slashy string + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, -- ? + { pattern = "-?%d+[%d%.eE]*[a-zA-Z]?", type = "number" }, -- ? + { pattern = "-?%.?%d+", type = "number" }, -- ? + { pattern = "-?[%d_+]+[a-zA-Z]?", type = "number" }, -- ? + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operators + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Function/Method/Class/... + { pattern = "[%a_][%w_]*%f[%[]", type = "function" }, -- Custom Type + { regex = [[[A-Z](?:[A-Z_][\\d]*)+(?!\\w)]], type = "keyword2" }, -- Constants + { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, + { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? -- TODO: .class }, symbols = { diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 8173c9ba..a15cac24 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -21,13 +21,14 @@ syntax.add { { pattern = "-?%.?%d+f?", type = "number" }, { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - { regex = "(?>\\w+\\.?)+\\<.+?\\>\\>*(?=\\s+\\w+\\s*)?", type = "function" }, -- Generic class name reference (?>\w+\.?)+\<.+?\>\>*(?=\s+\w+\s*)? - { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)", type = "function" }, -- Class name reference - { regex = "(?>\\w+\\.?)+(?=\\s+\\w+\\s*)?(?=\\s*\\{|\\,)", type = "function" }, -- Class name + { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import + -- WIP: fixing class name reference pattern + { regex = [[(?>\\w+\\.?)+\\<.+?\\>\\>*(?=\\s+.+\\s+\\=)]], type = "function" }, -- Generic class name reference + -- WIP: fixing class name reference pattern + { regex = [[(?>\\w+\\.?)+(?=\\s+.+[(?:\\s+\\=)|;])]], type = "function" }, -- Class name reference { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations - { regex = "[A-Z](?:[A-Z_][\\d]*)+(?!\\w)", type = "keyword2" }, -- Constants + { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "[%a_][%w_]*", type = "symbol" }, }, diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index d161953f..7632fa5a 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -26,14 +26,15 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operators { regex = [[\?(?=\.)]], type = "operator" }, -- ?. operator { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Function/Method/Class - { regex = "`[\\w_\\s]+`(?=\\s*\\()", type = "function" }, -- Test Method + { regex = [[`[\\w_\\s]+`(?=\\s*\\()]], type = "function" }, -- Test Method { regex = [[let(?=\s\{)]], type = "function" }, -- ? operator { regex = [[\?\:(?=\s?)]], type = "operator" }, -- elvis operator { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) - { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, - { regex = "[A-Z](?:[A-Z_][\\d]*)+(?!\\w)", type = "keyword2" }, -- Constants + { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, + -- WIP: converting regex pattern to lua pattern + { regex = [[[A-Z](?:[A-Z_][\\d]*)+(?!\\w)]], type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? }, symbols = { From e43c3749f390bef91692e3b7089391e4d0971c43 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Wed, 8 Jan 2025 00:09:07 +0100 Subject: [PATCH 33/55] Fixed Java/Kotlin/Groovy constants and class patterns; fixed all regex patterns still using double apices. --- plugins/language_groovy.lua | 2 +- plugins/language_java.lua | 6 ++---- plugins/language_kotlin.lua | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/plugins/language_groovy.lua b/plugins/language_groovy.lua index e07d79c3..44b9a35a 100644 --- a/plugins/language_groovy.lua +++ b/plugins/language_groovy.lua @@ -26,7 +26,7 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operators { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Function/Method/Class/... { pattern = "[%a_][%w_]*%f[%[]", type = "function" }, -- Custom Type - { regex = [[[A-Z](?:[A-Z_][\\d]*)+(?!\\w)]], type = "keyword2" }, -- Constants + { regex = [[[A-Z](?:[A-Z_][\d]*)+(?!\w)]], type = "keyword2" }, -- Constants { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? -- TODO: .class diff --git a/plugins/language_java.lua b/plugins/language_java.lua index a15cac24..41038eda 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -22,10 +22,8 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - -- WIP: fixing class name reference pattern - { regex = [[(?>\\w+\\.?)+\\<.+?\\>\\>*(?=\\s+.+\\s+\\=)]], type = "function" }, -- Generic class name reference - -- WIP: fixing class name reference pattern - { regex = [[(?>\\w+\\.?)+(?=\\s+.+[(?:\\s+\\=)|;])]], type = "function" }, -- Class name reference + { regex = [[(?>\w+\.?)+\<.+?\>\>*(?=\s+\w+(?>\s+\=|;))]], type = "function" }, -- Generic class name reference + { regex = [[(?>\w+\.?)+(?=\s+\w+(?>\s+\=|;))]], type = "function" }, -- Class name reference { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index 7632fa5a..9cbd8d93 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -26,15 +26,14 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operators { regex = [[\?(?=\.)]], type = "operator" }, -- ?. operator { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Function/Method/Class - { regex = [[`[\\w_\\s]+`(?=\\s*\\()]], type = "function" }, -- Test Method + { regex = [[`[\w_\s]+`(?=\s*\()]], type = "function" }, -- Test Method { regex = [[let(?=\s\{)]], type = "function" }, -- ? operator { regex = [[\?\:(?=\s?)]], type = "operator" }, -- elvis operator { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, - -- WIP: converting regex pattern to lua pattern - { regex = [[[A-Z](?:[A-Z_][\\d]*)+(?!\\w)]], type = "keyword2" }, -- Constants + { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? }, symbols = { From df627b5812b8f50bf1a1a9b4ceac51e1fbb90473 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Wed, 8 Jan 2025 00:17:12 +0100 Subject: [PATCH 34/55] Added missing match case to Java class name reference pattern: type reference inside a method's () --- plugins/language_java.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 41038eda..272522bf 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -22,8 +22,8 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - { regex = [[(?>\w+\.?)+\<.+?\>\>*(?=\s+\w+(?>\s+\=|;))]], type = "function" }, -- Generic class name reference - { regex = [[(?>\w+\.?)+(?=\s+\w+(?>\s+\=|;))]], type = "function" }, -- Class name reference + { regex = [[(?>\w+\.?)+\<.+?\>\>*(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Generic class name reference + { regex = [[(?>\w+\.?)+(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Class name reference { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants From a634bd747e2c5a97b55ea7f7304c6b694991df22 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Wed, 15 Jan 2025 21:11:26 +0100 Subject: [PATCH 35/55] WIP: updating annotation pattern. --- plugins/language_java.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 272522bf..2ff01d11 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -25,6 +25,7 @@ syntax.add { { regex = [[(?>\w+\.?)+\<.+?\>\>*(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Generic class name reference { regex = [[(?>\w+\.?)+(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Class name reference { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword + -- TODO: match something like: public String hello(@RequestParam(value="user", required=false, defaultValue="Mr") String user, Model model) { { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator From 1c29f53e19abc953b8e3fdd037507de607659446 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sun, 19 Jan 2025 13:25:26 +0100 Subject: [PATCH 36/55] WIP: fixing patterns... --- plugins/language_java.lua | 6 +++++- plugins/language_kotlin.lua | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 2ff01d11..25eac430 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -22,14 +22,18 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import + -- FIX: rework { regex = [[(?>\w+\.?)+\<.+?\>\>*(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Generic class name reference + -- FIX: rework { regex = [[(?>\w+\.?)+(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Class name reference { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword -- TODO: match something like: public String hello(@RequestParam(value="user", required=false, defaultValue="Mr") String user, Model model) { - { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations + -- FIX: stop the pattern match after the last ) when the annotation doesn't begin at line/column n:1 + { pattern = "%s*@.+", type = "keyword2" }, -- Annotations { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "[%a_][%w_]*", type = "symbol" }, + -- FIX: in SomeClassName.class .class should be matched as normal, not keyword }, symbols = { ["abstract"] = "keyword", diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index 9cbd8d93..d1b920e0 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -30,6 +30,7 @@ syntax.add { { regex = [[let(?=\s\{)]], type = "function" }, -- ? operator { regex = [[\?\:(?=\s?)]], type = "operator" }, -- elvis operator { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword + -- TODO: check if it really needs the ^ { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, From bd262ce1e56808879f4881afec00a74ea1e375b1 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Thu, 30 Jan 2025 11:07:49 +0100 Subject: [PATCH 37/55] WIP: ... --- plugins/language_java.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 25eac430..f49e71e8 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -23,8 +23,10 @@ syntax.add { { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import -- FIX: rework + -- missing: public SomethingLikeThat someRandomName() {} { regex = [[(?>\w+\.?)+\<.+?\>\>*(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Generic class name reference -- FIX: rework + -- missing: public SomethingLikeThat someRandomName() {} { regex = [[(?>\w+\.?)+(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Class name reference { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword -- TODO: match something like: public String hello(@RequestParam(value="user", required=false, defaultValue="Mr") String user, Model model) { From d1ebcc6a8d9052b162db28f2859941e0ef558d83 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Tue, 4 Feb 2025 13:08:46 +0100 Subject: [PATCH 38/55] WIP: fixing patterns... --- plugins/language_java.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index f49e71e8..34b3b58c 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -4,6 +4,18 @@ local syntax = require "core.syntax" -- Language Syntax References -- https://docs.oracle.com/javase/specs/jls/se8/html/index.html +-- TEMP: WIP examples +-- public Something someRandomName() {} +-- String somevar = new String(); +-- someMethodCall(String thatSameVar, String anotherSameVar); +-- String someOtherVar; + +-- public Something someRandomName() {} +-- String anotherVar = new String(); +-- String somevar = new String(); +-- someMethodCall(String thatSameVar, String anotherSameVar); +-- String someOtherVar; + syntax.add { name = "Java", files = { "%.java$" }, @@ -22,12 +34,12 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - -- FIX: rework - -- missing: public SomethingLikeThat someRandomName() {} - { regex = [[(?>\w+\.?)+\<.+?\>\>*(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Generic class name reference - -- FIX: rework - -- missing: public SomethingLikeThat someRandomName() {} - { regex = [[(?>\w+\.?)+(?=\s+\w+(?>\s+\=|;|\)))]], type = "function" }, -- Class name reference + { regex = [[(?>\w+\.?)+\<.+?\>\>*(?=\s+\w+(?>\s+\=|;|,|\)))]],type = "function" }, -- Generic class name reference + -- WIP: the first %w+ needs a capt group + { pattern = "%w+%s+()%w+%<.*%>%s+()%w+%f[(]", type = { "keyword", "function", "function" } }, -- Class name reference 2 + { regex = [[(?>\w+\.?)+(?=\s+\w+(?>\s+\=|;|,|\)))]], type = "function" }, -- Class name reference + -- WIP: the first %w+ needs a capt group + { pattern = "%w+%s+()%w+%s+()%w+%f[(]", type = { "keyword", "function", "function" } }, -- Class name reference 2 { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword -- TODO: match something like: public String hello(@RequestParam(value="user", required=false, defaultValue="Mr") String user, Model model) { -- FIX: stop the pattern match after the last ) when the annotation doesn't begin at line/column n:1 From 2cb662fb8fac7221ed23e0728051adbcb1fe1ca1 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Mon, 10 Feb 2025 18:38:41 +0100 Subject: [PATCH 39/55] WIP: fixing patterns --- plugins/language_java.lua | 44 ++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 34b3b58c..a93676e1 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -21,32 +21,28 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - { regex = [[(?>\w+\.?)+\<.+?\>\>*(?=\s+\w+(?>\s+\=|;|,|\)))]],type = "function" }, -- Generic class name reference - -- WIP: the first %w+ needs a capt group - { pattern = "%w+%s+()%w+%<.*%>%s+()%w+%f[(]", type = { "keyword", "function", "function" } }, -- Class name reference 2 - { regex = [[(?>\w+\.?)+(?=\s+\w+(?>\s+\=|;|,|\)))]], type = "function" }, -- Class name reference - -- WIP: the first %w+ needs a capt group - { pattern = "%w+%s+()%w+%s+()%w+%f[(]", type = { "keyword", "function", "function" } }, -- Class name reference 2 - { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import + -- TODO: add support for anything withing the <...> + { regex = [[(?>(?>[A-Z]\w+_?\.?)+(?>\<(?>[\w_?]+)\>)?)+(?=\s+\w+)]], type = "function" }, -- Class name reference + { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword -- TODO: match something like: public String hello(@RequestParam(value="user", required=false, defaultValue="Mr") String user, Model model) { -- FIX: stop the pattern match after the last ) when the annotation doesn't begin at line/column n:1 - { pattern = "%s*@.+", type = "keyword2" }, -- Annotations - { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants - { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "%s*@.+", type = "keyword2" }, -- Annotations + { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants + { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator + { pattern = "[%a_][%w_]*", type = "symbol" }, -- FIX: in SomeClassName.class .class should be matched as normal, not keyword }, symbols = { From 4a65e901c38357a579396d1ddae5cbb77358ce7d Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sun, 23 Feb 2025 18:46:43 +0100 Subject: [PATCH 40/55] WIP: fixing patterns --- plugins/language_java.lua | 56 +++++++++++++++------------------------ 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index a93676e1..97f2e155 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -4,45 +4,33 @@ local syntax = require "core.syntax" -- Language Syntax References -- https://docs.oracle.com/javase/specs/jls/se8/html/index.html --- TEMP: WIP examples --- public Something someRandomName() {} --- String somevar = new String(); --- someMethodCall(String thatSameVar, String anotherSameVar); --- String someOtherVar; - --- public Something someRandomName() {} --- String anotherVar = new String(); --- String somevar = new String(); --- someMethodCall(String thatSameVar, String anotherSameVar); --- String someOtherVar; - syntax.add { name = "Java", files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - -- TODO: add support for anything withing the <...> - { regex = [[(?>(?>[A-Z]\w+_?\.?)+(?>\<(?>[\w_?]+)\>)?)+(?=\s+\w+)]], type = "function" }, -- Class name reference - { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - -- TODO: match something like: public String hello(@RequestParam(value="user", required=false, defaultValue="Mr") String user, Model model) { - -- FIX: stop the pattern match after the last ) when the annotation doesn't begin at line/column n:1 - { pattern = "%s*@.+", type = "keyword2" }, -- Annotations - { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants - { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import + { regex = [[(?>(?>[A-Z]\w+_?\.?)+(?>\<(?>[\w_?\s?]+)\>)?)+(?=(?>\s+\w+)|[(])]], type = "function" }, -- Class name reference + { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword + -- FIX: look at the Terrafirmacraft java file + { pattern = "^%s*%@.+%)$", type = "keyword2" }, -- Annotation (at line start) + { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) + { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) + { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants + { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator + { pattern = "[%a_][%w_]*", type = "symbol" }, -- FIX: in SomeClassName.class .class should be matched as normal, not keyword }, symbols = { From 588e5d4011ce65abd536d6c7a5aded3fa6aeaf72 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Tue, 25 Feb 2025 16:52:25 +0100 Subject: [PATCH 41/55] Updated java annotation patterns and removed java class patterns; updated kotlin annotation patterns; fixed groovy .class pattern. --- plugins/language_groovy.lua | 2 +- plugins/language_java.lua | 9 +++++---- plugins/language_kotlin.lua | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/language_groovy.lua b/plugins/language_groovy.lua index 44b9a35a..877d5b0f 100644 --- a/plugins/language_groovy.lua +++ b/plugins/language_groovy.lua @@ -28,8 +28,8 @@ syntax.add { { pattern = "[%a_][%w_]*%f[%[]", type = "function" }, -- Custom Type { regex = [[[A-Z](?:[A-Z_][\d]*)+(?!\w)]], type = "keyword2" }, -- Constants { pattern = "import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, + { pattern = "%.class", type = "normal" }, -- .class should be colored as normal { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? - -- TODO: .class }, symbols = { -- Reserved keywords diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 97f2e155..c1e27c23 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -19,19 +19,20 @@ syntax.add { { pattern = "-?0x%x+", type = "number" }, { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "%<.+%>", type = "keyword2" }, -- Generic type { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - { regex = [[(?>(?>[A-Z]\w+_?\.?)+(?>\<(?>[\w_?\s?]+)\>)?)+(?=(?>\s+\w+)|[(])]], type = "function" }, -- Class name reference + -- FIX: generic class with anything inside <> + -- { regex = [[(?>(?>[A-Z]\w+_?\.?)+(?>\<(?>[\w_?\s?]+)\>)?)+(?=(?>\s+\w+)|[(])]], type = "function" }, -- Class name reference { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - -- FIX: look at the Terrafirmacraft java file - { pattern = "^%s*%@.+%)$", type = "keyword2" }, -- Annotation (at line start) + { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator + { pattern = "%.class", type = "normal" }, -- .class should be colored as normal { pattern = "[%a_][%w_]*", type = "symbol" }, - -- FIX: in SomeClassName.class .class should be matched as normal, not keyword }, symbols = { ["abstract"] = "keyword", diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index d1b920e0..1c9019f0 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -30,9 +30,9 @@ syntax.add { { regex = [[let(?=\s\{)]], type = "function" }, -- ? operator { regex = [[\?\:(?=\s?)]], type = "operator" }, -- elvis operator { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - -- TODO: check if it really needs the ^ - { pattern = "^%s*@.+", type = "keyword2" }, -- Annotations - { regex = [[[a-zA-Z]+\@(?=\s?[a-zA-Z])]], type = "keyword2" }, -- Annotations (this pattern is lower priority than the `this keyword` pattern) + { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) + { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) + { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? From a65e754e4e8fea61378b61cb1ad58048034e23d3 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 22 Mar 2025 19:38:41 +0100 Subject: [PATCH 42/55] WIP: fixing class name reference pattern. --- plugins/language_java.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index c1e27c23..74c067cd 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -23,8 +23,8 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - -- FIX: generic class with anything inside <> - -- { regex = [[(?>(?>[A-Z]\w+_?\.?)+(?>\<(?>[\w_?\s?]+)\>)?)+(?=(?>\s+\w+)|[(])]], type = "function" }, -- Class name reference + -- FIX: see ./examples/example.java + { regex = [[(?>(?>[A-Z]\w+_?\.?)+(?>\<.+\>(?=\s+))?)+(?=(?>\s+\w+)|[(])]], type = "function" }, -- Class name reference { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) From b63d5a542da2e45d9def269d4f2c311d2aa2928c Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Wed, 23 Apr 2025 16:50:14 +0200 Subject: [PATCH 43/55] WIP: reworked class reference patterns, only 2 pattern fixes remaining. --- plugins/language_java.lua | 80 +++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 74c067cd..bd8ab9ec 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -9,30 +9,62 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "string" }, - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "%<.+%>", type = "keyword2" }, -- Generic type - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - -- FIX: see ./examples/example.java - { regex = [[(?>(?>[A-Z]\w+_?\.?)+(?>\<.+\>(?=\s+))?)+(?=(?>\s+\w+)|[(])]], type = "function" }, -- Class name reference - { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) - { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) - { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) - { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants - { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator - { pattern = "%.class", type = "normal" }, -- .class should be colored as normal - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, -- Single-line comment + { pattern = { "/%*", "%*/" }, type = "comment" }, -- Multi-line comment + { pattern = { '"', '"', '\\' }, type = "string" }, -- String + { pattern = { "'", "'", '\\' }, type = "string" }, -- String + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, -- Number, hexadecimal + { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, -- Number, exponential + { pattern = "-?%.?%d+f?", type = "number" }, -- Number + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operator + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Method + { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import + -- Class name reference, ; + { pattern = "^%w+%s*()%w+%s*%;", type = { "function", "normal" } }, + { pattern = "^%w+%s*()%<.*%>()%s*%w+%s*%;", type = { "function", "keyword2", "normal" } }, + -- Class name reference, = + { pattern = "%w+%s*()%w+%s*()%=", type = { "function", "normal", "operator" } }, + { pattern = "%w+%s*()%<.*%>()%s*%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, + -- Class name reference, new + { pattern = "new()%s*%w+()%<.*%>()%f[(]", type = { "keyword", "function", "keyword2", "normal" } }, + { pattern = "new()%s*%w+()%f[(]", type = { "keyword", "function", "normal" } }, + -- Class name reference, ( then , + { pattern = "%(%s*()%w+%s*()%w+%s*%,", type = { "normal", "function", "normal" } }, + { pattern = "%(%s*()%w+()%<.*%>()%s*%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, + -- Class name reference, (final then , + { pattern = "%(%s*()final%s*()%w+()%<.*%>()%s*%w+%s*%,", type = { "normal", "keyword", "function", "keyword2", "normal" } }, + { pattern = "%(%s*()final%s*()%w+%s*()%w+%s*%,", type = { "normal", "keyword", "function", "normal" } }, + -- Class name reference, , then , + { pattern = "%s*()%w+%s+()%w+%s*%,", type = { "normal", "function", "normal" } }, + { pattern = "%s*()%w+()%<.*%>()%s+%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, + -- FIX: Class name reference, , then ) + { pattern = "%s*()%w+()%s+%w+%s*%)", type = { "normal", "function", "normal" } }, + { pattern = "%,%s*()%w+()%<.*%>()%s+w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, + -- Class name reference, ( then ) + { pattern = "%(%s*()%w+%s*()%w+%s*%)", type = { "normal", "function", "normal" } }, + { pattern = "%(%s*()%w+()%<.*%>()%s*()%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, + -- ? + { pattern = "%s*()%w+()%<.*%>()%s+w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, + -- Array + { pattern = "%w+()%[()%d*()%]", type = { "function", "normal", "number", "normal" } }, + -- Class name reference, method + { pattern = "%w+%s+%w+%s*()%f[(]", type = { "function", "normal" } }, + { pattern = "%w+()%<.*%>()%s+%w+%s*()%f[(]", type = { "function", "keyword2", "function", "normal" } }, + -- other + -- TODO: see if therea are regex patterns that can be converted to lua patterns + { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword + { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) + { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) + { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) + { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants + { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator + { pattern = "%.class", type = "normal" }, -- .class should be colored as normal + { pattern = "[%a_][%w_]*", type = "symbol" }, -- Symbols + -- TODO: check for missing syntaxes by opening an example Java project + -- TODO: check if there are redundant/overlapping patterns }, symbols = { ["abstract"] = "keyword", From bf2350f26b7ef58d68573c2d606d342af30e8ec0 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Wed, 23 Apr 2025 17:10:30 +0200 Subject: [PATCH 44/55] Fixed typo. --- plugins/language_java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index bd8ab9ec..491bfebf 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -54,7 +54,7 @@ syntax.add { { pattern = "%w+%s+%w+%s*()%f[(]", type = { "function", "normal" } }, { pattern = "%w+()%<.*%>()%s+%w+%s*()%f[(]", type = { "function", "keyword2", "function", "normal" } }, -- other - -- TODO: see if therea are regex patterns that can be converted to lua patterns + -- TODO: see if there are regex patterns that can be converted to lua patterns { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) From cd773e052de47243c77c38e5fd75af8fda507412 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Mon, 28 Apr 2025 18:54:59 +0200 Subject: [PATCH 45/55] Fixed class patterns for most common instances. --- plugins/language_java.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 491bfebf..63048636 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -24,36 +24,36 @@ syntax.add { { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import -- Class name reference, ; { pattern = "^%w+%s*()%w+%s*%;", type = { "function", "normal" } }, - { pattern = "^%w+%s*()%<.*%>()%s*%w+%s*%;", type = { "function", "keyword2", "normal" } }, + { pattern = "^%w+%s*()%<.-%>()%s*%w+%s*%;", type = { "function", "keyword2", "normal" } }, -- Class name reference, = { pattern = "%w+%s*()%w+%s*()%=", type = { "function", "normal", "operator" } }, - { pattern = "%w+%s*()%<.*%>()%s*%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, + { pattern = "%w+%s*()%<.-%>()%s*%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, -- Class name reference, new - { pattern = "new()%s*%w+()%<.*%>()%f[(]", type = { "keyword", "function", "keyword2", "normal" } }, + { pattern = "new()%s*%w+()%<.-%>()%f[(]", type = { "keyword", "function", "keyword2", "normal" } }, { pattern = "new()%s*%w+()%f[(]", type = { "keyword", "function", "normal" } }, - -- Class name reference, ( then , + -- FIX: Class name reference, ( then , { pattern = "%(%s*()%w+%s*()%w+%s*%,", type = { "normal", "function", "normal" } }, - { pattern = "%(%s*()%w+()%<.*%>()%s*%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, + { pattern = "%(%s*()%w+()%<.-%>()%s*%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, -- Class name reference, (final then , - { pattern = "%(%s*()final%s*()%w+()%<.*%>()%s*%w+%s*%,", type = { "normal", "keyword", "function", "keyword2", "normal" } }, - { pattern = "%(%s*()final%s*()%w+%s*()%w+%s*%,", type = { "normal", "keyword", "function", "normal" } }, + { pattern = "%(%s*()final%s*()%w+()%<.-%>()%s*%w+%s*%,", type = { "normal", "keyword", "function", "keyword2", "normal" } }, + { pattern = "%(%s*()final%s*()%w+%s*()%w+%s*%,", type = { "normal", "keyword", "function", "normal" } }, -- Class name reference, , then , { pattern = "%s*()%w+%s+()%w+%s*%,", type = { "normal", "function", "normal" } }, - { pattern = "%s*()%w+()%<.*%>()%s+%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, - -- FIX: Class name reference, , then ) + { pattern = "%s*()%w+()%<.-%>()%s+%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, + -- Class name reference, , then ) { pattern = "%s*()%w+()%s+%w+%s*%)", type = { "normal", "function", "normal" } }, - { pattern = "%,%s*()%w+()%<.*%>()%s+w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, + { pattern = "%s*()%w+()%<.-%>()%s+%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, -- Class name reference, ( then ) { pattern = "%(%s*()%w+%s*()%w+%s*%)", type = { "normal", "function", "normal" } }, - { pattern = "%(%s*()%w+()%<.*%>()%s*()%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, + { pattern = "%(%s*()%w+()%<.-%>()%s*()%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, -- ? - { pattern = "%s*()%w+()%<.*%>()%s+w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, + { pattern = "%s*()%w+()%<.-%>()%s+w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, -- Array { pattern = "%w+()%[()%d*()%]", type = { "function", "normal", "number", "normal" } }, -- Class name reference, method { pattern = "%w+%s+%w+%s*()%f[(]", type = { "function", "normal" } }, - { pattern = "%w+()%<.*%>()%s+%w+%s*()%f[(]", type = { "function", "keyword2", "function", "normal" } }, - -- other + { pattern = "%w+()%<.-%>()%s+%w+%s*()%f[(]", type = { "function", "keyword2", "function", "normal" } }, + -- Other patterns -- TODO: see if there are regex patterns that can be converted to lua patterns { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) From 7ab827a79c482f376b32765f8a92c0506a3edce2 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Wed, 30 Apr 2025 14:32:34 +0200 Subject: [PATCH 46/55] WIP: fixing patterns.... --- plugins/language_java.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 63048636..0f926efb 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -23,15 +23,25 @@ syntax.add { { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Method { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import -- Class name reference, ; + { pattern = "^%s*()return()%s*%.-()%;$", type = { "normal", "keyword", "symbol", "normal" } }, -- Fix class name reference, ; pattern { pattern = "^%w+%s*()%w+%s*%;", type = { "function", "normal" } }, { pattern = "^%w+%s*()%<.-%>()%s*%w+%s*%;", type = { "function", "keyword2", "normal" } }, + -- FIX: valid only when preceded by a single keyword (es. private), when using more than one (es. private static) it breaks + { pattern = "^%s*%w+%s*()%w+()%<.-%>()%s*%w+%s*%;", type = { "keyword", "function", "keyword2", "normal" } }, + { pattern = "^%s*%w+%s*()%w+%s*()%w+%s*%;", type = { "keyword", "function", "normal" } }, -- Class name reference, = + -- FIX: paramClassDiagramTextToWrap = builder.toString(); + -- FIX: return paramClassDiagramTextToWrap; + -- FIX: classDiagramText = createAsciidocWrappedDiagramText(classDiagramText); + -- FIX: IOUtils.write(classDiagramText, outputStream, getEncoding()); + -- FIX: this.outputFilename = outputFilename; + -- FIX: if (whitelistRegexp == null || "".equals(whitelistRegexp)) { { pattern = "%w+%s*()%w+%s*()%=", type = { "function", "normal", "operator" } }, { pattern = "%w+%s*()%<.-%>()%s*%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, -- Class name reference, new { pattern = "new()%s*%w+()%<.-%>()%f[(]", type = { "keyword", "function", "keyword2", "normal" } }, { pattern = "new()%s*%w+()%f[(]", type = { "keyword", "function", "normal" } }, - -- FIX: Class name reference, ( then , + -- Class name reference, ( then , { pattern = "%(%s*()%w+%s*()%w+%s*%,", type = { "normal", "function", "normal" } }, { pattern = "%(%s*()%w+()%<.-%>()%s*%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, -- Class name reference, (final then , @@ -46,12 +56,10 @@ syntax.add { -- Class name reference, ( then ) { pattern = "%(%s*()%w+%s*()%w+%s*%)", type = { "normal", "function", "normal" } }, { pattern = "%(%s*()%w+()%<.-%>()%s*()%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, - -- ? - { pattern = "%s*()%w+()%<.-%>()%s+w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, -- Array { pattern = "%w+()%[()%d*()%]", type = { "function", "normal", "number", "normal" } }, -- Class name reference, method - { pattern = "%w+%s+%w+%s*()%f[(]", type = { "function", "normal" } }, + { pattern = "%w+%s+()%w+%s*()%f[(]", type = { "keyword", "function", "normal" } }, { pattern = "%w+()%<.-%>()%s+%w+%s*()%f[(]", type = { "function", "keyword2", "function", "normal" } }, -- Other patterns -- TODO: see if there are regex patterns that can be converted to lua patterns @@ -63,8 +71,10 @@ syntax.add { { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "%.class", type = "normal" }, -- .class should be colored as normal { pattern = "[%a_][%w_]*", type = "symbol" }, -- Symbols - -- TODO: check for missing syntaxes by opening an example Java project + -- WIP: check for missing syntaxes by opening an example Java project -- TODO: check if there are redundant/overlapping patterns + -- TODO: private final VisibilityType maxVisibilityMethods = VisibilityType.PRIVATE; + -- in this case VisibilityType should be colored as function }, symbols = { ["abstract"] = "keyword", From 25ebcb7d6627032786fa068f500c49a283e1a9f7 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Thu, 15 May 2025 09:32:51 +0200 Subject: [PATCH 47/55] WIP: fixing patterns --- plugins/language_java.lua | 24 +++++++++--------------- plugins/language_kotlin.lua | 1 + 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 0f926efb..5bf98b07 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -18,24 +18,20 @@ syntax.add { { pattern = "'\\?.'", type = "string" }, -- character literal { pattern = "-?0x%x+", type = "number" }, -- Number, hexadecimal { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, -- Number, exponential - { pattern = "-?%.?%d+f?", type = "number" }, -- Number + -- FIX: int, float, long, double + { pattern = "-?%d+%.?%d*[lLfFdD]?", type = "number" }, -- Number { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operator { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Method { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import -- Class name reference, ; - { pattern = "^%s*()return()%s*%.-()%;$", type = { "normal", "keyword", "symbol", "normal" } }, -- Fix class name reference, ; pattern - { pattern = "^%w+%s*()%w+%s*%;", type = { "function", "normal" } }, - { pattern = "^%w+%s*()%<.-%>()%s*%w+%s*%;", type = { "function", "keyword2", "normal" } }, - -- FIX: valid only when preceded by a single keyword (es. private), when using more than one (es. private static) it breaks + { pattern = "^%s*()return()%s*%.-()%;$", type = { "normal", "keyword", "symbol", "normal" } }, + { pattern = "^%s*[A-Z]%w+%s*()%w+%s*%;", type = { "function", "normal" } }, + { pattern = "^%s*%w+()%<.-%>()%s*%w+%s*%;", type = { "function", "keyword2", "normal" } }, + -- FIX { pattern = "^%s*%w+%s*()%w+()%<.-%>()%s*%w+%s*%;", type = { "keyword", "function", "keyword2", "normal" } }, { pattern = "^%s*%w+%s*()%w+%s*()%w+%s*%;", type = { "keyword", "function", "normal" } }, -- Class name reference, = - -- FIX: paramClassDiagramTextToWrap = builder.toString(); - -- FIX: return paramClassDiagramTextToWrap; - -- FIX: classDiagramText = createAsciidocWrappedDiagramText(classDiagramText); - -- FIX: IOUtils.write(classDiagramText, outputStream, getEncoding()); - -- FIX: this.outputFilename = outputFilename; - -- FIX: if (whitelistRegexp == null || "".equals(whitelistRegexp)) { + -- FIX { pattern = "%w+%s*()%w+%s*()%=", type = { "function", "normal", "operator" } }, { pattern = "%w+%s*()%<.-%>()%s*%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, -- Class name reference, new @@ -62,19 +58,17 @@ syntax.add { { pattern = "%w+%s+()%w+%s*()%f[(]", type = { "keyword", "function", "normal" } }, { pattern = "%w+()%<.-%>()%s+%w+%s*()%f[(]", type = { "function", "keyword2", "function", "normal" } }, -- Other patterns - -- TODO: see if there are regex patterns that can be converted to lua patterns { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) + -- FIX: SQUID_ works but not SQUID { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "%.class", type = "normal" }, -- .class should be colored as normal { pattern = "[%a_][%w_]*", type = "symbol" }, -- Symbols - -- WIP: check for missing syntaxes by opening an example Java project -- TODO: check if there are redundant/overlapping patterns - -- TODO: private final VisibilityType maxVisibilityMethods = VisibilityType.PRIVATE; - -- in this case VisibilityType should be colored as function + -- WIP: check for missing syntaxes by opening an example Java project }, symbols = { ["abstract"] = "keyword", diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index 1c9019f0..a5658dea 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -36,6 +36,7 @@ syntax.add { { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? + -- TODO: class references }, symbols = { -- Hard keywords From bca9f37281a9bda134f83b7324badd0158cce52b Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Mon, 2 Jun 2025 12:46:22 +0200 Subject: [PATCH 48/55] WIP: fixing patterns --- plugins/language_java.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 5bf98b07..53ce3e8c 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -23,38 +23,38 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operator { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Method { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - -- Class name reference, ; + -- Class name reference: ; { pattern = "^%s*()return()%s*%.-()%;$", type = { "normal", "keyword", "symbol", "normal" } }, { pattern = "^%s*[A-Z]%w+%s*()%w+%s*%;", type = { "function", "normal" } }, { pattern = "^%s*%w+()%<.-%>()%s*%w+%s*%;", type = { "function", "keyword2", "normal" } }, -- FIX { pattern = "^%s*%w+%s*()%w+()%<.-%>()%s*%w+%s*%;", type = { "keyword", "function", "keyword2", "normal" } }, { pattern = "^%s*%w+%s*()%w+%s*()%w+%s*%;", type = { "keyword", "function", "normal" } }, - -- Class name reference, = + -- Class name reference: = -- FIX { pattern = "%w+%s*()%w+%s*()%=", type = { "function", "normal", "operator" } }, { pattern = "%w+%s*()%<.-%>()%s*%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, - -- Class name reference, new + -- Class name reference: new { pattern = "new()%s*%w+()%<.-%>()%f[(]", type = { "keyword", "function", "keyword2", "normal" } }, { pattern = "new()%s*%w+()%f[(]", type = { "keyword", "function", "normal" } }, - -- Class name reference, ( then , + -- Class name reference: ( then , { pattern = "%(%s*()%w+%s*()%w+%s*%,", type = { "normal", "function", "normal" } }, { pattern = "%(%s*()%w+()%<.-%>()%s*%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, - -- Class name reference, (final then , + -- Class name reference: (final then , { pattern = "%(%s*()final%s*()%w+()%<.-%>()%s*%w+%s*%,", type = { "normal", "keyword", "function", "keyword2", "normal" } }, { pattern = "%(%s*()final%s*()%w+%s*()%w+%s*%,", type = { "normal", "keyword", "function", "normal" } }, - -- Class name reference, , then , + -- Class name reference: , then , { pattern = "%s*()%w+%s+()%w+%s*%,", type = { "normal", "function", "normal" } }, { pattern = "%s*()%w+()%<.-%>()%s+%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, - -- Class name reference, , then ) + -- Class name reference: , then ) { pattern = "%s*()%w+()%s+%w+%s*%)", type = { "normal", "function", "normal" } }, { pattern = "%s*()%w+()%<.-%>()%s+%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, - -- Class name reference, ( then ) + -- Class name reference: ( then ) { pattern = "%(%s*()%w+%s*()%w+%s*%)", type = { "normal", "function", "normal" } }, { pattern = "%(%s*()%w+()%<.-%>()%s*()%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, -- Array { pattern = "%w+()%[()%d*()%]", type = { "function", "normal", "number", "normal" } }, - -- Class name reference, method + -- Class name reference: method { pattern = "%w+%s+()%w+%s*()%f[(]", type = { "keyword", "function", "normal" } }, { pattern = "%w+()%<.-%>()%s+%w+%s*()%f[(]", type = { "function", "keyword2", "function", "normal" } }, -- Other patterns @@ -62,7 +62,7 @@ syntax.add { { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) - -- FIX: SQUID_ works but not SQUID + -- WIP: constants { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "%.class", type = "normal" }, -- .class should be colored as normal From 304077f23a4455f5744420614b5037c64718cde1 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Fri, 25 Jul 2025 21:49:28 +0200 Subject: [PATCH 49/55] WIP: fixing some more patterns for Class name references. --- plugins/language_java.lua | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 53ce3e8c..5c91ffef 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -16,24 +16,32 @@ syntax.add { { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, -- Number, hexadecimal - { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, -- Number, exponential - -- FIX: int, float, long, double - { pattern = "-?%d+%.?%d*[lLfFdD]?", type = "number" }, -- Number + { pattern = "-?0x%x+", type = "number" }, -- Number: hexadecimal + { pattern = "-?%d+[%d%.eE]*[fFdD]?", type = "number" }, -- Number: exponential, float/double { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operator { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Method { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - -- Class name reference: ; - { pattern = "^%s*()return()%s*%.-()%;$", type = { "normal", "keyword", "symbol", "normal" } }, + -- Constants + { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, + -- Class name reference: ; (single accessibility modifier) + { pattern = "^%s*()return()%s*%.-()%;$", type = { "normal", "function", "symbol", "normal" } }, { pattern = "^%s*[A-Z]%w+%s*()%w+%s*%;", type = { "function", "normal" } }, { pattern = "^%s*%w+()%<.-%>()%s*%w+%s*%;", type = { "function", "keyword2", "normal" } }, - -- FIX + -- Class name reference: ; (multiple accessibility modifiers) + { pattern = "%s*[A-Z]%w+%s*()[A-Z_]+()%s*%;", type = { "function", "keyword2", "normal" } }, + { pattern = "%s*[A-Z]%w+()%<.-%>()%s*[A-Z_]+()%s*%;", type = { "function", "keyword2", "keyword2", "normal" } }, + { pattern = "%s*[A-Z]%w+%s*()[%w_]+%s*%;", type = { "function", "normal" } }, + { pattern = "%s*[A-Z]%w+()%<.-%>()%s*[%w_]+%s*%;", type = { "function", "keyword2", "normal" } }, + -- es. private String classBlacklistRegexp; + -- es. private String<> classBlacklistRegexp; + -- es. private String classBlacklistRegexp; { pattern = "^%s*%w+%s*()%w+()%<.-%>()%s*%w+%s*%;", type = { "keyword", "function", "keyword2", "normal" } }, { pattern = "^%s*%w+%s*()%w+%s*()%w+%s*%;", type = { "keyword", "function", "normal" } }, -- Class name reference: = - -- FIX + { pattern = "%w+%s*()[A-Z_]+%s*()%=", type = { "function", "keyword2", "operator" } }, + { pattern = "%w+()%<.-%>()%s*[A-Z_]+%s*()%=", type = { "function", "keyword2", "keyword2", "operator" } }, { pattern = "%w+%s*()%w+%s*()%=", type = { "function", "normal", "operator" } }, - { pattern = "%w+%s*()%<.-%>()%s*%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, + { pattern = "%w+()%<.-%>()%s*%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, -- Class name reference: new { pattern = "new()%s*%w+()%<.-%>()%f[(]", type = { "keyword", "function", "keyword2", "normal" } }, { pattern = "new()%s*%w+()%f[(]", type = { "keyword", "function", "normal" } }, @@ -51,19 +59,18 @@ syntax.add { { pattern = "%s*()%w+()%<.-%>()%s+%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, -- Class name reference: ( then ) { pattern = "%(%s*()%w+%s*()%w+%s*%)", type = { "normal", "function", "normal" } }, - { pattern = "%(%s*()%w+()%<.-%>()%s*()%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, + { pattern = "%(%s*()%w+()%<.-%>()%s*()%w+%s*%)", type = { "normal", "function", "keyword2", "normal", "normal" } }, -- Array { pattern = "%w+()%[()%d*()%]", type = { "function", "normal", "number", "normal" } }, -- Class name reference: method - { pattern = "%w+%s+()%w+%s*()%f[(]", type = { "keyword", "function", "normal" } }, + -- es. public String SomeClass( + { pattern = "%w+%s+()%w+%s*()%f[(]", type = { "function", "function", "normal" } }, { pattern = "%w+()%<.-%>()%s+%w+%s*()%f[(]", type = { "function", "keyword2", "function", "normal" } }, -- Other patterns - { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) - { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) + { pattern = "this()%s*.*$", type = { "keyword", "normal" } }, -- Import + -- { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) + -- { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) - -- WIP: constants - { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator { pattern = "%.class", type = "normal" }, -- .class should be colored as normal { pattern = "[%a_][%w_]*", type = "symbol" }, -- Symbols From 8e8ca22aa5765ef6b11581a37169dcaecfc89315 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 26 Jul 2025 13:50:30 +0200 Subject: [PATCH 50/55] WIP: fixing last few class name reference patterns. --- plugins/language_java.lua | 44 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 5c91ffef..b3166c04 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -24,33 +24,35 @@ syntax.add { -- Constants { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Class name reference: ; (single accessibility modifier) - { pattern = "^%s*()return()%s*%.-()%;$", type = { "normal", "function", "symbol", "normal" } }, - { pattern = "^%s*[A-Z]%w+%s*()%w+%s*%;", type = { "function", "normal" } }, - { pattern = "^%s*%w+()%<.-%>()%s*%w+%s*%;", type = { "function", "keyword2", "normal" } }, + -- WIP: return ... + { pattern = "^%s*()return()%s+[A-Z]%w+()%s+.-()%;", type = { "normal", "symbol", "function", "normal", "normal" } }, + { pattern = "^%s*()return()%s+[A-Z][A-Z_]+()%;", type = { "normal", "symbol", "keyword2", "normal" } }, + { pattern = "^%s*[A-Z]%w+%s+()%w+%s*%;", type = { "function", "normal" } }, + { pattern = "^%s*%w+()%<.-%>()%s+%w+%s*%;", type = { "function", "keyword2", "normal" } }, -- Class name reference: ; (multiple accessibility modifiers) - { pattern = "%s*[A-Z]%w+%s*()[A-Z_]+()%s*%;", type = { "function", "keyword2", "normal" } }, - { pattern = "%s*[A-Z]%w+()%<.-%>()%s*[A-Z_]+()%s*%;", type = { "function", "keyword2", "keyword2", "normal" } }, - { pattern = "%s*[A-Z]%w+%s*()[%w_]+%s*%;", type = { "function", "normal" } }, - { pattern = "%s*[A-Z]%w+()%<.-%>()%s*[%w_]+%s*%;", type = { "function", "keyword2", "normal" } }, + { pattern = "%s*[A-Z]%w+%s+()[A-Z_]+()%s*%;", type = { "function", "keyword2", "normal" } }, + { pattern = "%s*[A-Z]%w+()%<.-%>()%s+[A-Z_]+()%s*%;", type = { "function", "keyword2", "keyword2", "normal" } }, + { pattern = "%s*[A-Z]%w+%s+()[%w_]+%s*%;", type = { "function", "normal" } }, + { pattern = "%s*[A-Z]%w+()%<.-%>()%s+[%w_]+%s*%;", type = { "function", "keyword2", "normal" } }, -- es. private String classBlacklistRegexp; -- es. private String<> classBlacklistRegexp; -- es. private String classBlacklistRegexp; - { pattern = "^%s*%w+%s*()%w+()%<.-%>()%s*%w+%s*%;", type = { "keyword", "function", "keyword2", "normal" } }, - { pattern = "^%s*%w+%s*()%w+%s*()%w+%s*%;", type = { "keyword", "function", "normal" } }, + { pattern = "^%s*%w+%s+()%w+()%<.-%>()%s*%w+%s*%;", type = { "keyword", "function", "keyword2", "normal" } }, + { pattern = "^%s*%w+%s+()%w+%s*()%w+%s*%;", type = { "keyword", "function", "normal" } }, -- Class name reference: = - { pattern = "%w+%s*()[A-Z_]+%s*()%=", type = { "function", "keyword2", "operator" } }, - { pattern = "%w+()%<.-%>()%s*[A-Z_]+%s*()%=", type = { "function", "keyword2", "keyword2", "operator" } }, - { pattern = "%w+%s*()%w+%s*()%=", type = { "function", "normal", "operator" } }, - { pattern = "%w+()%<.-%>()%s*%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, + { pattern = "%w+%s+()[A-Z_]+%s*()%=", type = { "function", "keyword2", "operator" } }, + { pattern = "%w+()%<.-%>()%s+[A-Z_]+%s*()%=", type = { "function", "keyword2", "keyword2", "operator" } }, + { pattern = "%w+%s+()%w+%s*()%=", type = { "function", "normal", "operator" } }, + { pattern = "%w+()%<.-%>()%s+%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, -- Class name reference: new - { pattern = "new()%s*%w+()%<.-%>()%f[(]", type = { "keyword", "function", "keyword2", "normal" } }, - { pattern = "new()%s*%w+()%f[(]", type = { "keyword", "function", "normal" } }, + { pattern = "new()%s+%w+()%<.-%>()%f[(]", type = { "keyword", "function", "keyword2", "normal" } }, + { pattern = "new()%s+%w+()%f[(]", type = { "keyword", "function", "normal" } }, -- Class name reference: ( then , - { pattern = "%(%s*()%w+%s*()%w+%s*%,", type = { "normal", "function", "normal" } }, - { pattern = "%(%s*()%w+()%<.-%>()%s*%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, + { pattern = "%(%s*()%w+%s+()%w+%s*%,", type = { "normal", "function", "normal" } }, + { pattern = "%(%s*()%w+()%<.-%>()%s+%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, -- Class name reference: (final then , - { pattern = "%(%s*()final%s*()%w+()%<.-%>()%s*%w+%s*%,", type = { "normal", "keyword", "function", "keyword2", "normal" } }, - { pattern = "%(%s*()final%s*()%w+%s*()%w+%s*%,", type = { "normal", "keyword", "function", "normal" } }, + { pattern = "%(%s*()final%s*()%w+()%<.-%>()%s+%w+%s*%,", type = { "normal", "keyword", "function", "keyword2", "normal" } }, + { pattern = "%(%s*()final%s*()%w+%s+()%w+%s*%,", type = { "normal", "keyword", "function", "normal" } }, -- Class name reference: , then , { pattern = "%s*()%w+%s+()%w+%s*%,", type = { "normal", "function", "normal" } }, { pattern = "%s*()%w+()%<.-%>()%s+%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, @@ -58,8 +60,8 @@ syntax.add { { pattern = "%s*()%w+()%s+%w+%s*%)", type = { "normal", "function", "normal" } }, { pattern = "%s*()%w+()%<.-%>()%s+%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, -- Class name reference: ( then ) - { pattern = "%(%s*()%w+%s*()%w+%s*%)", type = { "normal", "function", "normal" } }, - { pattern = "%(%s*()%w+()%<.-%>()%s*()%w+%s*%)", type = { "normal", "function", "keyword2", "normal", "normal" } }, + { pattern = "%(%s*()%w+%s+()%w+%s*%)", type = { "normal", "function", "normal" } }, + { pattern = "%(%s*()%w+()%<.-%>()%s+()%w+%s*%)", type = { "normal", "function", "keyword2", "normal", "normal" } }, -- Array { pattern = "%w+()%[()%d*()%]", type = { "function", "normal", "number", "normal" } }, -- Class name reference: method From e84d7b26234ba6865aecc55b106582ca3f90c1cb Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 26 Jul 2025 16:58:16 +0200 Subject: [PATCH 51/55] Fixed last class name reference pattern. --- plugins/language_java.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index b3166c04..a498fe36 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -21,12 +21,10 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operator { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Method { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - -- Constants - { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, + { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants -- Class name reference: ; (single accessibility modifier) - -- WIP: return ... - { pattern = "^%s*()return()%s+[A-Z]%w+()%s+.-()%;", type = { "normal", "symbol", "function", "normal", "normal" } }, - { pattern = "^%s*()return()%s+[A-Z][A-Z_]+()%;", type = { "normal", "symbol", "keyword2", "normal" } }, + { pattern = "return()%s+()[A-Z]%w+()%s+.-()%;", type = { "symbol", "normal", "function", "normal", "normal" } }, + { pattern = "return()%s+()[A-Z][A-Z_]+()%;", type = { "symbol", "normal", "keyword2", "normal" } }, { pattern = "^%s*[A-Z]%w+%s+()%w+%s*%;", type = { "function", "normal" } }, { pattern = "^%s*%w+()%<.-%>()%s+%w+%s*%;", type = { "function", "keyword2", "normal" } }, -- Class name reference: ; (multiple accessibility modifiers) From a7886985e17ba64322c7230f0dd82b69929d7cb7 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 30 Aug 2025 23:26:28 +0200 Subject: [PATCH 52/55] Finally fixed Method patterns and too many other changes --- plugins/language_java.lua | 43 +++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index a498fe36..16c335dc 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -19,12 +19,20 @@ syntax.add { { pattern = "-?0x%x+", type = "number" }, -- Number: hexadecimal { pattern = "-?%d+[%d%.eE]*[fFdD]?", type = "number" }, -- Number: exponential, float/double { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operator - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Method - { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import - { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants + -- Method + { pattern = "[A-Z_]+[a-z-A-Z_]+()%s+()%w+()%f[(]", type = { "function", "normal", "function", "normal" } }, + { pattern = "[A-Z_]+[a-z-A-Z_]+()%<.-%>()%s+()%w+()%f[(]",type = { "function", "keyword2", "normal", "function", "normal" } }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + -- Generic method + { pattern = "%s+()%<.-%>()%s+", type = { "normal", "keyword2", "normal" } }, + { pattern = "%.()%<.-%>()%w+", type = { "normal", "keyword2", "function" } }, + -- Import + { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, + -- Constants + { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Class name reference: ; (single accessibility modifier) - { pattern = "return()%s+()[A-Z]%w+()%s+.-()%;", type = { "symbol", "normal", "function", "normal", "normal" } }, - { pattern = "return()%s+()[A-Z][A-Z_]+()%;", type = { "symbol", "normal", "keyword2", "normal" } }, + { pattern = "return()%s()[a-z][%w_]+()%;", type = { "symbol", "normal", "normal", "normal" } }, -- This is a fix: es. return someVarName; + { pattern = "return()%s()[A-Z][A-Z_]+()%;", type = { "symbol", "normal", "keyword2", "normal" } }, { pattern = "^%s*[A-Z]%w+%s+()%w+%s*%;", type = { "function", "normal" } }, { pattern = "^%s*%w+()%<.-%>()%s+%w+%s*%;", type = { "function", "keyword2", "normal" } }, -- Class name reference: ; (multiple accessibility modifiers) @@ -62,20 +70,19 @@ syntax.add { { pattern = "%(%s*()%w+()%<.-%>()%s+()%w+%s*%)", type = { "normal", "function", "keyword2", "normal", "normal" } }, -- Array { pattern = "%w+()%[()%d*()%]", type = { "function", "normal", "number", "normal" } }, - -- Class name reference: method - -- es. public String SomeClass( - { pattern = "%w+%s+()%w+%s*()%f[(]", type = { "function", "function", "normal" } }, - { pattern = "%w+()%<.-%>()%s+%w+%s*()%f[(]", type = { "function", "keyword2", "function", "normal" } }, - -- Other patterns - { pattern = "this()%s*.*$", type = { "keyword", "normal" } }, -- Import - -- { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) - -- { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) - { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) - { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator - { pattern = "%.class", type = "normal" }, -- .class should be colored as normal - { pattern = "[%a_][%w_]*", type = "symbol" }, -- Symbols - -- TODO: check if there are redundant/overlapping patterns + -- FIX: ? + { pattern = "this()%s*.*$", type = { "keyword", "normal" } }, + -- Annotation (like: final @Nullable String something;) + { pattern = "%@%w+", type = "keyword2" }, + -- Method reference with double colon operator + { pattern = "%:%:()%w+", type = { "normal", "function" } }, + -- .class should be colored as normal + { pattern = "%.class", type = "normal" }, + -- Symbols + { pattern = "[%a_][%w_]*", type = "symbol" }, -- WIP: check for missing syntaxes by opening an example Java project + -- TODO: check if there are redundant/overlapping patterns + -- TODO: , final BiomeDictionary.Type... types) { }, symbols = { ["abstract"] = "keyword", From 106249929d41b993a55d15a04f3e8843138f6df9 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Tue, 16 Sep 2025 23:14:28 +0200 Subject: [PATCH 53/55] WIP: fixing stuff --- plugins/language_java.lua | 3 +++ plugins/language_kotlin.lua | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 16c335dc..e3011333 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -4,6 +4,9 @@ local syntax = require "core.syntax" -- Language Syntax References -- https://docs.oracle.com/javase/specs/jls/se8/html/index.html +-- WIP: required for complex recurring patterns + + syntax.add { name = "Java", files = { "%.java$" }, diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index a5658dea..fd1e1331 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -36,7 +36,7 @@ syntax.add { { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? - -- TODO: class references + -- TODO: class name reference }, symbols = { -- Hard keywords From fbe9522e18e9fd3c2aea0cb02a803d124d67efe0 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Wed, 1 Oct 2025 07:49:01 +0200 Subject: [PATCH 54/55] Removed class reference patterns; fixed remaining base patterns; changed primitive data type patterns from keyword2 to keyword --- plugins/language_java.lua | 118 ++++++++++---------------------------- 1 file changed, 30 insertions(+), 88 deletions(-) diff --git a/plugins/language_java.lua b/plugins/language_java.lua index e3011333..eeae5e33 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -4,88 +4,30 @@ local syntax = require "core.syntax" -- Language Syntax References -- https://docs.oracle.com/javase/specs/jls/se8/html/index.html --- WIP: required for complex recurring patterns - - syntax.add { name = "Java", files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.*", type = "comment" }, -- Single-line comment - { pattern = { "/%*", "%*/" }, type = "comment" }, -- Multi-line comment - { pattern = { '"', '"', '\\' }, type = "string" }, -- String - { pattern = { "'", "'", '\\' }, type = "string" }, -- String - { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence - { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence - { pattern = "'\\?.'", type = "string" }, -- character literal - { pattern = "-?0x%x+", type = "number" }, -- Number: hexadecimal - { pattern = "-?%d+[%d%.eE]*[fFdD]?", type = "number" }, -- Number: exponential, float/double - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operator - -- Method - { pattern = "[A-Z_]+[a-z-A-Z_]+()%s+()%w+()%f[(]", type = { "function", "normal", "function", "normal" } }, - { pattern = "[A-Z_]+[a-z-A-Z_]+()%<.-%>()%s+()%w+()%f[(]",type = { "function", "keyword2", "normal", "function", "normal" } }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - -- Generic method - { pattern = "%s+()%<.-%>()%s+", type = { "normal", "keyword2", "normal" } }, - { pattern = "%.()%<.-%>()%w+", type = { "normal", "keyword2", "function" } }, - -- Import - { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, - -- Constants - { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, - -- Class name reference: ; (single accessibility modifier) - { pattern = "return()%s()[a-z][%w_]+()%;", type = { "symbol", "normal", "normal", "normal" } }, -- This is a fix: es. return someVarName; - { pattern = "return()%s()[A-Z][A-Z_]+()%;", type = { "symbol", "normal", "keyword2", "normal" } }, - { pattern = "^%s*[A-Z]%w+%s+()%w+%s*%;", type = { "function", "normal" } }, - { pattern = "^%s*%w+()%<.-%>()%s+%w+%s*%;", type = { "function", "keyword2", "normal" } }, - -- Class name reference: ; (multiple accessibility modifiers) - { pattern = "%s*[A-Z]%w+%s+()[A-Z_]+()%s*%;", type = { "function", "keyword2", "normal" } }, - { pattern = "%s*[A-Z]%w+()%<.-%>()%s+[A-Z_]+()%s*%;", type = { "function", "keyword2", "keyword2", "normal" } }, - { pattern = "%s*[A-Z]%w+%s+()[%w_]+%s*%;", type = { "function", "normal" } }, - { pattern = "%s*[A-Z]%w+()%<.-%>()%s+[%w_]+%s*%;", type = { "function", "keyword2", "normal" } }, - -- es. private String classBlacklistRegexp; - -- es. private String<> classBlacklistRegexp; - -- es. private String classBlacklistRegexp; - { pattern = "^%s*%w+%s+()%w+()%<.-%>()%s*%w+%s*%;", type = { "keyword", "function", "keyword2", "normal" } }, - { pattern = "^%s*%w+%s+()%w+%s*()%w+%s*%;", type = { "keyword", "function", "normal" } }, - -- Class name reference: = - { pattern = "%w+%s+()[A-Z_]+%s*()%=", type = { "function", "keyword2", "operator" } }, - { pattern = "%w+()%<.-%>()%s+[A-Z_]+%s*()%=", type = { "function", "keyword2", "keyword2", "operator" } }, - { pattern = "%w+%s+()%w+%s*()%=", type = { "function", "normal", "operator" } }, - { pattern = "%w+()%<.-%>()%s+%w+%s*()%=", type = { "function", "keyword2", "normal", "operator" } }, - -- Class name reference: new - { pattern = "new()%s+%w+()%<.-%>()%f[(]", type = { "keyword", "function", "keyword2", "normal" } }, - { pattern = "new()%s+%w+()%f[(]", type = { "keyword", "function", "normal" } }, - -- Class name reference: ( then , - { pattern = "%(%s*()%w+%s+()%w+%s*%,", type = { "normal", "function", "normal" } }, - { pattern = "%(%s*()%w+()%<.-%>()%s+%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, - -- Class name reference: (final then , - { pattern = "%(%s*()final%s*()%w+()%<.-%>()%s+%w+%s*%,", type = { "normal", "keyword", "function", "keyword2", "normal" } }, - { pattern = "%(%s*()final%s*()%w+%s+()%w+%s*%,", type = { "normal", "keyword", "function", "normal" } }, - -- Class name reference: , then , - { pattern = "%s*()%w+%s+()%w+%s*%,", type = { "normal", "function", "normal" } }, - { pattern = "%s*()%w+()%<.-%>()%s+%w+%s*%,", type = { "normal", "function", "keyword2", "normal" } }, - -- Class name reference: , then ) - { pattern = "%s*()%w+()%s+%w+%s*%)", type = { "normal", "function", "normal" } }, - { pattern = "%s*()%w+()%<.-%>()%s+%w+%s*%)", type = { "normal", "function", "keyword2", "normal" } }, - -- Class name reference: ( then ) - { pattern = "%(%s*()%w+%s+()%w+%s*%)", type = { "normal", "function", "normal" } }, - { pattern = "%(%s*()%w+()%<.-%>()%s+()%w+%s*%)", type = { "normal", "function", "keyword2", "normal", "normal" } }, - -- Array - { pattern = "%w+()%[()%d*()%]", type = { "function", "normal", "number", "normal" } }, - -- FIX: ? - { pattern = "this()%s*.*$", type = { "keyword", "normal" } }, - -- Annotation (like: final @Nullable String something;) - { pattern = "%@%w+", type = "keyword2" }, - -- Method reference with double colon operator - { pattern = "%:%:()%w+", type = { "normal", "function" } }, - -- .class should be colored as normal - { pattern = "%.class", type = "normal" }, - -- Symbols - { pattern = "[%a_][%w_]*", type = "symbol" }, - -- WIP: check for missing syntaxes by opening an example Java project - -- TODO: check if there are redundant/overlapping patterns - -- TODO: , final BiomeDictionary.Type... types) { + { pattern = "//.*", type = "comment" }, -- Single-line comment + { pattern = { "/%*", "%*/" }, type = "comment" }, -- Multi-line comment + { pattern = { '"', '"', '\\' }, type = "string" }, -- String + { pattern = { "'", "'", '\\' }, type = "string" }, -- String + { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence + { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence + { pattern = "'\\?.'", type = "string" }, -- character literal + { pattern = "-?0x%x+", type = "number" }, -- Number: hexadecimal + { pattern = "-?%d+[%d%.eE]*[fFdD]?", type = "number" }, -- Number: exponential, float/double + { pattern = "%<.-%>%>*", type = "keyword2" }, -- Generic + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operator + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Method + { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, -- Import + { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants + { pattern = "this()%s*.*$", type = { "keyword", "normal" } }, -- FIX: ? + { pattern = "%@%w+", type = "keyword2" }, -- Annotation + { pattern = "%:%:()%w+", type = { "normal", "function" } }, -- Method reference with double colon operator + { pattern = "%.class", type = "normal" }, -- .class should be colored as normal + { pattern = "[%a_][%w_]*", type = "symbol" } -- Symbols }, symbols = { ["abstract"] = "keyword", @@ -136,17 +78,17 @@ syntax.add { ["while"] = "keyword", ["yield"] = "keyword", - ["boolean"] = "keyword2", - ["byte"] = "keyword2", - ["char"] = "keyword2", - ["double"] = "keyword2", - ["float"] = "keyword2", - ["int"] = "keyword2", - ["long"] = "keyword2", - ["short"] = "keyword2", + ["boolean"] = "keyword", + ["byte"] = "keyword", + ["char"] = "keyword", + ["double"] = "keyword", + ["float"] = "keyword", + ["int"] = "keyword", + ["long"] = "keyword", + ["short"] = "keyword", - ["true"] = "literal", - ["false"] = "literal", - ["null"] = "literal" + ["true"] = "literal", + ["false"] = "literal", + ["null"] = "literal" } } From 1527dfd3de497095d85a29fa4b3b9f539b424378 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Thu, 2 Oct 2025 22:45:16 +0200 Subject: [PATCH 55/55] Fixed and added a few more patterns --- plugins/language_kotlin.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/language_kotlin.lua b/plugins/language_kotlin.lua index fd1e1331..1e484a96 100644 --- a/plugins/language_kotlin.lua +++ b/plugins/language_kotlin.lua @@ -18,25 +18,23 @@ syntax.add { { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- Character hexadecimal escape sequence { pattern = "'\\u%x%x%x%x'", type = "string" }, -- Character unicode escape sequence { pattern = "'\\?.'", type = "string" }, -- Character literal + { pattern = "%<.-%>%>*", type = "keyword2" }, -- Generic { pattern = "-?0x%x+", type = "number" }, -- ? { pattern = "-?%d+[%deE]*f?", type = "number" }, -- ? { pattern = "-?%.?%d+f?", type = "number" }, -- ? { regex = [[\-\>(?=\s)]], type = "operator" }, -- Lambda { regex = [[\.{2}\!~|&]", type = "operator" }, -- Operators - { regex = [[\?(?=\.)]], type = "operator" }, -- ?. operator { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Function/Method/Class { regex = [[`[\w_\s]+`(?=\s*\()]], type = "function" }, -- Test Method { regex = [[let(?=\s\{)]], type = "function" }, -- ? operator { regex = [[\?\:(?=\s?)]], type = "operator" }, -- elvis operator { regex = [[this(?=\.?\@?)]], type = "keyword" }, -- this keyword - { pattern = "^%s*%@.+%)", type = "keyword2" }, -- Annotation (at line start) - { regex = [[\s*\@.+\)(?=\s+\w+)]], type = "keyword2" }, -- Annotation (at line middle) - { pattern = "%@%w+", type = "keyword2" }, -- Annotation (like: final @Nullable String something;) + { pattern = "%@[%w%.]+", type = "keyword2" }, -- Annotation { pattern = "^import()%s+()[%w_.]+", type = { "keyword", "normal", "normal" } }, { pattern = "[A-Z][A-Z_%d]+%f[^a-zA-Z_%d]", type = "keyword2" }, -- Constants - { pattern = "[%a_][%w_]*", type = "symbol" }, -- ? - -- TODO: class name reference + { pattern = "%:%s()%w+", type = { "normal", "function" } }, -- Type reference + { pattern = "[%a_][%w_]*", type = "symbol" }, -- Symbols }, symbols = { -- Hard keywords @@ -87,6 +85,7 @@ syntax.add { ["setparam"] = "keyword", ["value"] = "keyword", ["where"] = "keyword", + ["to"] = "keyword", -- Modifier keywords ["abstract"] = "keyword",