Prolog: Removed variable token + minor improvements (#3247)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
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