From dafa06269717caf3333ac8a78857a10e498eec3f Mon Sep 17 00:00:00 2001 From: Alexander Kogtenkov <935198+kwaxer@users.noreply.github.com> Date: Tue, 30 Oct 2018 22:04:35 +0300 Subject: [PATCH 1/7] Supported Eiffel --- loader/lang-eiffel.js | 16 +++++++++++ src/lang-eiffel.js | 59 ++++++++++++++++++++++++++++++++++++++ tests/prettify_test_2.html | 59 ++++++++++++++++++++++++++++++++++++++ tests/prettify_test_2.js | 57 +++++++++++++++++++++++++++++++++++- 4 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 loader/lang-eiffel.js create mode 100644 src/lang-eiffel.js diff --git a/loader/lang-eiffel.js b/loader/lang-eiffel.js new file mode 100644 index 00000000..d7fc53df --- /dev/null +++ b/loader/lang-eiffel.js @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 Alexander Kogtenkov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^\s+/,null,' \r\n\t\xA0'],["str",/^(?:'''|'[^']+')/,null,"'"],["str",/^"(?:(?:%[ \t\v]*[\r\n]\s*%|%"|[^"\r\n])*|\[(?=\s*[\r\n])[\s\S]*[\r\n]\s*\]|\{(?=\s*[\r\n])[\s\S]*[\r\n]\s*\})"/,null,'"'],["lit",/^0[bcx][a-f\d](?:[_a-f\d]*[a-f\d])?|(?:\d(?:[_\d]*\d)?(?:\.(?:\d(?:[_\d]*\d)?)?(?:e[-+]?\d+)?)?)/i,null,'0123456789']],[["com",/^--[^\r\n]*/],["kwd",/^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|then|undefine|until|variant|when|xor)\b/i],["kwd",/^\b(?:Current|Precursor|Result)\b/i],["lit",/^\b(?:False|True|Void)\b/i],["typ",/^[A-Z][_A-Z\d]*/],["lit",/^\.\d(?:[_\d]*\d)?(?:e[-+]?\d+)?/i],["pln",/^[a-z]\w*/iu],["pun",/^[^\s\w]+/]]),['eiffel','e']); diff --git a/src/lang-eiffel.js b/src/lang-eiffel.js new file mode 100644 index 00000000..dfd5b395 --- /dev/null +++ b/src/lang-eiffel.js @@ -0,0 +1,59 @@ +/** + * @license + * Copyright (C) 2018 Alexander Kogtenkov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview + * Registers a language handler for Eiffel. + * + * To use, include prettify.js and this file in your HTML page. + * Then put your code in an HTML tag like + *
(my Eiffel code)
+ * + * @author Alexander Kogtenkov + */ + +PR.registerLangHandler( + PR.createSimpleLexer( + [ // shortcutStylePatterns + // Whitespace + [PR['PR_PLAIN'], /^\s+/, null, ' \r\n\t\xA0'], + // Character + [PR['PR_STRING'], /^(?:'''|'[^']+')/, null, "'"], + // String + [PR['PR_STRING'], /^"(?:(?:%[ \t\v]*[\r\n]\s*%|%"|[^"\r\n])*|\[(?=\s*[\r\n])[\s\S]*[\r\n]\s*\]|\{(?=\s*[\r\n])[\s\S]*[\r\n]\s*\})"/, null, '"'], + // Integer or real starting from a digit + [PR['PR_LITERAL'], /^0[bcx][a-f\d](?:[_a-f\d]*[a-f\d])?|(?:\d(?:[_\d]*\d)?(?:\.(?:\d(?:[_\d]*\d)?)?(?:e[-+]?\d+)?)?)/i, null, '0123456789'] + ], + [ // fallthroughStylePatterns + // A line comment + [PR['PR_COMMENT'], /^--[^\r\n]*/], + // Keyword + [PR['PR_KEYWORD'], /^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|then|undefine|until|variant|when|xor)\b/i], + // A reserved word: entity + [PR['PR_KEYWORD'], /^\b(?:Current|Precursor|Result)\b/i], + // A reserved word: value + [PR['PR_LITERAL'], /^\b(?:False|True|Void)\b/i], + // Treat an upper case identifier as a type + [PR['PR_TYPE'], /^[A-Z][_A-Z\d]*/], + // Real starting from a dot + [PR['PR_LITERAL'], /^\.\d(?:[_\d]*\d)?(?:e[-+]?\d+)?/i], + // Identifier + [PR['PR_PLAIN'], /^[a-z]\w*/iu], + // Other symbols + [PR['PR_PUNCTUATION'], /^[^\s\w]+/] + ]), + ['eiffel','e']); diff --git a/tests/prettify_test_2.html b/tests/prettify_test_2.html index c62e032b..39242b29 100644 --- a/tests/prettify_test_2.html +++ b/tests/prettify_test_2.html @@ -25,6 +25,7 @@ 'lang-clj.js', 'lang-css.js', 'lang-dart.js', + 'lang-eiffel.js', 'lang-ex.js', 'lang-kotlin.js', 'lang-lisp.js', @@ -1201,5 +1202,63 @@

