From 01686f9d5b33ec3cc9feee37292b3158f336a189 Mon Sep 17 00:00:00 2001 From: Carlo Kok Date: Mon, 1 Mar 2021 21:07:25 +0100 Subject: [PATCH 01/12] lang updates --- src/languages/csharp.js | 6 +- src/languages/go.js | 2 +- src/languages/java.js | 5 +- src/languages/mercury.js | 119 --------------------------------------- src/languages/oxygene.js | 9 +-- src/languages/vbnet.js | 6 +- 6 files changed, 12 insertions(+), 135 deletions(-) delete mode 100644 src/languages/mercury.js diff --git a/src/languages/csharp.js b/src/languages/csharp.js index 636e442a52..2ebd8cf3fb 100644 --- a/src/languages/csharp.js +++ b/src/languages/csharp.js @@ -144,7 +144,9 @@ export default function(hljs) { 'when', 'where', 'with', - 'yield' + 'yield', + "__arglist","__makeref","__reftype","__refvalue","async","await","module","assembly","when","unmanaged","init","record","__autoreleasepool", +"__selector","__weak","__strong","__unretained","__aspect","__mapped","__inline","__extension","__require","__ensure","__result","__old","__invariants" ]; var KEYWORDS = { @@ -235,7 +237,7 @@ export default function(hljs) { return { name: 'C#', - aliases: ['cs', 'c#'], + aliases: ['cs', 'c#', 'hydrogene'], keywords: KEYWORDS, illegal: /::/, contains: [ diff --git a/src/languages/go.js b/src/languages/go.js index 925ad421f4..ce34b757e4 100644 --- a/src/languages/go.js +++ b/src/languages/go.js @@ -21,7 +21,7 @@ export default function(hljs) { }; return { name: 'Go', - aliases: ['golang'], + aliases: ['golang', 'gold'], keywords: GO_KEYWORDS, illegal: ' -Description: Mercury is a logic/functional programming language which combines the clarity and expressiveness of declarative programming with advanced static analysis and error detection features. -Website: https://www.mercurylang.org -*/ - -export default function(hljs) { - const KEYWORDS = { - keyword: - 'module use_module import_module include_module end_module initialise ' + - 'mutable initialize finalize finalise interface implementation pred ' + - 'mode func type inst solver any_pred any_func is semidet det nondet ' + - 'multi erroneous failure cc_nondet cc_multi typeclass instance where ' + - 'pragma promise external trace atomic or_else require_complete_switch ' + - 'require_det require_semidet require_multi require_nondet ' + - 'require_cc_multi require_cc_nondet require_erroneous require_failure', - meta: - // pragma - 'inline no_inline type_spec source_file fact_table obsolete memo ' + - 'loop_check minimal_model terminates does_not_terminate ' + - 'check_termination promise_equivalent_clauses ' + - // preprocessor - 'foreign_proc foreign_decl foreign_code foreign_type ' + - 'foreign_import_module foreign_export_enum foreign_export ' + - 'foreign_enum may_call_mercury will_not_call_mercury thread_safe ' + - 'not_thread_safe maybe_thread_safe promise_pure promise_semipure ' + - 'tabled_for_io local untrailed trailed attach_to_io_state ' + - 'can_pass_as_mercury_type stable will_not_throw_exception ' + - 'may_modify_trail will_not_modify_trail may_duplicate ' + - 'may_not_duplicate affects_liveness does_not_affect_liveness ' + - 'doesnt_affect_liveness no_sharing unknown_sharing sharing', - built_in: - 'some all not if then else true fail false try catch catch_any ' + - 'semidet_true semidet_false semidet_fail impure_true impure semipure' - }; - - const COMMENT = hljs.COMMENT('%', '$'); - - const NUMCODE = { - className: 'number', - begin: "0'.\\|0[box][0-9a-fA-F]*" - }; - - const ATOM = hljs.inherit(hljs.APOS_STRING_MODE, { - relevance: 0 - }); - const STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, { - relevance: 0 - }); - const STRING_FMT = { - className: 'subst', - begin: '\\\\[abfnrtv]\\|\\\\x[0-9a-fA-F]*\\\\\\|%[-+# *.0-9]*[dioxXucsfeEgGp]', - relevance: 0 - }; - STRING.contains = STRING.contains.slice(); // we need our own copy of contains - STRING.contains.push(STRING_FMT); - - const IMPLICATION = { - className: 'built_in', - variants: [ - { - begin: '<=>' - }, - { - begin: '<=', - relevance: 0 - }, - { - begin: '=>', - relevance: 0 - }, - { - begin: '/\\\\' - }, - { - begin: '\\\\/' - } - ] - }; - - const HEAD_BODY_CONJUNCTION = { - className: 'built_in', - variants: [ - { - begin: ':-\\|-->' - }, - { - begin: '=', - relevance: 0 - } - ] - }; - - return { - name: 'Mercury', - aliases: [ - 'm', - 'moo' - ], - keywords: KEYWORDS, - contains: [ - IMPLICATION, - HEAD_BODY_CONJUNCTION, - COMMENT, - hljs.C_BLOCK_COMMENT_MODE, - NUMCODE, - hljs.NUMBER_MODE, - ATOM, - STRING, - { // relevance booster - begin: /:-/ - }, - { // relevance booster - begin: /\.$/ - } - ] - }; -} diff --git a/src/languages/oxygene.js b/src/languages/oxygene.js index 6eaef0d295..01fc2120ab 100644 --- a/src/languages/oxygene.js +++ b/src/languages/oxygene.js @@ -9,14 +9,7 @@ export default function(hljs) { const OXYGENE_KEYWORDS = { $pattern: /\.?\w+/, keyword: - 'abstract add and array as asc aspect assembly async begin break block by case class concat const copy constructor continue ' + - 'create default delegate desc distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false ' + - 'final finalize finalizer finally flags for forward from function future global group has if implementation implements implies in index inherited ' + - 'inline interface into invariants is iterator join locked locking loop matching method mod module namespace nested new nil not notify nullable of ' + - 'old on operator or order out override parallel params partial pinned private procedure property protected public queryable raise read readonly ' + - 'record reintroduce remove repeat require result reverse sealed select self sequence set shl shr skip static step soft take then to true try tuple ' + - 'type union unit unsafe until uses using var virtual raises volatile where while with write xor yield await mapped deprecated stdcall cdecl pascal ' + - 'register safecall overload library platform reference packed strict published autoreleasepool selector strong weak unretained' + "absolute abstract add and array as asc asm aspect assembler assembly async at autoreleasepool await begin block break by case cdecl class const constructor continue copy create default delegate deprecated desc destructor distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false file final finalization finalize finalizer finally flags for forward from function future global goto group has helper if implementation implements implies in index inherited initialization inline interface into invariants is iterator join label lazy library lifetimestrategy locked locking loop mapped matching method mod module namespace nested new nil not notify nullable of old on operator optional or order otherwise out overload override packed parallel param params partial pascal pinned platform private procedure program property protected public published queryable raise raises read readonly record reference register reintroduce remove repeat require resourcestring result reverse safecall sealed select selector self sequence set shl shr skip soft static stdcall step strict strong take then threadvar to true try tuple type unit unretained unsafe until uses using var virtual volatile weak where while with write xor yield " }; const CURLY_COMMENT = hljs.COMMENT( /\{/, diff --git a/src/languages/vbnet.js b/src/languages/vbnet.js index 1933ac1b4d..f7932f49bf 100644 --- a/src/languages/vbnet.js +++ b/src/languages/vbnet.js @@ -133,7 +133,7 @@ export default function(hljs) { return { name: 'Visual Basic .NET', - aliases: [ 'vb' ], + aliases: [ 'vb', 'mercury' ], case_insensitive: true, classNameAliases: { label: 'symbol' @@ -142,13 +142,13 @@ export default function(hljs) { keyword: 'addhandler alias aggregate ansi as async assembly auto binary by byref byval ' + /* a-b */ 'call case catch class compare const continue custom declare default delegate dim distinct do ' + /* c-d */ - 'each equals else elseif end enum erase error event exit explicit finally for friend from function ' + /* e-f */ + 'each equals else elseif end mapped enum erase error event exit explicit finally for friend from function ' + /* e-f */ 'get global goto group handles if implements imports in inherits interface into iterator ' + /* g-i */ 'join key let lib loop me mid module mustinherit mustoverride mybase myclass ' + /* j-m */ 'namespace narrowing new next notinheritable notoverridable ' + /* n */ 'of off on operator option optional order overloads overridable overrides ' + /* o */ 'paramarray partial preserve private property protected public ' + /* p */ - 'raiseevent readonly redim removehandler resume return ' + /* r */ + 'raiseevent readonly redim removehandler resume return mappedto mymapped ' + /* r */ 'select set shadows shared skip static step stop structure strict sub synclock ' + /* s */ 'take text then throw to try unicode until using when where while widening with withevents writeonly yield' /* t-y */, built_in: From 2fa634be2e997a1feb207bee35977607192ae39c Mon Sep 17 00:00:00 2001 From: Carlo Kok Date: Wed, 16 Feb 2022 14:38:22 +0100 Subject: [PATCH 02/12] Langupdates --- src/languages/oxygene.js | 2 +- src/languages/vbnet.js | 22 ++-------------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/languages/oxygene.js b/src/languages/oxygene.js index a3d6c34b68..95c353d101 100644 --- a/src/languages/oxygene.js +++ b/src/languages/oxygene.js @@ -9,7 +9,7 @@ export default function(hljs) { const OXYGENE_KEYWORDS = { $pattern: /\.?\w+/, keyword: - "absolute abstract add and array as asc asm aspect assembler assembly async at autoreleasepool await begin block break by case cdecl class const constructor continue copy create default delegate deprecated desc destructor distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false file final finalization finalize finalizer finally flags for forward from function future global goto group has helper if implementation implements implies in index inherited initialization inline interface into invariants is iterator join label lazy library lifetimestrategy locked locking loop mapped matching method mod module namespace nested new nil not notify nullable of old on operator optional or order otherwise out overload override packed parallel param params partial pascal pinned platform private procedure program property protected public published queryable raise raises read readonly record reference register reintroduce remove repeat require resourcestring result reverse safecall sealed select selector self sequence set shl shr skip soft static stdcall step strict strong take then threadvar to true try tuple type unit unretained unsafe until uses using var virtual volatile weak where while with write xor yield " + "absolute abstract add and array as asc asm aspect assembler assembly async at autoreleasepool await begin block break by case cdecl class const constructor continue copy create default delegate deprecated desc destructor distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false file final finalization finalize finalizer finally flags for forward from function future global goto group has helper if implementation implements implies in index inherited initialization inline interface into invariants is iterator join label lazy library lifetimestrategy locked locking loop mapped matching method mod module namespace nested new nil not notify nullable of old on operator optional or order otherwise out overload override packed parallel param params partial pascal pinned platform private procedure program property protected public published queryable raise raises read readonly record reference register reintroduce remove repeat require resourcestring result reverse safecall sealed select selector self sequence set shl shr skip soft static stdcall step strict strong take then threadvar to true try tuple type unconstrained unit unmanaged unretained unsafe until uses using var virtual volatile weak where while with write xor yield " }; const CURLY_COMMENT = hljs.COMMENT( /\{/, diff --git a/src/languages/vbnet.js b/src/languages/vbnet.js index 193fe84d16..dd187cd5c1 100644 --- a/src/languages/vbnet.js +++ b/src/languages/vbnet.js @@ -139,26 +139,8 @@ export default function(hljs) { }, keywords: { keyword: - 'addhandler alias aggregate ansi as async assembly auto binary by byref byval ' + /* a-b */ - 'call case catch class compare const continue custom declare default delegate dim distinct do ' + /* c-d */ - 'each equals else elseif end mapped enum erase error event exit explicit finally for friend from function ' + /* e-f */ - 'get global goto group handles if implements imports in inherits interface into iterator ' + /* g-i */ - 'join key let lib loop me mid module mustinherit mustoverride mybase myclass ' + /* j-m */ - 'namespace narrowing new next notinheritable notoverridable ' + /* n */ - 'of off on operator option optional order overloads overridable overrides ' + /* o */ - 'paramarray partial preserve private property protected public ' + /* p */ - 'raiseevent readonly redim removehandler resume return mappedto mymapped ' + /* r */ - 'select set shadows shared skip static step stop structure strict sub synclock ' + /* s */ - 'take text then throw to try unicode until using when where while widening with withevents writeonly yield' /* t-y */, - built_in: - // Operators https://docs.microsoft.com/dotnet/visual-basic/language-reference/operators - 'addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor ' + - // Type Conversion Functions https://docs.microsoft.com/dotnet/visual-basic/language-reference/functions/type-conversion-functions - 'cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort', - type: - // Data types https://docs.microsoft.com/dotnet/visual-basic/language-reference/data-types - 'boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort', - literal: 'true false nothing' + 'addhandler addressof alias and andalso ansi as ascending assembly async auto autoreleasepool await boolean by byref byte byval call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj const continue csbyte cshort csng cstr ctrytype ctype cuint culng cushort custom decimal declare default delegate descending dim directcast distinct do double dynamic each else elseif end endif enum equals erase error event exit extends false finally for friend from function get gettype getxmlnamespace global gosub goto group handles if implements imports in index inherits integer interface into is isfalse isnot istrue iterator join key lazy let lib like long loop mappedto matching me mod module mustinherit mustoverride mybase myclass mymapped namespace namespace narrowing new next not nothing notinheritable notoverridable null object of on operator option optional or order orelse out overloads overridable overrides paramarray partial preserve private property protected ptr public raiseevent readonly record redim rem removehandler resume return sbyte select set shadows shared short single skip static step stop string structure sub synclock take then throw to true try trycast typeof uinteger ulong unicode unmanaged unsafe until ushort using variant wend when where while widening with withevents writeonly xor yield zip ' + }, illegal: '//|\\{|\\}|endif|gosub|variant|wend|^\\$ ' /* reserved deprecated keywords */, From 9162483048fd764572e727ed67c167d5a1b5bea8 Mon Sep 17 00:00:00 2001 From: Carlo Kok Date: Fri, 25 Feb 2022 19:59:43 +0100 Subject: [PATCH 03/12] vb keywords --- src/languages/vbnet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/vbnet.js b/src/languages/vbnet.js index dd187cd5c1..216a5cc8fb 100644 --- a/src/languages/vbnet.js +++ b/src/languages/vbnet.js @@ -139,7 +139,7 @@ export default function(hljs) { }, keywords: { keyword: - 'addhandler addressof alias and andalso ansi as ascending assembly async auto autoreleasepool await boolean by byref byte byval call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj const continue csbyte cshort csng cstr ctrytype ctype cuint culng cushort custom decimal declare default delegate descending dim directcast distinct do double dynamic each else elseif end endif enum equals erase error event exit extends false finally for friend from function get gettype getxmlnamespace global gosub goto group handles if implements imports in index inherits integer interface into is isfalse isnot istrue iterator join key lazy let lib like long loop mappedto matching me mod module mustinherit mustoverride mybase myclass mymapped namespace namespace narrowing new next not nothing notinheritable notoverridable null object of on operator option optional or order orelse out overloads overridable overrides paramarray partial preserve private property protected ptr public raiseevent readonly record redim rem removehandler resume return sbyte select set shadows shared short single skip static step stop string structure sub synclock take then throw to true try trycast typeof uinteger ulong unicode unmanaged unsafe until ushort using variant wend when where while widening with withevents writeonly xor yield zip ' + 'Ensure Check Invariants Old Require addhandler addressof alias and andalso ansi as ascending assembly async auto autoreleasepool await boolean by byref byte byval call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj const continue csbyte cshort csng cstr ctrytype ctype cuint culng cushort custom decimal declare default delegate descending dim directcast distinct do double dynamic each else elseif end endif enum equals erase error event exit extends false finally for friend from function get gettype getxmlnamespace global gosub goto group handles if implements imports in index inherits integer interface into is isfalse isnot istrue iterator join key lazy let lib like long loop mappedto matching me mod module mustinherit mustoverride mybase myclass mymapped namespace namespace narrowing new next not nothing notinheritable notoverridable null object of on operator option optional or order orelse out overloads overridable overrides paramarray partial preserve private property protected ptr public raiseevent readonly record redim rem removehandler resume return sbyte select set shadows shared short single skip static step stop string structure sub synclock take then throw to true try trycast typeof uinteger ulong unicode unmanaged unsafe until ushort using variant wend when where while widening with withevents writeonly xor yield zip ' }, illegal: From 07f6ac526b4b5ed8150f2ba3335d36d66ae100b2 Mon Sep 17 00:00:00 2001 From: Carlo Kok Date: Fri, 25 Feb 2022 20:11:43 +0100 Subject: [PATCH 04/12] go --- build.bat | 1 + src/languages/lib/kws_swift.js | 2 ++ src/languages/swift.js | 1 + src/languages/vbnet.js | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 build.bat diff --git a/build.bat b/build.bat new file mode 100644 index 0000000000..9cc6754065 --- /dev/null +++ b/build.bat @@ -0,0 +1 @@ +node tools/build.js -t browser diff --git a/src/languages/lib/kws_swift.js b/src/languages/lib/kws_swift.js index be06394ba8..6e8d614655 100644 --- a/src/languages/lib/kws_swift.js +++ b/src/languages/lib/kws_swift.js @@ -32,6 +32,8 @@ export const keywords = [ // strings below will be fed into the regular `keywords` engine while regex // will result in additional modes being created to scan for those keywords to // avoid conflicts with other rules + '__abstract', '__await', '__catch', '__COLUMN__', '__event', '__external', '__FILE__',, '__ensure', '__field', '__invariants', '__lock', '__old', '__reintroduce', '__require__result', '__using', + '__finally', '__FUNCTION__', '__inline', '__LINE__', '__mapped', '__out', '__partial', '__throw', '__try', '__yield', 'as', 'as!', 'as?', 'associativity', 'actor', 'associatedtype', 'async', diff --git a/src/languages/swift.js b/src/languages/swift.js index 15fb39c9e9..a205d9a346 100644 --- a/src/languages/swift.js +++ b/src/languages/swift.js @@ -465,6 +465,7 @@ export default function(hljs) { return { name: 'Swift', + aliases: ['silver'], keywords: KEYWORDS, contains: [ ...COMMENTS, diff --git a/src/languages/vbnet.js b/src/languages/vbnet.js index 216a5cc8fb..b769f13e32 100644 --- a/src/languages/vbnet.js +++ b/src/languages/vbnet.js @@ -139,7 +139,7 @@ export default function(hljs) { }, keywords: { keyword: - 'Ensure Check Invariants Old Require addhandler addressof alias and andalso ansi as ascending assembly async auto autoreleasepool await boolean by byref byte byval call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj const continue csbyte cshort csng cstr ctrytype ctype cuint culng cushort custom decimal declare default delegate descending dim directcast distinct do double dynamic each else elseif end endif enum equals erase error event exit extends false finally for friend from function get gettype getxmlnamespace global gosub goto group handles if implements imports in index inherits integer interface into is isfalse isnot istrue iterator join key lazy let lib like long loop mappedto matching me mod module mustinherit mustoverride mybase myclass mymapped namespace namespace narrowing new next not nothing notinheritable notoverridable null object of on operator option optional or order orelse out overloads overridable overrides paramarray partial preserve private property protected ptr public raiseevent readonly record redim rem removehandler resume return sbyte select set shadows shared short single skip static step stop string structure sub synclock take then throw to true try trycast typeof uinteger ulong unicode unmanaged unsafe until ushort using variant wend when where while widening with withevents writeonly xor yield zip ' + 'ensure check invariants old require addhandler addressof alias and andalso ansi as ascending assembly async auto autoreleasepool await boolean by byref byte byval call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj const continue csbyte cshort csng cstr ctrytype ctype cuint culng cushort custom decimal declare default delegate descending dim directcast distinct do double dynamic each else elseif end endif enum equals erase error event exit extends false finally for friend from function get gettype getxmlnamespace global gosub goto group handles if implements imports in index inherits integer interface into is isfalse isnot istrue iterator join key lazy let lib like long loop mappedto matching me mod module mustinherit mustoverride mybase myclass mymapped namespace namespace narrowing new next not nothing notinheritable notoverridable null object of on operator option optional or order orelse out overloads overridable overrides paramarray partial preserve private property protected ptr public raiseevent readonly record redim rem removehandler resume return sbyte select set shadows shared short single skip static step stop string structure sub synclock take then throw to true try trycast typeof uinteger ulong unicode unmanaged unsafe until ushort using variant wend when where while widening with withevents writeonly xor yield zip ' }, illegal: From ef252f489172edb49c73da6e92440e9e325a5900 Mon Sep 17 00:00:00 2001 From: marc hoffman Date: Sat, 10 Jan 2026 10:01:24 -0400 Subject: [PATCH 05/12] Oxygene: latest keywords --- src/languages/oxygene.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/oxygene.js b/src/languages/oxygene.js index 95c353d101..a9802668c4 100644 --- a/src/languages/oxygene.js +++ b/src/languages/oxygene.js @@ -9,7 +9,7 @@ export default function(hljs) { const OXYGENE_KEYWORDS = { $pattern: /\.?\w+/, keyword: - "absolute abstract add and array as asc asm aspect assembler assembly async at autoreleasepool await begin block break by case cdecl class const constructor continue copy create default delegate deprecated desc destructor distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false file final finalization finalize finalizer finally flags for forward from function future global goto group has helper if implementation implements implies in index inherited initialization inline interface into invariants is iterator join label lazy library lifetimestrategy locked locking loop mapped matching method mod module namespace nested new nil not notify nullable of old on operator optional or order otherwise out overload override packed parallel param params partial pascal pinned platform private procedure program property protected public published queryable raise raises read readonly record reference register reintroduce remove repeat require resourcestring result reverse safecall sealed select selector self sequence set shl shr skip soft static stdcall step strict strong take then threadvar to true try tuple type unconstrained unit unmanaged unretained unsafe until uses using var virtual volatile weak where while with write xor yield " + "abstract add and array as asc asm aspect assembly async autoreleasepool await begin block break by case cdecl class const constructor continue copy create default delegate deprecated desc destructor distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false final finalization finalize finalizer finally flags for forward from function future global goto group has helper if implementation implements implies in index inherited initialization inline interface into invariants is iterator join lazy library lifetimestrategy locked locking loop mapped matching method mod module namespace nested new nil not notify nullable of old on operator optional or order otherwise out overload override packed parallel param params partial pascal pinned platform private procedure property protected public published queryable raise raises read readonly record reference register reintroduce remove repeat require required result reverse safecall sealed select selector self sequence set shl shr skip soft static stdcall step strict strong take then to true try tuple type unconstrained unit unmanaged unretained unsafe until uses using var virtual volatile weak where while with write xor yield " }; const CURLY_COMMENT = hljs.COMMENT( /\{/, From f697d8d840de1ba273782e2fc77149330af13a62 Mon Sep 17 00:00:00 2001 From: marc hoffman Date: Wed, 11 Feb 2026 16:45:39 -0400 Subject: [PATCH 06/12] Update Oxygene keywords to include 'field' --- src/languages/oxygene.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/oxygene.js b/src/languages/oxygene.js index a9802668c4..684a027e16 100644 --- a/src/languages/oxygene.js +++ b/src/languages/oxygene.js @@ -9,7 +9,7 @@ export default function(hljs) { const OXYGENE_KEYWORDS = { $pattern: /\.?\w+/, keyword: - "abstract add and array as asc asm aspect assembly async autoreleasepool await begin block break by case cdecl class const constructor continue copy create default delegate deprecated desc destructor distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false final finalization finalize finalizer finally flags for forward from function future global goto group has helper if implementation implements implies in index inherited initialization inline interface into invariants is iterator join lazy library lifetimestrategy locked locking loop mapped matching method mod module namespace nested new nil not notify nullable of old on operator optional or order otherwise out overload override packed parallel param params partial pascal pinned platform private procedure property protected public published queryable raise raises read readonly record reference register reintroduce remove repeat require required result reverse safecall sealed select selector self sequence set shl shr skip soft static stdcall step strict strong take then to true try tuple type unconstrained unit unmanaged unretained unsafe until uses using var virtual volatile weak where while with write xor yield " + "abstract add and array as asc asm aspect assembly async autoreleasepool await begin block break by case cdecl class const constructor continue copy create default delegate deprecated desc destructor distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false field final finalization finalize finalizer finally flags for forward from function future global goto group has helper if implementation implements implies in index inherited initialization inline interface into invariants is iterator join lazy library lifetimestrategy locked locking loop mapped matching method mod module namespace nested new nil not notify nullable of old on operator optional or order otherwise out overload override packed parallel param params partial pascal pinned platform private procedure property protected public published queryable raise raises read readonly record reference register reintroduce remove repeat require required result reverse safecall sealed select selector self sequence set shl shr skip soft static stdcall step strict strong take then to true try tuple type unconstrained unit unmanaged unretained unsafe until uses using var virtual volatile weak where while with write xor yield " }; const CURLY_COMMENT = hljs.COMMENT( /\{/, From e9da31f752791be2c43fe81afc0c73cfcd25698e Mon Sep 17 00:00:00 2001 From: Iamfittz Date: Tue, 17 Feb 2026 10:58:05 +0200 Subject: [PATCH 07/12] Separate csharp and hydrogene into separate highlighters. --- src/languages/csharp.js | 10 +- src/languages/hydrogene.js | 463 +++++++++++++++++++++++++++++++++++++ 2 files changed, 470 insertions(+), 3 deletions(-) create mode 100644 src/languages/hydrogene.js diff --git a/src/languages/csharp.js b/src/languages/csharp.js index f81856136c..5fbb1b414a 100644 --- a/src/languages/csharp.js +++ b/src/languages/csharp.js @@ -146,8 +146,12 @@ export default function(hljs) { 'where', 'with', 'yield', - "__arglist","__makeref","__reftype","__refvalue","async","await","module","assembly","when","unmanaged","init","record","__autoreleasepool", -"__selector","__weak","__strong","__unretained","__aspect","__mapped","__inline","__extension","__require","__ensure","__result","__old","__invariants" + '__arglist', + '__makeref', + '__reftype', + '__refvalue', + 'module', + 'assembly' ]; const KEYWORDS = { @@ -293,7 +297,7 @@ export default function(hljs) { return { name: 'C#', - aliases: ['cs', 'c#', 'hydrogene'], + aliases: ['cs', 'c#'], keywords: KEYWORDS, illegal: /::/, contains: [ diff --git a/src/languages/hydrogene.js b/src/languages/hydrogene.js new file mode 100644 index 0000000000..3ac3aaf5e0 --- /dev/null +++ b/src/languages/hydrogene.js @@ -0,0 +1,463 @@ +/* +Language: Hydrogene +Author: Carlo Kok +Contributor: Jason Diamond , Nicolas LLOBERA , Pieter Vantorre , David Pine +Description: Hydrogene is RemObjects Software's C#-compatible language for the Elements compiler, with additional platform-specific extensions. +Website: https://www.elementscompiler.com/elements/hydrogene/ +*/ + +/** @type LanguageFn */ +export default function(hljs) { + const BUILT_IN_KEYWORDS = [ + 'bool', + 'byte', + 'char', + 'decimal', + 'delegate', + 'double', + 'dynamic', + 'enum', + 'float', + 'int', + 'long', + 'nint', + 'nuint', + 'object', + 'sbyte', + 'short', + 'string', + 'ulong', + 'uint', + 'ushort' + ]; + const FUNCTION_MODIFIERS = [ + 'public', + 'private', + 'protected', + 'static', + 'internal', + 'protected', + 'abstract', + 'async', + 'extern', + 'override', + 'unsafe', + 'virtual', + 'new', + 'sealed', + 'partial' + ]; + const LITERAL_KEYWORDS = [ + 'default', + 'false', + 'null', + 'true' + ]; + const NORMAL_KEYWORDS = [ + 'abstract', + 'as', + 'base', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'do', + 'else', + 'event', + 'explicit', + 'extern', + 'finally', + 'fixed', + 'for', + 'foreach', + 'goto', + 'if', + 'implicit', + 'in', + 'interface', + 'internal', + 'is', + 'lock', + 'namespace', + 'new', + 'operator', + 'out', + 'override', + 'params', + 'private', + 'protected', + 'public', + 'readonly', + 'record', + 'ref', + 'return', + 'sealed', + 'sizeof', + 'stackalloc', + 'static', + 'struct', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'unchecked', + 'unsafe', + 'using', + 'virtual', + 'void', + 'volatile', + 'while' + ]; + const CONTEXTUAL_KEYWORDS = [ + 'add', + 'alias', + 'and', + 'ascending', + 'async', + 'await', + 'by', + 'descending', + 'equals', + 'from', + 'get', + 'global', + 'group', + 'init', + 'into', + 'join', + 'let', + 'nameof', + 'not', + 'notnull', + 'on', + 'or', + 'orderby', + 'partial', + 'remove', + 'select', + 'set', + 'unmanaged', + 'value|0', + 'var', + 'when', + 'where', + 'with', + 'yield', + '__arglist', + '__makeref', + '__reftype', + '__refvalue', + 'module', + 'assembly' + ]; + // RemObjects Elements-specific extensions + const ELEMENTS_KEYWORDS = [ + '__autoreleasepool', + '__selector', + '__weak', + '__strong', + '__unretained', + '__aspect', + '__mapped', + '__inline', + '__extension', + '__require', + '__ensure', + '__result', + '__old', + '__invariants' + ]; + + const KEYWORDS = { + keyword: NORMAL_KEYWORDS.concat(CONTEXTUAL_KEYWORDS).concat(ELEMENTS_KEYWORDS), + built_in: BUILT_IN_KEYWORDS, + literal: LITERAL_KEYWORDS + }; + const TITLE_MODE = hljs.inherit(hljs.TITLE_MODE, { + begin: '[a-zA-Z](\\.?\\w)*' + }); + const NUMBERS = { + className: 'number', + variants: [ + { + begin: '\\b(0b[01\']+)' + }, + { + begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)(u|U|l|L|ul|UL|f|F|b|B)' + }, + { + begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)' + } + ], + relevance: 0 + }; + const VERBATIM_STRING = { + className: 'string', + begin: '@"', + end: '"', + contains: [ + { + begin: '""' + } + ] + }; + const VERBATIM_STRING_NO_LF = hljs.inherit(VERBATIM_STRING, { + illegal: /\n/ + }); + const SUBST = { + className: 'subst', + begin: /\{/, + end: /\}/, + keywords: KEYWORDS + }; + const SUBST_NO_LF = hljs.inherit(SUBST, { + illegal: /\n/ + }); + const INTERPOLATED_STRING = { + className: 'string', + begin: /\$"/, + end: '"', + illegal: /\n/, + contains: [ + { + begin: /\{\{/ + }, + { + begin: /\}\}/ + }, + hljs.BACKSLASH_ESCAPE, + SUBST_NO_LF + ] + }; + const INTERPOLATED_VERBATIM_STRING = { + className: 'string', + begin: /\$@"/, + end: '"', + contains: [ + { + begin: /\{\{/ + }, + { + begin: /\}\}/ + }, + { + begin: '""' + }, + SUBST + ] + }; + const INTERPOLATED_VERBATIM_STRING_NO_LF = hljs.inherit(INTERPOLATED_VERBATIM_STRING, { + illegal: /\n/, + contains: [ + { + begin: /\{\{/ + }, + { + begin: /\}\}/ + }, + { + begin: '""' + }, + SUBST_NO_LF + ] + }); + SUBST.contains = [ + INTERPOLATED_VERBATIM_STRING, + INTERPOLATED_STRING, + VERBATIM_STRING, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + NUMBERS, + hljs.C_BLOCK_COMMENT_MODE + ]; + SUBST_NO_LF.contains = [ + INTERPOLATED_VERBATIM_STRING_NO_LF, + INTERPOLATED_STRING, + VERBATIM_STRING_NO_LF, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + NUMBERS, + hljs.inherit(hljs.C_BLOCK_COMMENT_MODE, { + illegal: /\n/ + }) + ]; + const STRING = { + variants: [ + INTERPOLATED_VERBATIM_STRING, + INTERPOLATED_STRING, + VERBATIM_STRING, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE + ] + }; + + const GENERIC_MODIFIER = { + begin: "<", + end: ">", + contains: [ + { + beginKeywords: "in out" + }, + TITLE_MODE + ] + }; + const TYPE_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '(\\s*,\\s*' + hljs.IDENT_RE + ')*>)?(\\[\\])?'; + const AT_IDENTIFIER = { + // prevents expressions like `@class` from incorrect flagging + // `class` as a keyword + begin: "@" + hljs.IDENT_RE, + relevance: 0 + }; + + return { + name: 'Hydrogene', + aliases: ['hydrogene'], + keywords: KEYWORDS, + illegal: /::/, + contains: [ + hljs.COMMENT( + '///', + '$', + { + returnBegin: true, + contains: [ + { + className: 'doctag', + variants: [ + { + begin: '///', + relevance: 0 + }, + { + begin: '' + }, + { + begin: '' + } + ] + } + ] + } + ), + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE, + { + className: 'meta', + begin: '#', + end: '$', + keywords: { + keyword: 'if else elif endif define undef warning error line region endregion pragma checksum' + } + }, + STRING, + NUMBERS, + { + beginKeywords: 'class interface', + relevance: 0, + end: /[{;=]/, + illegal: /[^\s:,]/, + contains: [ + { + beginKeywords: "where class" + }, + TITLE_MODE, + GENERIC_MODIFIER, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE + ] + }, + { + beginKeywords: 'namespace', + relevance: 0, + end: /[{;=]/, + illegal: /[^\s:]/, + contains: [ + TITLE_MODE, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE + ] + }, + { + beginKeywords: 'record', + relevance: 0, + end: /[{;=]/, + illegal: /[^\s:]/, + contains: [ + TITLE_MODE, + GENERIC_MODIFIER, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE + ] + }, + { + // [Attributes("")] + className: 'meta', + begin: '^\\s*\\[(?=[\\w])', + excludeBegin: true, + end: '\\]', + excludeEnd: true, + contains: [ + { + className: 'string', + begin: /"/, + end: /"/ + } + ] + }, + { + // Expression keywords prevent 'keyword Name(...)' from being + // recognized as a function definition + beginKeywords: 'new return throw await else', + relevance: 0 + }, + { + className: 'function', + begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*(<[^=]+>\\s*)?\\(', + returnBegin: true, + end: /\s*[{;=]/, + excludeEnd: true, + keywords: KEYWORDS, + contains: [ + // prevents these from being highlighted `title` + { + beginKeywords: FUNCTION_MODIFIERS.join(" "), + relevance: 0 + }, + { + begin: hljs.IDENT_RE + '\\s*(<[^=]+>\\s*)?\\(', + returnBegin: true, + contains: [ + hljs.TITLE_MODE, + GENERIC_MODIFIER + ], + relevance: 0 + }, + { + match: /\(\)/ + }, + { + className: 'params', + begin: /\(/, + end: /\)/, + excludeBegin: true, + excludeEnd: true, + keywords: KEYWORDS, + relevance: 0, + contains: [ + STRING, + NUMBERS, + hljs.C_BLOCK_COMMENT_MODE + ] + }, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE + ] + }, + AT_IDENTIFIER + ] + }; +} From 733e2d3bcd1252541b49900a74e8c8a23dd2b5d5 Mon Sep 17 00:00:00 2001 From: Iamfittz Date: Wed, 18 Feb 2026 20:10:15 +0200 Subject: [PATCH 08/12] Extract Elements languages into separate highlighters: gold, iodine, vbmercury. --- src/languages/go.js | 2 +- src/languages/gold.js | 139 ++++++++++++++++++ src/languages/iodine.js | 284 +++++++++++++++++++++++++++++++++++++ src/languages/java.js | 7 +- src/languages/vbmercury.js | 157 ++++++++++++++++++++ src/languages/vbnet.js | 4 +- 6 files changed, 585 insertions(+), 8 deletions(-) create mode 100644 src/languages/gold.js create mode 100644 src/languages/iodine.js create mode 100644 src/languages/vbmercury.js diff --git a/src/languages/go.js b/src/languages/go.js index 2e3b766eac..870c9cd5e5 100644 --- a/src/languages/go.js +++ b/src/languages/go.js @@ -88,7 +88,7 @@ export default function(hljs) { }; return { name: 'Go', - aliases: ['golang', 'gold'], + aliases: ['golang'], keywords: KEYWORDS, illegal: ' +Contributor: Stephan Kountso aka StepLg , Evgeny Stepanischev +Description: Gold is RemObjects Software's Go-compatible language for the Elements compiler. +Website: https://www.elementscompiler.com/elements/gold/ +*/ + +export default function(hljs) { + const LITERALS = [ + "true", + "false", + "iota", + "nil" + ]; + const BUILT_INS = [ + "append", + "cap", + "close", + "complex", + "copy", + "imag", + "len", + "make", + "new", + "panic", + "print", + "println", + "real", + "recover", + "delete" + ]; + const TYPES = [ + "bool", + "byte", + "complex64", + "complex128", + "error", + "float32", + "float64", + "int8", + "int16", + "int32", + "int64", + "string", + "uint8", + "uint16", + "uint32", + "uint64", + "int", + "uint", + "uintptr", + "rune" + ]; + const KWS = [ + "break", + "case", + "chan", + "const", + "continue", + "default", + "defer", + "else", + "fallthrough", + "for", + "func", + "go", + "goto", + "if", + "import", + "interface", + "map", + "package", + "range", + "return", + "select", + "struct", + "switch", + "type", + "var", + ]; + const KEYWORDS = { + keyword: KWS, + type: TYPES, + literal: LITERALS, + built_in: BUILT_INS + }; + return { + name: 'Gold', + aliases: ['gold'], + keywords: KEYWORDS, + illegal: ' +Contributor: Vsevolod Solovyov +Description: Iodine is RemObjects Software's Java-compatible language for the Elements compiler. +Website: https://www.elementscompiler.com/elements/iodine/ +*/ + +import { + NUMERIC as NUMBER +} from "./lib/java.js"; + +/** + * Allows recursive regex expressions to a given depth + * + * ie: recurRegex("(abc~~~)", /~~~/g, 2) becomes: + * (abc(abc(abc))) + * + * @param {string} re + * @param {RegExp} substitution (should be a g mode regex) + * @param {number} depth + * @returns {string}`` + */ +function recurRegex(re, substitution, depth) { + if (depth === -1) return ""; + + return re.replace(substitution, _ => { + return recurRegex(re, substitution, depth - 1); + }); +} + +/** @type LanguageFn */ +export default function(hljs) { + const regex = hljs.regex; + const JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*'; + const GENERIC_IDENT_RE = JAVA_IDENT_RE + + recurRegex('(?:<' + JAVA_IDENT_RE + '~~~(?:\\s*,\\s*' + JAVA_IDENT_RE + '~~~)*>)?', /~~~/g, 2); + const MAIN_KEYWORDS = [ + 'synchronized', + 'abstract', + 'private', + 'var', + 'static', + 'if', + 'const ', + 'for', + 'while', + 'strictfp', + 'finally', + 'protected', + 'import', + 'native', + 'final', + 'void', + 'enum', + 'else', + 'break', + 'transient', + 'catch', + 'instanceof', + 'volatile', + 'case', + 'assert', + 'package', + 'default', + 'public', + 'try', + 'switch', + 'continue', + 'throws', + 'protected', + 'public', + 'private', + 'module', + 'requires', + 'exports', + 'do', + 'sealed', + // RemObjects Elements extensions + '__aspect', + '__assembly', + '__module', + '__extension', + '__partial', + '__out', + '__ref', + '__struct', + '__mapped', + '__get', + '__set', + '__block', + '__strong', + '__weak', + '__unretained', + '__selector', + '__require', + '__ensure', + '__result', + '__old', + '__invariants', + '__autoreleasepool', + '__event', + '__add', + '__remove' + ]; + + const BUILT_INS = [ + 'super', + 'this' + ]; + + const LITERALS = [ + 'false', + 'true', + 'null' + ]; + + const TYPES = [ + 'char', + 'boolean', + 'long', + 'float', + 'int', + 'byte', + 'short', + 'double' + ]; + + const KEYWORDS = { + keyword: MAIN_KEYWORDS, + literal: LITERALS, + type: TYPES, + built_in: BUILT_INS + }; + + const ANNOTATION = { + className: 'meta', + begin: '@' + JAVA_IDENT_RE, + contains: [ + { + begin: /\(/, + end: /\)/, + contains: [ "self" ] // allow nested () inside our annotation + } + ] + }; + const PARAMS = { + className: 'params', + begin: /\(/, + end: /\)/, + keywords: KEYWORDS, + relevance: 0, + contains: [ + hljs.C_BLOCK_COMMENT_MODE + ], + endsParent: true + }; + + return { + name: 'Iodine', + aliases: ['iodine'], + keywords: KEYWORDS, + illegal: /<\/|#/, + contains: [ + hljs.COMMENT( + '/\\*\\*', + '\\*/', + { + relevance: 0, + contains: [ + { + // eat up @'s in emails to prevent them to be recognized as doctags + begin: /\w+@/, + relevance: 0 + }, + { + className: 'doctag', + begin: '@[A-Za-z]+' + } + ] + } + ), + // relevance boost + { + begin: /import java\.[a-z]+\./, + keywords: "import", + relevance: 2 + }, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE, + { + begin: /"""/, + end: /"""/, + className: "string", + contains: [hljs.BACKSLASH_ESCAPE] + }, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + { + match: [ + /\b(?:class|interface|enum|extends|implements|new)/, + /\s+/, + JAVA_IDENT_RE + ], + className: { + 1: "keyword", + 3: "title.class" + } + }, + { + // Exceptions for hyphenated keywords + match: /non-sealed/, + scope: "keyword" + }, + { + begin: [ + regex.concat(/(?!else)/, JAVA_IDENT_RE), + /\s+/, + JAVA_IDENT_RE, + /\s+/, + /=/ + ], + className: { + 1: "type", + 3: "variable", + 5: "operator" + } + }, + { + begin: [ + /record/, + /\s+/, + JAVA_IDENT_RE + ], + className: { + 1: "keyword", + 3: "title.class" + }, + contains: [ + PARAMS, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE + ] + }, + { + // Expression keywords prevent 'keyword Name(...)' from being + // recognized as a function definition + beginKeywords: 'new throw return else', + relevance: 0 + }, + { + begin: [ + '(?:' + GENERIC_IDENT_RE + '\\s+)', + hljs.UNDERSCORE_IDENT_RE, + /\s*(?=\()/ + ], + className: { + 2: "title.function" + }, + keywords: KEYWORDS, + contains: [ + { + className: 'params', + begin: /\(/, + end: /\)/, + keywords: KEYWORDS, + relevance: 0, + contains: [ + ANNOTATION, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + NUMBER, + hljs.C_BLOCK_COMMENT_MODE + ] + }, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE + ] + }, + NUMBER, + ANNOTATION + ] + }; +} diff --git a/src/languages/java.js b/src/languages/java.js index a1e6d4c5ae..270f0d1a77 100644 --- a/src/languages/java.js +++ b/src/languages/java.js @@ -74,10 +74,7 @@ export default function(hljs) { 'requires', 'exports', 'do', - 'sealed', - '__aspect','__assembly','__module','__extension','__partial','__out','__ref','__struct','__mapped', - '__get','__set','__block','__strong','__weak','__unretained','__selector','__require', - '__ensure','__result','__old','__invariants','__autoreleasepool','__event','__add','__remove' + 'sealed' ]; const BUILT_INS = [ @@ -134,7 +131,7 @@ export default function(hljs) { return { name: 'Java', - aliases: ['jsp', 'iodine'], + aliases: ['jsp'], keywords: KEYWORDS, illegal: /<\/|#/, contains: [ diff --git a/src/languages/vbmercury.js b/src/languages/vbmercury.js new file mode 100644 index 0000000000..236b7c73df --- /dev/null +++ b/src/languages/vbmercury.js @@ -0,0 +1,157 @@ +/* +Language: Mercury (VB) +Author: Carlo Kok +Contributor: Poren Chiang , Jan Pilzer +Description: Mercury is RemObjects Software's Visual Basic-compatible language for the Elements compiler, with additional platform-specific extensions. +Website: https://www.elementscompiler.com/elements/mercury/ +*/ + +/** @type LanguageFn */ +export default function(hljs) { + const regex = hljs.regex; + /** + * Character Literal + * Either a single character ("a"C) or an escaped double quote (""""C). + */ + const CHARACTER = { + className: 'string', + begin: /"(""|[^/n])"C\b/ + }; + + const STRING = { + className: 'string', + begin: /"/, + end: /"/, + illegal: /\n/, + contains: [ + { + // double quote escape + begin: /""/ + } + ] + }; + + /** Date Literals consist of a date, a time, or both separated by whitespace, surrounded by # */ + const MM_DD_YYYY = /\d{1,2}\/\d{1,2}\/\d{4}/; + const YYYY_MM_DD = /\d{4}-\d{1,2}-\d{1,2}/; + const TIME_12H = /(\d|1[012])(:\d+){0,2} *(AM|PM)/; + const TIME_24H = /\d{1,2}(:\d{1,2}){1,2}/; + const DATE = { + className: 'literal', + variants: [ + { + // #YYYY-MM-DD# (ISO-Date) or #M/D/YYYY# (US-Date) + begin: regex.concat(/# */, regex.either(YYYY_MM_DD, MM_DD_YYYY), / *#/) + }, + { + // #H:mm[:ss]# (24h Time) + begin: regex.concat(/# */, TIME_24H, / *#/) + }, + { + // #h[:mm[:ss]] A# (12h Time) + begin: regex.concat(/# */, TIME_12H, / *#/) + }, + { + // date plus time + begin: regex.concat( + /# */, + regex.either(YYYY_MM_DD, MM_DD_YYYY), + / +/, + regex.either(TIME_12H, TIME_24H), + / *#/ + ) + } + ] + }; + + const NUMBER = { + className: 'number', + relevance: 0, + variants: [ + { + // Float + begin: /\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/ + }, + { + // Integer (base 10) + begin: /\b\d[\d_]*((U?[SIL])|[%&])?/ + }, + { + // Integer (base 16) + begin: /&H[\dA-F_]+((U?[SIL])|[%&])?/ + }, + { + // Integer (base 8) + begin: /&O[0-7_]+((U?[SIL])|[%&])?/ + }, + { + // Integer (base 2) + begin: /&B[01_]+((U?[SIL])|[%&])?/ + } + ] + }; + + const LABEL = { + className: 'label', + begin: /^\w+:/ + }; + + const DOC_COMMENT = hljs.COMMENT(/'''/, /$/, { + contains: [ + { + className: 'doctag', + begin: /<\/?/, + end: />/ + } + ] + }); + + const COMMENT = hljs.COMMENT(null, /$/, { + variants: [ + { + begin: /'/ + }, + { + // TODO: Use multi-class for leading spaces + begin: /([\t ]|^)REM(?=\s)/ + } + ] + }); + + const DIRECTIVES = { + className: 'meta', + // TODO: Use multi-class for indentation once available + begin: /[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/, + end: /$/, + keywords: { + keyword: + 'const disable else elseif enable end externalsource if region then' + }, + contains: [ COMMENT ] + }; + + return { + name: 'Mercury', + aliases: [ 'vbmercury' ], + case_insensitive: true, + classNameAliases: { + label: 'symbol' + }, + keywords: { + keyword: + 'ensure check invariants old require addhandler addressof alias and andalso ansi as ascending assembly async auto autoreleasepool await boolean by byref byte byval call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj const continue csbyte cshort csng cstr ctrytype ctype cuint culng cushort custom decimal declare default delegate descending dim directcast distinct do double dynamic each else elseif end endif enum equals erase error event exit extends false finally for friend from function get gettype getxmlnamespace global gosub goto group handles if implements imports in index inherits integer interface into is isfalse isnot istrue iterator join key lazy let lib like long loop mappedto matching me mid mod module mustinherit mustoverride mybase myclass mymapped namespace narrowing new next not nothing notinheritable notoverridable null object of off on operator option optional or order orelse out overloads overridable overrides paramarray partial preserve private property protected ptr public raiseevent readonly record redim rem removehandler resume return sbyte select set shadows shared short single skip static step stop string structure strict sub synclock take text then throw to true try trycast typeof uinteger ulong unicode unmanaged unsafe until ushort using variant wend when where while widening with withevents writeonly xor yield zip' + }, + illegal: + '//|\\{|\\}|endif|gosub|variant|wend|^\\$ ' /* reserved deprecated keywords */, + contains: [ + CHARACTER, + STRING, + DATE, + NUMBER, + LABEL, + DOC_COMMENT, + COMMENT, + DIRECTIVES + ] + }; +} diff --git a/src/languages/vbnet.js b/src/languages/vbnet.js index b769f13e32..3162f3bd2b 100644 --- a/src/languages/vbnet.js +++ b/src/languages/vbnet.js @@ -132,14 +132,14 @@ export default function(hljs) { return { name: 'Visual Basic .NET', - aliases: [ 'vb', 'mercury' ], + aliases: [ 'vb' ], case_insensitive: true, classNameAliases: { label: 'symbol' }, keywords: { keyword: - 'ensure check invariants old require addhandler addressof alias and andalso ansi as ascending assembly async auto autoreleasepool await boolean by byref byte byval call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj const continue csbyte cshort csng cstr ctrytype ctype cuint culng cushort custom decimal declare default delegate descending dim directcast distinct do double dynamic each else elseif end endif enum equals erase error event exit extends false finally for friend from function get gettype getxmlnamespace global gosub goto group handles if implements imports in index inherits integer interface into is isfalse isnot istrue iterator join key lazy let lib like long loop mappedto matching me mod module mustinherit mustoverride mybase myclass mymapped namespace namespace narrowing new next not nothing notinheritable notoverridable null object of on operator option optional or order orelse out overloads overridable overrides paramarray partial preserve private property protected ptr public raiseevent readonly record redim rem removehandler resume return sbyte select set shadows shared short single skip static step stop string structure sub synclock take then throw to true try trycast typeof uinteger ulong unicode unmanaged unsafe until ushort using variant wend when where while widening with withevents writeonly xor yield zip ' + 'addhandler addressof alias and andalso ansi as ascending assembly async auto await boolean by byref byte byval call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj const continue csbyte cshort csng cstr ctype cuint culng cushort custom decimal declare default delegate descending dim directcast distinct do double each else elseif end endif enum equals erase error event exit extends false finally for friend from function get gettype getxmlnamespace global gosub goto group handles if implements imports in inherits integer interface into is isfalse isnot istrue iterator join key let lib like long loop me mod module mustinherit mustoverride mybase myclass namespace narrowing new next not nothing notinheritable notoverridable null object of on operator option optional or order orelse out overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim rem removehandler resume return sbyte select set shadows shared short single skip static step stop string structure sub synclock take then throw to true try trycast typeof uinteger ulong unicode until ushort using variant wend when where while widening with withevents writeonly xor yield zip' }, illegal: From f7b8522e2a3dc72d0f3e0d6e822f15aefd3f1e79 Mon Sep 17 00:00:00 2001 From: marc hoffman Date: Thu, 19 Feb 2026 07:52:50 -0400 Subject: [PATCH 09/12] Synced Hydrogene up with C# --- src/languages/hydrogene.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/languages/hydrogene.js b/src/languages/hydrogene.js index 3ac3aaf5e0..aa7e591d97 100644 --- a/src/languages/hydrogene.js +++ b/src/languages/hydrogene.js @@ -93,6 +93,7 @@ export default function(hljs) { 'record', 'ref', 'return', + 'scoped', 'sealed', 'sizeof', 'stackalloc', @@ -116,11 +117,14 @@ export default function(hljs) { 'alias', 'and', 'ascending', + 'args', 'async', 'await', 'by', 'descending', + 'dynamic', 'equals', + 'file', 'from', 'get', 'global', @@ -136,7 +140,10 @@ export default function(hljs) { 'or', 'orderby', 'partial', + 'record', 'remove', + 'required', + 'scoped', 'select', 'set', 'unmanaged', @@ -194,6 +201,11 @@ export default function(hljs) { ], relevance: 0 }; + const RAW_STRING = { + className: 'string', + begin: /"""("*)(?!")(.|\n)*?"""\1/, + relevance: 1 + }; const VERBATIM_STRING = { className: 'string', begin: '@"', @@ -286,6 +298,7 @@ export default function(hljs) { ]; const STRING = { variants: [ + RAW_STRING, INTERPOLATED_VERBATIM_STRING, INTERPOLATED_STRING, VERBATIM_STRING, From f0d4daedf2d15c62d9547993c0fe9d1db7fdb299 Mon Sep 17 00:00:00 2001 From: Iamfittz Date: Fri, 20 Feb 2026 11:14:59 +0200 Subject: [PATCH 10/12] Sync gold, iodine, vbmercury with latest base highlighters. --- src/languages/gold.js | 24 +++++++++++++++++++----- src/languages/iodine.js | 30 +++++++++++++++--------------- src/languages/vbmercury.js | 35 +++++++++++++++++++++++++---------- 3 files changed, 59 insertions(+), 30 deletions(-) diff --git a/src/languages/gold.js b/src/languages/gold.js index 919ffb6144..c2a8dc0c4c 100644 --- a/src/languages/gold.js +++ b/src/languages/gold.js @@ -108,14 +108,28 @@ export default function(hljs) { className: 'number', variants: [ { - begin: hljs.C_NUMBER_RE + '[i]', - relevance: 1 + match: /-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/, + relevance: 0 }, - hljs.C_NUMBER_MODE + { + match: /-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/, + relevance: 0 + }, + { + match: /-?\b0[oO](_?[0-7])*i?/, + relevance: 0 + }, + { + match: /-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/, + relevance: 0 + }, + { + match: /-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/, + relevance: 0 + } ] }, - { - begin: /:=/ // relevance booster + { begin: /:=/ }, { className: 'function', diff --git a/src/languages/iodine.js b/src/languages/iodine.js index 62a656b3c3..2d2c731105 100644 --- a/src/languages/iodine.js +++ b/src/languages/iodine.js @@ -6,9 +6,7 @@ Description: Iodine is RemObjects Software's Java-compatible language for the El Website: https://www.elementscompiler.com/elements/iodine/ */ -import { - NUMERIC as NUMBER -} from "./lib/java.js"; +import { NUMERIC as NUMBER } from "./lib/java.js"; /** * Allows recursive regex expressions to a given depth @@ -33,8 +31,8 @@ function recurRegex(re, substitution, depth) { export default function(hljs) { const regex = hljs.regex; const JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*'; - const GENERIC_IDENT_RE = JAVA_IDENT_RE + - recurRegex('(?:<' + JAVA_IDENT_RE + '~~~(?:\\s*,\\s*' + JAVA_IDENT_RE + '~~~)*>)?', /~~~/g, 2); + const GENERIC_IDENT_RE = JAVA_IDENT_RE + + recurRegex('(?:<' + JAVA_IDENT_RE + '~~~(?:\\s*,\\s*' + JAVA_IDENT_RE + '~~~)*>)?', /~~~/g, 2); const MAIN_KEYWORDS = [ 'synchronized', 'abstract', @@ -76,7 +74,13 @@ export default function(hljs) { 'exports', 'do', 'sealed', - // RemObjects Elements extensions + 'yield', + 'permits', + 'goto', + 'when' + ]; + // RemObjects Elements-specific extensions + const ELEMENTS_KEYWORDS = [ '__aspect', '__assembly', '__module', @@ -127,7 +131,7 @@ export default function(hljs) { ]; const KEYWORDS = { - keyword: MAIN_KEYWORDS, + keyword: MAIN_KEYWORDS.concat(ELEMENTS_KEYWORDS), literal: LITERALS, type: TYPES, built_in: BUILT_INS @@ -150,9 +154,7 @@ export default function(hljs) { end: /\)/, keywords: KEYWORDS, relevance: 0, - contains: [ - hljs.C_BLOCK_COMMENT_MODE - ], + contains: [ hljs.C_BLOCK_COMMENT_MODE ], endsParent: true }; @@ -192,7 +194,7 @@ export default function(hljs) { begin: /"""/, end: /"""/, className: "string", - contains: [hljs.BACKSLASH_ESCAPE] + contains: [ hljs.BACKSLASH_ESCAPE ] }, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, @@ -218,7 +220,7 @@ export default function(hljs) { /\s+/, JAVA_IDENT_RE, /\s+/, - /=/ + /=(?!=)/ ], className: { 1: "type", @@ -254,9 +256,7 @@ export default function(hljs) { hljs.UNDERSCORE_IDENT_RE, /\s*(?=\()/ ], - className: { - 2: "title.function" - }, + className: { 2: "title.function" }, keywords: KEYWORDS, contains: [ { diff --git a/src/languages/vbmercury.js b/src/languages/vbmercury.js index 236b7c73df..e291ca4155 100644 --- a/src/languages/vbmercury.js +++ b/src/languages/vbmercury.js @@ -7,7 +7,7 @@ Website: https://www.elementscompiler.com/elements/mercury/ */ /** @type LanguageFn */ -export default function(hljs) { +export default function (hljs) { const regex = hljs.regex; /** * Character Literal @@ -108,9 +108,7 @@ export default function(hljs) { const COMMENT = hljs.COMMENT(null, /$/, { variants: [ - { - begin: /'/ - }, + { begin: /'/ }, { // TODO: Use multi-class for leading spaces begin: /([\t ]|^)REM(?=\s)/ @@ -127,19 +125,36 @@ export default function(hljs) { keyword: 'const disable else elseif enable end externalsource if region then' }, - contains: [ COMMENT ] + contains: [COMMENT] }; return { name: 'Mercury', - aliases: [ 'vbmercury' ], + aliases: ['vbmercury'], case_insensitive: true, - classNameAliases: { - label: 'symbol' - }, + classNameAliases: { label: 'symbol' }, keywords: { keyword: - 'ensure check invariants old require addhandler addressof alias and andalso ansi as ascending assembly async auto autoreleasepool await boolean by byref byte byval call case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj const continue csbyte cshort csng cstr ctrytype ctype cuint culng cushort custom decimal declare default delegate descending dim directcast distinct do double dynamic each else elseif end endif enum equals erase error event exit extends false finally for friend from function get gettype getxmlnamespace global gosub goto group handles if implements imports in index inherits integer interface into is isfalse isnot istrue iterator join key lazy let lib like long loop mappedto matching me mid mod module mustinherit mustoverride mybase myclass mymapped namespace narrowing new next not nothing notinheritable notoverridable null object of off on operator option optional or order orelse out overloads overridable overrides paramarray partial preserve private property protected ptr public raiseevent readonly record redim rem removehandler resume return sbyte select set shadows shared short single skip static step stop string structure strict sub synclock take text then throw to true try trycast typeof uinteger ulong unicode unmanaged unsafe until ushort using variant wend when where while widening with withevents writeonly xor yield zip' + 'addhandler alias aggregate ansi as ascending async assembly auto autoreleasepool binary by byref byval ' /* a-b */ + + 'call case catch check class compare const continue custom declare default delegate descending dim distinct do dynamic ' /* c-d */ + + 'each ensure equals else elseif end enum erase error event exit explicit extends finally for friend from function ' /* e-f */ + + 'get global goto group handles if implements imports in index inherits interface into invariants iterator ' /* g-i */ + + 'join key lazy let lib like long loop mappedto matching me mid mod module mustinherit mustoverride mybase myclass mymapped ' /* j-m */ + + 'namespace narrowing new next notinheritable notoverridable ' /* n */ + + 'of off old on operator option optional or order orelse out overloads overridable overrides ' /* o */ + + 'paramarray partial preserve private property protected ptr public ' /* p */ + + 'raiseevent readonly record redim removehandler require resume return ' /* r */ + + 'select set shadows shared skip static step stop structure strict sub synclock ' /* s */ + + 'take text then throw to try unicode unmanaged unsafe until using when where while widening with withevents writeonly yield zip' /* t-z */, + built_in: + // Operators https://docs.microsoft.com/dotnet/visual-basic/language-reference/operators + 'addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor ' + // Type Conversion Functions https://docs.microsoft.com/dotnet/visual-basic/language-reference/functions/type-conversion-functions + + 'cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort', + type: + // Data types https://docs.microsoft.com/dotnet/visual-basic/language-reference/data-types + 'boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort', + literal: 'true false nothing' }, illegal: '//|\\{|\\}|endif|gosub|variant|wend|^\\$ ' /* reserved deprecated keywords */, From 69d2f2f77ef89db16aef7cdb9ed1cefb0d6e06ee Mon Sep 17 00:00:00 2001 From: Iamfittz Date: Fri, 20 Feb 2026 15:05:26 +0200 Subject: [PATCH 11/12] Add 'field' keyword to csharp and hydrogene. --- src/languages/csharp.js | 1 + src/languages/hydrogene.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/languages/csharp.js b/src/languages/csharp.js index 8a2c65b614..b652bff9b1 100644 --- a/src/languages/csharp.js +++ b/src/languages/csharp.js @@ -124,6 +124,7 @@ export default function(hljs) { 'descending', 'dynamic', 'equals', + 'field', 'file', 'from', 'get', diff --git a/src/languages/hydrogene.js b/src/languages/hydrogene.js index aa7e591d97..a1b5e27479 100644 --- a/src/languages/hydrogene.js +++ b/src/languages/hydrogene.js @@ -124,6 +124,7 @@ export default function(hljs) { 'descending', 'dynamic', 'equals', + 'field', 'file', 'from', 'get', From f2826704c73cb83eb3a7ac3fd762c8e7dfe21ef0 Mon Sep 17 00:00:00 2001 From: Iamfittz Date: Fri, 20 Feb 2026 15:50:22 +0200 Subject: [PATCH 12/12] Add string support for Oxygene. --- src/languages/oxygene.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/languages/oxygene.js b/src/languages/oxygene.js index ffc3690b93..d680953cd1 100644 --- a/src/languages/oxygene.js +++ b/src/languages/oxygene.js @@ -22,6 +22,29 @@ export default function (hljs) { '\\*\\)', { relevance: 10 } ); + const RAW_STRING = { + className: 'string', + begin: /#+"{2,}/, + end: /"{2,}/ + }; + const INTERPOLATED_DOUBLE_STRING = { + className: 'string', + begin: /\$"/, + end: '"', + contains: [{ begin: '""' }] + }; + const INTERPOLATED_SINGLE_STRING = { + className: 'string', + begin: /\$'/, + end: '\'', + contains: [{ begin: '\'\'' }] + }; + const DOUBLE_STRING = { + className: 'string', + begin: '"', + end: '"', + contains: [{ begin: '""' }] + }; const STRING = { className: 'string', begin: '\'', @@ -30,7 +53,7 @@ export default function (hljs) { }; const CHAR_STRING = { className: 'string', - begin: '(#\\d+)+' + begin: /(#\d+|#\$[0-9a-fA-F]+)+/ }; const FUNCTION = { beginKeywords: 'function constructor destructor procedure method', @@ -44,6 +67,10 @@ export default function (hljs) { end: '\\)', keywords: OXYGENE_KEYWORDS, contains: [ + RAW_STRING, + INTERPOLATED_DOUBLE_STRING, + INTERPOLATED_SINGLE_STRING, + DOUBLE_STRING, STRING, CHAR_STRING ] @@ -63,11 +90,15 @@ export default function (hljs) { name: 'Oxygene', case_insensitive: true, keywords: OXYGENE_KEYWORDS, - illegal: '("|\\$[G-Zg-z]|\\/\\*||->)', + illegal: '(\\$[G-Zg-z]|\\/\\*||->)', contains: [ CURLY_COMMENT, PAREN_COMMENT, hljs.C_LINE_COMMENT_MODE, + RAW_STRING, + INTERPOLATED_DOUBLE_STRING, + INTERPOLATED_SINGLE_STRING, + DOUBLE_STRING, STRING, CHAR_STRING, hljs.NUMBER_MODE,