From 062655c9d20b69c1f4df3e1b72e2dc08924b6e54 Mon Sep 17 00:00:00 2001 From: 5BNeumann <146111161+5BNeumann@users.noreply.github.com> Date: Mon, 21 Sep 2026 01:39:23 +0200 Subject: [PATCH 1/2] Update nim.yaml to nim 2.0+ Add support for multiline comments and string as well as fix the old single line comments and strings. --- runtime/syntax/nim.yaml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/runtime/syntax/nim.yaml b/runtime/syntax/nim.yaml index 45f73d173b..3b64d55da8 100644 --- a/runtime/syntax/nim.yaml +++ b/runtime/syntax/nim.yaml @@ -17,11 +17,35 @@ rules: - constant.number: "\\b0[ocC][0-7][0-7_]+\\b" - constant.number: "\\b0[bB][01][01_]+\\b" - constant.number: "\\b[0-9_]((\\.?)[0-9_]+)?[eE][+\\-][0-9][0-9_]+\\b" - - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" - - comment: "[[:space:]]*(?:[^\\\\]|^)#.*$" + + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\([\"'abceflnprtv\\\\]|\\d+|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\})" + + - constant.string: + start: "'" + end: "'" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\([\"'abceflnprtv\\\\]|\\d+|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\})" + + - constant.string: + start: "\"\"\"" + end: "\"\"\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\([\"'abceflnprtv\\\\]|\\d+|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\})" + + - comment: + start: "#" + end: "$" + rules: + - todo: "(TODO|FIXME|XXX):?" - comment: start: "\\#\\[" end: "\\]\\#" - rules: [] - - - todo: "(TODO|FIXME|XXX):?" + rules: + - todo: "(TODO|FIXME|XXX):?" From 3a7e88984118e0180b684c0516b6ab62630d1274 Mon Sep 17 00:00:00 2001 From: 5BNeumann Date: Tue, 22 Sep 2026 03:53:55 +0200 Subject: [PATCH 2/2] Fix issues in the updated syntax The muti-line comment is now a raw string (I had support for special chars which shouldn't have been the case) and raw string litterals should work too. (Although I did test them, there might be edge cases I missed) I borrowed more rules from the C syntax to make `'` chars instead of strings. (I honnestly forgot this behavior the first time round) I also fixed multi-line comments by moving the higher up, the single line comment was taking priority on the closing tag which caused issues. --- runtime/syntax/nim.yaml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/runtime/syntax/nim.yaml b/runtime/syntax/nim.yaml index 3b64d55da8..71cc5b47d7 100644 --- a/runtime/syntax/nim.yaml +++ b/runtime/syntax/nim.yaml @@ -20,32 +20,39 @@ rules: - constant.string: start: "\"" - end: "\"" + end: "(\"|$)" skip: "\\\\." rules: - constant.specialChar: "\\\\([\"'abceflnprtv\\\\]|\\d+|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\})" - constant.string: - start: "'" - end: "'" + start: "(r|R)\"" + end: "(\"|$)" skip: "\\\\." - rules: - - constant.specialChar: "\\\\([\"'abceflnprtv\\\\]|\\d+|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\})" + rules: [] - constant.string: start: "\"\"\"" end: "\"\"\"" skip: "\\\\." + rules: [] + + - constant.string: + start: "'" + end: "('|$)" + skip: "\\\\." rules: + - error: "[[:graph:]]{2,}'" - constant.specialChar: "\\\\([\"'abceflnprtv\\\\]|\\d+|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\})" - comment: - start: "#" - end: "$" + start: "#\\[" + end: "\\]#" rules: - todo: "(TODO|FIXME|XXX):?" + - comment: - start: "\\#\\[" - end: "\\]\\#" + start: "#" + end: "$" rules: - todo: "(TODO|FIXME|XXX):?"