From ffd8343f330f98df6406d84d71b1365767ec2f2a Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Sat, 18 Dec 2021 12:51:17 +0100 Subject: [PATCH] Xojo: Proper token name for directives (#3263) --- components/prism-xojo.js | 8 ++++++-- components/prism-xojo.min.js | 2 +- tests/languages/xojo/directive_feature.test | 19 +++++++++++++++++++ tests/languages/xojo/symbol_feature.test | 19 ------------------- 4 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 tests/languages/xojo/directive_feature.test delete mode 100644 tests/languages/xojo/symbol_feature.test diff --git a/components/prism-xojo.js b/components/prism-xojo.js index a99fc94b73..c048b24584 100644 --- a/components/prism-xojo.js +++ b/components/prism-xojo.js @@ -1,6 +1,7 @@ Prism.languages.xojo = { 'comment': { - pattern: /(?:'|\/\/|Rem\b).+/i + pattern: /(?:'|\/\/|Rem\b).+/i, + greedy: true }, 'string': { pattern: /"(?:""|[^"])*"/, @@ -10,7 +11,10 @@ Prism.languages.xojo = { /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i, /&[bchou][a-z\d]+/i ], - 'symbol': /#(?:Else|ElseIf|Endif|If|Pragma)\b/i, + 'directive': { + pattern: /#(?:Else|ElseIf|Endif|If|Pragma)\b/i, + alias: 'property' + }, 'keyword': /\b(?:AddHandler|App|Array|As(?:signs)?|Auto|Boolean|Break|By(?:Ref|Val)|Byte|Call|Case|Catch|CFStringRef|CGFloat|Class|Color|Const|Continue|CString|Currency|CurrentMethodName|Declare|Delegate|Dim|Do(?:uble|wnTo)?|Each|Else(?:If)?|End|Enumeration|Event|Exception|Exit|Extends|False|Finally|For|Function|Get|GetTypeInfo|Global|GOTO|If|Implements|In|Inherits|Int(?:8|16|32|64|eger|erface)?|Lib|Loop|Me|Module|Next|Nil|Object|Optional|OSType|ParamArray|Private|Property|Protected|PString|Ptr|Raise(?:Event)?|ReDim|RemoveHandler|Return|Select(?:or)?|Self|Set|Shared|Short|Single|Soft|Static|Step|String|Sub|Super|Text|Then|To|True|Try|Ubound|UInt(?:8|16|32|64|eger)?|Until|Using|Var(?:iant)?|Wend|While|WindowPtr|WString)\b/i, 'operator': /<[=>]?|>=?|[+\-*\/\\^=]|\b(?:AddressOf|And|Ctype|IsA?|Mod|New|Not|Or|WeakAddressOf|Xor)\b/i, 'punctuation': /[.,;:()]/ diff --git a/components/prism-xojo.min.js b/components/prism-xojo.min.js index 8abacf930b..015aed5b78 100644 --- a/components/prism-xojo.min.js +++ b/components/prism-xojo.min.js @@ -1 +1 @@ -Prism.languages.xojo={comment:{pattern:/(?:'|\/\/|Rem\b).+/i},string:{pattern:/"(?:""|[^"])*"/,greedy:!0},number:[/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,/&[bchou][a-z\d]+/i],symbol:/#(?:Else|ElseIf|Endif|If|Pragma)\b/i,keyword:/\b(?:AddHandler|App|Array|As(?:signs)?|Auto|Boolean|Break|By(?:Ref|Val)|Byte|Call|Case|Catch|CFStringRef|CGFloat|Class|Color|Const|Continue|CString|Currency|CurrentMethodName|Declare|Delegate|Dim|Do(?:uble|wnTo)?|Each|Else(?:If)?|End|Enumeration|Event|Exception|Exit|Extends|False|Finally|For|Function|Get|GetTypeInfo|Global|GOTO|If|Implements|In|Inherits|Int(?:8|16|32|64|eger|erface)?|Lib|Loop|Me|Module|Next|Nil|Object|Optional|OSType|ParamArray|Private|Property|Protected|PString|Ptr|Raise(?:Event)?|ReDim|RemoveHandler|Return|Select(?:or)?|Self|Set|Shared|Short|Single|Soft|Static|Step|String|Sub|Super|Text|Then|To|True|Try|Ubound|UInt(?:8|16|32|64|eger)?|Until|Using|Var(?:iant)?|Wend|While|WindowPtr|WString)\b/i,operator:/<[=>]?|>=?|[+\-*\/\\^=]|\b(?:AddressOf|And|Ctype|IsA?|Mod|New|Not|Or|WeakAddressOf|Xor)\b/i,punctuation:/[.,;:()]/}; \ No newline at end of file +Prism.languages.xojo={comment:{pattern:/(?:'|\/\/|Rem\b).+/i,greedy:!0},string:{pattern:/"(?:""|[^"])*"/,greedy:!0},number:[/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,/&[bchou][a-z\d]+/i],directive:{pattern:/#(?:Else|ElseIf|Endif|If|Pragma)\b/i,alias:"property"},keyword:/\b(?:AddHandler|App|Array|As(?:signs)?|Auto|Boolean|Break|By(?:Ref|Val)|Byte|Call|Case|Catch|CFStringRef|CGFloat|Class|Color|Const|Continue|CString|Currency|CurrentMethodName|Declare|Delegate|Dim|Do(?:uble|wnTo)?|Each|Else(?:If)?|End|Enumeration|Event|Exception|Exit|Extends|False|Finally|For|Function|Get|GetTypeInfo|Global|GOTO|If|Implements|In|Inherits|Int(?:8|16|32|64|eger|erface)?|Lib|Loop|Me|Module|Next|Nil|Object|Optional|OSType|ParamArray|Private|Property|Protected|PString|Ptr|Raise(?:Event)?|ReDim|RemoveHandler|Return|Select(?:or)?|Self|Set|Shared|Short|Single|Soft|Static|Step|String|Sub|Super|Text|Then|To|True|Try|Ubound|UInt(?:8|16|32|64|eger)?|Until|Using|Var(?:iant)?|Wend|While|WindowPtr|WString)\b/i,operator:/<[=>]?|>=?|[+\-*\/\\^=]|\b(?:AddressOf|And|Ctype|IsA?|Mod|New|Not|Or|WeakAddressOf|Xor)\b/i,punctuation:/[.,;:()]/}; \ No newline at end of file diff --git a/tests/languages/xojo/directive_feature.test b/tests/languages/xojo/directive_feature.test new file mode 100644 index 0000000000..f5aef811af --- /dev/null +++ b/tests/languages/xojo/directive_feature.test @@ -0,0 +1,19 @@ +#If +#Else +#ElseIf +#Endif +#Pragma + +---------------------------------------------------- + +[ + ["directive", "#If"], + ["directive", "#Else"], + ["directive", "#ElseIf"], + ["directive", "#Endif"], + ["directive", "#Pragma"] +] + +---------------------------------------------------- + +Checks for conditional compilation and pragma. diff --git a/tests/languages/xojo/symbol_feature.test b/tests/languages/xojo/symbol_feature.test deleted file mode 100644 index 980c0f13ed..0000000000 --- a/tests/languages/xojo/symbol_feature.test +++ /dev/null @@ -1,19 +0,0 @@ -#If -#Else -#ElseIf -#Endif -#Pragma - ----------------------------------------------------- - -[ - ["symbol", "#If"], - ["symbol", "#Else"], - ["symbol", "#ElseIf"], - ["symbol", "#Endif"], - ["symbol", "#Pragma"] -] - ----------------------------------------------------- - -Checks for conditional compilation and pragma. \ No newline at end of file