Commit bacf9ae31157fb6e336fe26dac705565cab5181f

Michael Schmidt 2021-12-10T14:40:37

Prolog: Removed variable token + minor improvements (#3247)

diff --git a/components/prism-prolog.js b/components/prism-prolog.js
index 2fb2aad..0917e54 100644
--- a/components/prism-prolog.js
+++ b/components/prism-prolog.js
@@ -1,16 +1,15 @@
 Prism.languages.prolog = {
 	// Syntax depends on the implementation
-	'comment': [
-		/%.+/,
-		/\/\*[\s\S]*?\*\//
-	],
+	'comment': {
+		pattern: /\/\*[\s\S]*?\*\/|%.*/,
+		greedy: true
+	},
 	// Depending on the implementation, strings may allow escaped newlines and quote-escape
 	'string': {
-		pattern: /(["'])(?:\1\1|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
+		pattern: /(["'])(?:\1\1|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1(?!\1)/,
 		greedy: true
 	},
 	'builtin': /\b(?:fx|fy|xf[xy]?|yfx?)\b/,
-	'variable': /\b[A-Z_]\w*/,
 	// FIXME: Should we list all null-ary predicates (not followed by a parenthesis) like halt, trace, etc.?
 	'function': /\b[a-z]\w*(?:(?=\()|\/\d+)/,
 	'number': /\b\d+(?:\.\d*)?/,
diff --git a/components/prism-prolog.min.js b/components/prism-prolog.min.js
index 1739018..531b2fd 100644
--- a/components/prism-prolog.min.js
+++ b/components/prism-prolog.min.js
@@ -1 +1 @@
-Prism.languages.prolog={comment:[/%.+/,/\/\*[\s\S]*?\*\//],string:{pattern:/(["'])(?:\1\1|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},builtin:/\b(?:fx|fy|xf[xy]?|yfx?)\b/,variable:/\b[A-Z_]\w*/,function:/\b[a-z]\w*(?:(?=\()|\/\d+)/,number:/\b\d+(?:\.\d*)?/,operator:/[:\\=><\-?*@\/;+^|!$.]+|\b(?:is|mod|not|xor)\b/,punctuation:/[(){}\[\],]/};
\ No newline at end of file
+Prism.languages.prolog={comment:{pattern:/\/\*[\s\S]*?\*\/|%.*/,greedy:!0},string:{pattern:/(["'])(?:\1\1|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1(?!\1)/,greedy:!0},builtin:/\b(?:fx|fy|xf[xy]?|yfx?)\b/,function:/\b[a-z]\w*(?:(?=\()|\/\d+)/,number:/\b\d+(?:\.\d*)?/,operator:/[:\\=><\-?*@\/;+^|!$.]+|\b(?:is|mod|not|xor)\b/,punctuation:/[(){}\[\],]/};
\ No newline at end of file
diff --git a/tests/languages/prolog/variable_feature.test b/tests/languages/prolog/variable_feature.test
deleted file mode 100644
index 555c2ef..0000000
--- a/tests/languages/prolog/variable_feature.test
+++ /dev/null
@@ -1,15 +0,0 @@
-Foobar
-Foo_bar_42
-_foo
-
-----------------------------------------------------
-
-[
-	["variable", "Foobar"],
-	["variable", "Foo_bar_42"],
-	["variable", "_foo"]
-]
-
-----------------------------------------------------
-
-Checks for variables.
\ No newline at end of file