Kotlin

fun Boolean?.getOrThrow(): Boolean = this ?: throw Exception() + +

Eiffel

+
+note
+	description: "[
+		A test class with "string" literals, numbers, etc.
+	]"
+	usage: "[testing %"quotes%"]"
+
+class POLYGON
+
+inherit
+	ANY
+		rename
+			default_create as make
+		redefine
+			make,
+			out
+		end
+
+feature {NONE} -- Creation
+
+	make
+			-- Set coordinates to (0, 0).
+		do
+			x_offset := 0
+			y_offset := 123 - 0c124 + 0b001 + 1.0 + 1. - .0 + .1e3 - 1.e03 + (1_234.567_8 - 12_345.678e-1)
+		end
+
+feature -- Access
+
+	x_offset, y_offset: INTEGER_64
+			-- Offset of the polygon.
+
+	mask: NATURAL_8 = 0xA5
+			-- A color mask.
+
+feature -- Output
+
+	out: STRING
+			-- <Precursor>
+		do
+			Result :=
+				"An old-style %
+				%multi-line string with " +
+				"%
+				%%"quotes%"%
+				%" +
+				"{
+					and a "new"-style one.
+				}"
+		ensure then
+			result_attached: Result /= Void
+		end
+
+end
+
+ diff --git a/tests/prettify_test_2.js b/tests/prettify_test_2.js index 03e29f5a..2a762890 100644 --- a/tests/prettify_test_2.js +++ b/tests/prettify_test_2.js @@ -1068,5 +1068,60 @@ var goldens = { ' `END`ATV~C<hello>`END`PLN\n' + ' `END`KWDend`END`PLN\n' + '\n' + -'`END`KWDend`END') +'`END`KWDend`END'), + eiffel: ( + '`KWDnote`END`PLN\n' + + ' description`END`PUN:`END`PLN `END`STR"[\n' + + ' A test class with "string" literals, numbers, etc.\n' + + ' ]"`END`PLN\n' + + ' usage`END`PUN:`END`PLN `END`STR"[testing %"quotes%"]"`END`PLN\n' + + '\n' + + '`END`KWDclass`END`PLN `END`TYPPOLYGON`END`PLN\n' + + '\n' + + '`END`KWDinherit`END`PLN\n' + + ' `END`TYPANY`END`PLN\n' + + ' `END`KWDrename`END`PLN\n' + + ' default_create `END`KWDas`END`PLN make\n' + + ' `END`KWDredefine`END`PLN\n' + + ' make`END`PUN,`END`PLN\n' + + ' out\n' + + ' `END`KWDend`END`PLN\n' + + '\n' + + '`END`KWDfeature`END`PLN `END`PUN{`END`TYPNONE`END`PUN}`END`PLN `END`COM-- Creation`END`PLN\n' + + '\n' + + ' make\n' + + ' `END`COM-- Set coordinates to (0, 0).`END`PLN\n' + + ' `END`KWDdo`END`PLN\n' + + ' x_offset `END`PUN:=`END`PLN `END`LIT0`END`PLN\n' + + ' y_offset `END`PUN:=`END`PLN `END`LIT123`END`PLN `END`PUN-`END`PLN `END`LIT0c124`END`PLN `END`PUN+`END`PLN `END`LIT0b001`END`PLN `END`PUN+`END`PLN `END`LIT1.0`END`PLN `END`PUN+`END`PLN `END`LIT1.`END`PLN `END`PUN-`END`PLN `END`LIT.0`END`PLN `END`PUN+`END`PLN `END`LIT.1e3`END`PLN `END`PUN-`END`PLN `END`LIT1.e03`END`PLN `END`PUN+`END`PLN `END`PUN(`END`LIT1_234.567_8`END`PLN `END`PUN-`END`PLN `END`LIT12_345.678e-1`END`PUN)`END`PLN\n' + + ' `END`KWDend`END`PLN\n' + + '\n' + + '`END`KWDfeature`END`PLN `END`COM-- Access`END`PLN\n' + + '\n' + + ' x_offset`END`PUN,`END`PLN y_offset`END`PUN:`END`PLN `END`TYPINTEGER_64`END`PLN\n' + + ' `END`COM-- Offset of the polygon.`END`PLN\n' + + '\n' + + ' mask`END`PUN:`END`PLN `END`TYPNATURAL_8`END`PLN `END`PUN=`END`PLN `END`LIT0xA5`END`PLN\n' + + ' `END`COM-- A color mask.`END`PLN\n' + + '\n' + + '`END`KWDfeature`END`PLN `END`COM-- Output`END`PLN\n' + + '\n' + + ' out`END`PUN:`END`PLN `END`TYPSTRING`END`PLN\n' + + ' `END`COM-- <Precursor>`END`PLN\n' + + ' `END`KWDdo`END`PLN\n' + + ' `END`KWDResult`END`PLN `END`PUN:=`END`PLN\n' + + ' `END`STR"An old-style %\n' + + ' %multi-line string with "`END`PLN `END`PUN+`END`PLN\n' + + ' `END`STR"%\n' + + ' %%"quotes%"%\n' + + ' %"`END`PLN `END`PUN+`END`PLN\n' + + ' `END`STR"{\n' + + ' and a "new"-style one.\n' + + ' }"`END`PLN\n' + + ' `END`KWDensure`END`PLN `END`KWDthen`END`PLN\n' + + ' result_attached`END`PUN:`END`PLN `END`KWDResult`END`PLN `END`PUN/=`END`PLN `END`LITVoid`END`PLN\n' + + ' `END`KWDend`END`PLN\n' + + '\n' + + '`END`KWDend`END' + ) }; From 99322d0d4dd87aa985d1c2d08c4524e63cea68f6 Mon Sep 17 00:00:00 2001 From: Alexander Kogtenkov <935198+kwaxer@users.noreply.github.com> Date: Tue, 30 Oct 2018 22:50:23 +0300 Subject: [PATCH 2/7] Added a keyword "some". --- src/lang-eiffel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lang-eiffel.js b/src/lang-eiffel.js index dfd5b395..9655be46 100644 --- a/src/lang-eiffel.js +++ b/src/lang-eiffel.js @@ -42,7 +42,7 @@ PR.registerLangHandler( // A line comment [PR['PR_COMMENT'], /^--[^\r\n]*/], // Keyword - [PR['PR_KEYWORD'], /^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|then|undefine|until|variant|when|xor)\b/i], + [PR['PR_KEYWORD'], /^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|some|then|undefine|until|variant|when|xor)\b/i], // A reserved word: entity [PR['PR_KEYWORD'], /^\b(?:Current|Precursor|Result)\b/i], // A reserved word: value From 6880d6bae3dfd97ab1a47b63f61dfef179ddfd96 Mon Sep 17 00:00:00 2001 From: Alexander Kogtenkov <935198+kwaxer@users.noreply.github.com> Date: Tue, 30 Oct 2018 22:50:23 +0300 Subject: [PATCH 3/7] Added a keyword "some". --- loader/lang-eiffel.js | 4 ++-- src/lang-eiffel.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/loader/lang-eiffel.js b/loader/lang-eiffel.js index d7fc53df..ef0cc8f7 100644 --- a/loader/lang-eiffel.js +++ b/loader/lang-eiffel.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Alexander Kogtenkov + * Copyright (C) 2018-2019 Alexander Kogtenkov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -PR.registerLangHandler(PR.createSimpleLexer([["pln",/^\s+/,null,' \r\n\t\xA0'],["str",/^(?:'''|'[^']+')/,null,"'"],["str",/^"(?:(?:%[ \t\v]*[\r\n]\s*%|%"|[^"\r\n])*|\[(?=\s*[\r\n])[\s\S]*[\r\n]\s*\]|\{(?=\s*[\r\n])[\s\S]*[\r\n]\s*\})"/,null,'"'],["lit",/^0[bcx][a-f\d](?:[_a-f\d]*[a-f\d])?|(?:\d(?:[_\d]*\d)?(?:\.(?:\d(?:[_\d]*\d)?)?(?:e[-+]?\d+)?)?)/i,null,'0123456789']],[["com",/^--[^\r\n]*/],["kwd",/^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|then|undefine|until|variant|when|xor)\b/i],["kwd",/^\b(?:Current|Precursor|Result)\b/i],["lit",/^\b(?:False|True|Void)\b/i],["typ",/^[A-Z][_A-Z\d]*/],["lit",/^\.\d(?:[_\d]*\d)?(?:e[-+]?\d+)?/i],["pln",/^[a-z]\w*/iu],["pun",/^[^\s\w]+/]]),['eiffel','e']); +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^\s+/,null,' \r\n\t\xA0'],["str",/^(?:'''|'[^']+')/,null,"'"],["str",/^"(?:(?:%[ \t\v]*[\r\n]\s*%|%"|[^"\r\n])*|\[(?=\s*[\r\n])[\s\S]*[\r\n]\s*\]|\{(?=\s*[\r\n])[\s\S]*[\r\n]\s*\})"/,null,'"'],["lit",/^0[bcx][a-f\d](?:[_a-f\d]*[a-f\d])?|(?:\d(?:[_\d]*\d)?(?:\.(?:\d(?:[_\d]*\d)?)?(?:e[-+]?\d+)?)?)/i,null,'0123456789']],[["com",/^--[^\r\n]*/],["kwd",/^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|some|then|undefine|until|variant|when|xor)\b/i],["kwd",/^\b(?:Current|Precursor|Result)\b/i],["lit",/^\b(?:False|True|Void)\b/i],["typ",/^[A-Z][_A-Z\d]*/],["lit",/^\.\d(?:[_\d]*\d)?(?:e[-+]?\d+)?/i],["pln",/^[a-z]\w*/iu],["pun",/^[^\s\w]+/]]),['eiffel','e']); diff --git a/src/lang-eiffel.js b/src/lang-eiffel.js index dfd5b395..9655be46 100644 --- a/src/lang-eiffel.js +++ b/src/lang-eiffel.js @@ -42,7 +42,7 @@ PR.registerLangHandler( // A line comment [PR['PR_COMMENT'], /^--[^\r\n]*/], // Keyword - [PR['PR_KEYWORD'], /^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|then|undefine|until|variant|when|xor)\b/i], + [PR['PR_KEYWORD'], /^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|some|then|undefine|until|variant|when|xor)\b/i], // A reserved word: entity [PR['PR_KEYWORD'], /^\b(?:Current|Precursor|Result)\b/i], // A reserved word: value From 93f64f429fbd553b21455f75b2b72ca1b063c6c8 Mon Sep 17 00:00:00 2001 From: Alexander Kogtenkov <935198+kwaxer@users.noreply.github.com> Date: Tue, 17 Mar 2020 20:13:01 +0300 Subject: [PATCH 4/7] Added reserved symbols for symbolic forms of loops. Made sure punctuation rule stops when at a literal character or string boundary as well as at a loop symbol. --- src/lang-eiffel.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lang-eiffel.js b/src/lang-eiffel.js index 9655be46..7a3a254b 100644 --- a/src/lang-eiffel.js +++ b/src/lang-eiffel.js @@ -45,6 +45,8 @@ PR.registerLangHandler( [PR['PR_KEYWORD'], /^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|some|then|undefine|until|variant|when|xor)\b/i], // A reserved word: entity [PR['PR_KEYWORD'], /^\b(?:Current|Precursor|Result)\b/i], + // A reserved symbol: syntax (for_all, there_exists, broken_bar, clockwise_gapped_circle_arrow, anticlockwise_gapped_circle_arrow) + [PR['PR_KEYWORD'], /^(?<=[^\u0080-\uFFFF\w])[\u2200\u2203\xA6\u27F3\u27F2](?=[\s\xA0\w])/i], // A reserved word: value [PR['PR_LITERAL'], /^\b(?:False|True|Void)\b/i], // Treat an upper case identifier as a type @@ -54,6 +56,6 @@ PR.registerLangHandler( // Identifier [PR['PR_PLAIN'], /^[a-z]\w*/iu], // Other symbols - [PR['PR_PUNCTUATION'], /^[^\s\w]+/] + [PR['PR_PUNCTUATION'], /^[^\s\xA0\w'"\u2200\u2203\xA6\u27F3\u27F2]+/] ]), ['eiffel','e']); From f18f44bb8c8e6a2c78fbf505906fca85a60392c0 Mon Sep 17 00:00:00 2001 From: Alexander Kogtenkov <935198+kwaxer@users.noreply.github.com> Date: Tue, 17 Mar 2020 20:16:56 +0300 Subject: [PATCH 5/7] Updated copyright years. --- src/lang-eiffel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lang-eiffel.js b/src/lang-eiffel.js index 7a3a254b..b1008605 100644 --- a/src/lang-eiffel.js +++ b/src/lang-eiffel.js @@ -1,6 +1,6 @@ /** * @license - * Copyright (C) 2018 Alexander Kogtenkov + * Copyright (C) 2018-2020 Alexander Kogtenkov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From ea463f8eda5e5e50fcf5293d837d52405d29f449 Mon Sep 17 00:00:00 2001 From: Alexander Kogtenkov <935198+kwaxer@users.noreply.github.com> Date: Tue, 17 Mar 2020 22:03:46 +0300 Subject: [PATCH 6/7] Specified unicode modifier to handle non-ASCII white space as expected. Removed look-ahead and look-behind groups in regular expressions that do not seem to be supported. Updated loader version of the script to match the standard one. --- loader/lang-eiffel.js | 4 ++-- src/lang-eiffel.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/loader/lang-eiffel.js b/loader/lang-eiffel.js index ef0cc8f7..31133a2f 100644 --- a/loader/lang-eiffel.js +++ b/loader/lang-eiffel.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 Alexander Kogtenkov + * Copyright (C) 2018-2020 Alexander Kogtenkov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -PR.registerLangHandler(PR.createSimpleLexer([["pln",/^\s+/,null,' \r\n\t\xA0'],["str",/^(?:'''|'[^']+')/,null,"'"],["str",/^"(?:(?:%[ \t\v]*[\r\n]\s*%|%"|[^"\r\n])*|\[(?=\s*[\r\n])[\s\S]*[\r\n]\s*\]|\{(?=\s*[\r\n])[\s\S]*[\r\n]\s*\})"/,null,'"'],["lit",/^0[bcx][a-f\d](?:[_a-f\d]*[a-f\d])?|(?:\d(?:[_\d]*\d)?(?:\.(?:\d(?:[_\d]*\d)?)?(?:e[-+]?\d+)?)?)/i,null,'0123456789']],[["com",/^--[^\r\n]*/],["kwd",/^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|some|then|undefine|until|variant|when|xor)\b/i],["kwd",/^\b(?:Current|Precursor|Result)\b/i],["lit",/^\b(?:False|True|Void)\b/i],["typ",/^[A-Z][_A-Z\d]*/],["lit",/^\.\d(?:[_\d]*\d)?(?:e[-+]?\d+)?/i],["pln",/^[a-z]\w*/iu],["pun",/^[^\s\w]+/]]),['eiffel','e']); +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^\s+/u,null,' \r\n\t\xA0'],["str",/^(?:'''|'[^']+')/,null,"'"],["str",/^"(?:(?:%[ \t\v]*[\r\n]\s*%|%"|[^"\r\n])*|\[(?=\s*[\r\n])[\s\S]*[\r\n]\s*\]|\{(?=\s*[\r\n])[\s\S]*[\r\n]\s*\})"/,null,'"'],["lit",/^0[bcx][a-f\d](?:[_a-f\d]*[a-f\d])?|(?:\d(?:[_\d]*\d)?(?:\.(?:\d(?:[_\d]*\d)?)?(?:e[-+]?\d+)?)?)/i,null,'0123456789']],[["com",/^--[^\r\n]*/],["kwd",/^\b(?:across|agent|alias|all|and|as|assign|attached|attribute|check|class|convert|create|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|only|or|redefine|rename|require|rescue|retry|select|separate|some|then|undefine|until|variant|when|xor)\b/i],["kwd",/^\b(?:Current|Precursor|Result)\b/i],["kwd",/^[\u2200\u2203\xA6\u27F3\u27F2]/iu],["lit",/^\b(?:False|True|Void)\b/i],["typ",/^[A-Z][_A-Z\d]*/],["lit",/^\.\d(?:[_\d]*\d)?(?:e[-+]?\d+)?/i],["pln",/^[a-z]\w*/iu],["pun",/^[^\s\xA0\w'"\u2200\u2203\xA6\u27F3\u27F2]+/]]),['eiffel','e']); diff --git a/src/lang-eiffel.js b/src/lang-eiffel.js index b1008605..472e371d 100644 --- a/src/lang-eiffel.js +++ b/src/lang-eiffel.js @@ -30,7 +30,7 @@ PR.registerLangHandler( PR.createSimpleLexer( [ // shortcutStylePatterns // Whitespace - [PR['PR_PLAIN'], /^\s+/, null, ' \r\n\t\xA0'], + [PR['PR_PLAIN'], /^\s+/u, null, ' \r\n\t\xA0'], // Character [PR['PR_STRING'], /^(?:'''|'[^']+')/, null, "'"], // String @@ -46,7 +46,7 @@ PR.registerLangHandler( // A reserved word: entity [PR['PR_KEYWORD'], /^\b(?:Current|Precursor|Result)\b/i], // A reserved symbol: syntax (for_all, there_exists, broken_bar, clockwise_gapped_circle_arrow, anticlockwise_gapped_circle_arrow) - [PR['PR_KEYWORD'], /^(?<=[^\u0080-\uFFFF\w])[\u2200\u2203\xA6\u27F3\u27F2](?=[\s\xA0\w])/i], + [PR['PR_KEYWORD'], /^[\u2200\u2203\xA6\u27F3\u27F2]/iu], // A reserved word: value [PR['PR_LITERAL'], /^\b(?:False|True|Void)\b/i], // Treat an upper case identifier as a type From d09349f859c42920f2a93ba59f342a11681420a8 Mon Sep 17 00:00:00 2001 From: Alexander Kogtenkov <935198+kwaxer@users.noreply.github.com> Date: Tue, 17 Mar 2020 22:04:54 +0300 Subject: [PATCH 7/7] Updated Eiffel code example to include character literals and symbolic loops. --- tests/prettify_test_2.html | 2 ++ tests/prettify_test_2.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/prettify_test_2.html b/tests/prettify_test_2.html index 39242b29..69dd4e24 100644 --- a/tests/prettify_test_2.html +++ b/tests/prettify_test_2.html @@ -1253,6 +1253,8 @@

Eiffel

"{ and a "new"-style one. }" + Result.precede ('=') + Result.append_boolean (∀ x: Result ¦ x >= ' ') ensure then result_attached: Result /= Void end diff --git a/tests/prettify_test_2.js b/tests/prettify_test_2.js index 2a762890..20760080 100644 --- a/tests/prettify_test_2.js +++ b/tests/prettify_test_2.js @@ -1118,6 +1118,8 @@ var goldens = { ' `END`STR"{\n' + ' and a "new"-style one.\n' + ' }"`END`PLN\n' + + ' `END`KWDResult`END`PUN.`END`PLNprecede `END`PUN(`END`STR\'=\'`END`PUN)`END`PLN\n' + + ' `END`KWDResult`END`PUN.`END`PLNappend_boolean `END`PUN(`END`KWD\u2200`END`PLN x`END`PUN:`END`PLN `END`KWDResult`END`PLN `END`KWD\xA6`END`PLN x `END`PUN>=`END`PLN `END`STR\' \'`END`PUN)`END`PLN\n' + ' `END`KWDensure`END`PLN `END`KWDthen`END`PLN\n' + ' result_attached`END`PUN:`END`PLN `END`KWDResult`END`PLN `END`PUN/=`END`PLN `END`LITVoid`END`PLN\n' + ' `END`KWDend`END`PLN\n' +