Repository: PrismJS/prism
Pull request #3512 (2022-07-30 14:58:44)

Improve BBj regexs
* [BBj: extend BBj keywords list](https://github.com/PrismJS/prism/commit/ca5e6a8191c966c5e7da8cba0652b30614ca8435)
* [BBj: fix strings regex does not match single quotes](https://github.com/PrismJS/prism/commit/f069d10e4faeb52254d0973d8a79643c686d6a4b)
* [BBj: add declare as keyword](https://github.com/PrismJS/prism/commit/358f56ffcc65b781c66108a4f357bd4edc7d319e)

github-actions[bot]: 
<!--
  0 failure: 
  0 warning: 
  
  1 markdown notices
  DangerID: danger-id-Danger;
-->



## JS File Size Changes (gzipped)

A total of 1 files have changed, with a combined diff of +9 B (+1.6%).

<details>

| file | master | pull | size diff | % diff |
| --- | --- | --- | --- | --- |
| components/prism-bbj.min.js | 559 B | 568 B | +9 B | +1.6% |

</details>

<p align="right">
  Generated by :no_entry_sign: <a href="https://danger.systems/js">dangerJS</a> against 358f56ffcc65b781c66108a4f357bd4edc7d319e
</p>


Patch:
diff --git a/components/prism-bbj.js b/components/prism-bbj.js
index 883b4e7d..df401d32 100644
--- a/components/prism-bbj.js
+++ b/components/prism-bbj.js
@@ -6,11 +6,11 @@
 			greedy: true
 		},
 		'string': {
-			pattern: /"(?:""|[!#$%&'()*,\/:;<=>?^\w +\-.])*"/,
+			pattern: /(['"])(?:(?!\1|\\).|\\.)*\1/,
 			greedy: true
 		},
 		'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,
-		'keyword': /\b(?:abstract|all|argc|begin|bye|callback|case|chn|class|classend|ctl|day|delete|dom|dread|dsz|else|endif|err|exitto|extends|fi|field|for|from|gosub|goto|if|implements|interface|interfaceend|iol|iolist|let|list|load|method|methodend|methodret|on|opts|pfx|private|process_events|protected|psz|public|read_resource|remove_callback|restore|rev|seterr|setesc|sqlchn|sqlunt|ssn|start|static|swend|switch|sys|then|tim|unt|until|use|void|wend|where|while)\b/i,
+		'keyword': /\b(?:abstract|all|argc|begin|bye|callback|case|chn|class|classend|ctl|day|declare|delete|dim|dom|dread|dsz|else|end|endif|err|exitto|extends|fi|field|for|from|gosub|goto|if|implements|interface|interfaceend|iol|iolist|let|list|load|method|methodend|methodret|on|opts|pfx|print|private|process_events|protected|psz|public|read|read_resource|release|remove_callback|repeat|restore|return|rev|seterr|setesc|sqlchn|sqlunt|ssn|start|static|swend|switch|sys|then|tim|unt|until|use|void|wend|where|while)\b/i,
 		'function': /\b\w+(?=\()/,
 		'boolean': /\b(?:BBjAPI\.TRUE|BBjAPI\.FALSE)\b/i,
 		'operator': /<[=>]?|>=?|[+\-*\/^=&]|\b(?:and|not|or|xor)\b/i,
diff --git a/components/prism-bbj.min.js b/components/prism-bbj.min.js
index 64ca9b40..839b4a94 100644
--- a/components/prism-bbj.min.js
+++ b/components/prism-bbj.min.js
@@ -1,1 +1,1 @@
-!function(e){e.languages.bbj={comment:{pattern:/(^|[^\\:])rem\s+.*/i,lookbehind:!0,greedy:!0},string:{pattern:/"(?:""|[!#$%&'()*,\/:;<=>?^\w +\-.])*"/,greedy:!0},number:/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,keyword:/\b(?:abstract|all|argc|begin|bye|callback|case|chn|class|classend|ctl|day|delete|dom|dread|dsz|else|endif|err|exitto|extends|fi|field|for|from|gosub|goto|if|implements|interface|interfaceend|iol|iolist|let|list|load|method|methodend|methodret|on|opts|pfx|private|process_events|protected|psz|public|read_resource|remove_callback|restore|rev|seterr|setesc|sqlchn|sqlunt|ssn|start|static|swend|switch|sys|then|tim|unt|until|use|void|wend|where|while)\b/i,function:/\b\w+(?=\()/,boolean:/\b(?:BBjAPI\.TRUE|BBjAPI\.FALSE)\b/i,operator:/<[=>]?|>=?|[+\-*\/^=&]|\b(?:and|not|or|xor)\b/i,punctuation:/[.,;:()]/}}(Prism);
\ No newline at end of file
+!function(e){e.languages.bbj={comment:{pattern:/(^|[^\\:])rem\s+.*/i,lookbehind:!0,greedy:!0},string:{pattern:/(['"])(?:(?!\1|\\).|\\.)*\1/,greedy:!0},number:/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,keyword:/\b(?:abstract|all|argc|begin|bye|callback|case|chn|class|classend|ctl|day|declare|delete|dim|dom|dread|dsz|else|end|endif|err|exitto|extends|fi|field|for|from|gosub|goto|if|implements|interface|interfaceend|iol|iolist|let|list|load|method|methodend|methodret|on|opts|pfx|print|private|process_events|protected|psz|public|read|read_resource|release|remove_callback|repeat|restore|return|rev|seterr|setesc|sqlchn|sqlunt|ssn|start|static|swend|switch|sys|then|tim|unt|until|use|void|wend|where|while)\b/i,function:/\b\w+(?=\()/,boolean:/\b(?:BBjAPI\.TRUE|BBjAPI\.FALSE)\b/i,operator:/<[=>]?|>=?|[+\-*\/^=&]|\b(?:and|not|or|xor)\b/i,punctuation:/[.,;:()]/}}(Prism);
\ No newline at end of file


Test patch:
diff --git a/tests/languages/bbj/keyword_feature.test b/tests/languages/bbj/keyword_feature.test
index 77ed4c34..4948ebd8 100644
--- a/tests/languages/bbj/keyword_feature.test
+++ b/tests/languages/bbj/keyword_feature.test
@@ -1,8 +1,9 @@
-abstract all argc begin bye callback case chn class classend ctl day delete dom dread dsz else 
-endif err exitto extends fi field field for from gosub goto if implements interface interfaceend 
-iol iolist let list load method methodend methodret on opts pfx private private process_events 
-protected protected psz public public read_resource remove_callback restore rev seterr setesc sqlchn 
-sqlunt ssn start static static swend switch sys then tim unt until void void wend where while use
+abstract all argc begin bye callback case chn class classend ctl day delete dim dom 
+dread dsz else end endif err exitto extends fi field for from gosub goto if implements 
+interface interfaceend iol iolist let list load method methodend methodret on opts pfx 
+print private process_events protected psz public read read_resource release remove_callback 
+repeat restore return rev seterr setesc sqlchn sqlunt ssn start static swend switch sys then 
+tim unt until use void wend where while declare
 
 ----------------------------------------------------
 
@@ -20,27 +21,28 @@ sqlunt ssn start static static swend switch sys then tim unt until void void wen
 	["keyword", "ctl"],
 	["keyword", "day"],
 	["keyword", "delete"],
+	["keyword", "dim"],
 	["keyword", "dom"],
+
 	["keyword", "dread"],
 	["keyword", "dsz"],
 	["keyword", "else"],
-
+	["keyword", "end"],
 	["keyword", "endif"],
 	["keyword", "err"],
 	["keyword", "exitto"],
 	["keyword", "extends"],
 	["keyword", "fi"],
 	["keyword", "field"],
-	["keyword", "field"],
 	["keyword", "for"],
 	["keyword", "from"],
 	["keyword", "gosub"],
 	["keyword", "goto"],
 	["keyword", "if"],
 	["keyword", "implements"],
+
 	["keyword", "interface"],
 	["keyword", "interfaceend"],
-
 	["keyword", "iol"],
 	["keyword", "iolist"],
 	["keyword", "let"],
@@ -52,41 +54,43 @@ sqlunt ssn start static static swend switch sys then tim unt until void void wen
 	["keyword", "on"],
 	["keyword", "opts"],
 	["keyword", "pfx"],
-	["keyword", "private"],
+
+	["keyword", "print"],
 	["keyword", "private"],
 	["keyword", "process_events"],
-
-	["keyword", "protected"],
 	["keyword", "protected"],
 	["keyword", "psz"],
 	["keyword", "public"],
-	["keyword", "public"],
+	["keyword", "read"],
 	["keyword", "read_resource"],
+	["keyword", "release"],
 	["keyword", "remove_callback"],
+
+	["keyword", "repeat"],
 	["keyword", "restore"],
+	["keyword", "return"],
 	["keyword", "rev"],
 	["keyword", "seterr"],
 	["keyword", "setesc"],
 	["keyword", "sqlchn"],
-
 	["keyword", "sqlunt"],
 	["keyword", "ssn"],
 	["keyword", "start"],
 	["keyword", "static"],
-	["keyword", "static"],
 	["keyword", "swend"],
 	["keyword", "switch"],
 	["keyword", "sys"],
 	["keyword", "then"],
+
 	["keyword", "tim"],
 	["keyword", "unt"],
 	["keyword", "until"],
-	["keyword", "void"],
+	["keyword", "use"],
 	["keyword", "void"],
 	["keyword", "wend"],
 	["keyword", "where"],
 	["keyword", "while"],
-	["keyword", "use"]
+	["keyword", "declare"]
 ]
 
 ----------------------------------------------------
diff --git a/tests/languages/bbj/string_feature.test b/tests/languages/bbj/string_feature.test
index 101e1b3c..1d635e70 100644
--- a/tests/languages/bbj/string_feature.test
+++ b/tests/languages/bbj/string_feature.test
@@ -1,13 +1,27 @@
 ""
-"fo""obar"
+''
+"f\"oo"
+'b\'ar'
+
+"foo rem comment bar"
+"foo ""rem"" comment bar"
+"foo rem /* *rem comment bar"
 
 ----------------------------------------------------
 
 [
 	["string", "\"\""],
-	["string", "\"fo\"\"obar\""]
+	["string", "''"],
+	["string", "\"f\\\"oo\""],
+	["string", "'b\\'ar'"],
+
+	["string", "\"foo rem comment bar\""],
+	["string", "\"foo \""],
+	["string", "\"rem\""],
+	["string", "\" comment bar\""],
+	["string", "\"foo rem /* *rem comment bar\""]
 ]
 
 ----------------------------------------------------
 
-Checks for strings.
\ No newline at end of file
+Checks for strings.