forked from googlearchive/code-prettify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlang-eiffel.js
More file actions
61 lines (59 loc) · 2.99 KB
/
lang-eiffel.js
File metadata and controls
61 lines (59 loc) · 2.99 KB
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
58
59
60
61
/**
* @license
* 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.
* 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
* <pre class="prettyprint lang-eiffel">(my Eiffel code)</pre>
*
* @author Alexander Kogtenkov
*/
PR.registerLangHandler(
PR.createSimpleLexer(
[ // shortcutStylePatterns
// Whitespace
[PR['PR_PLAIN'], /^\s+/u, 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|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'], /^[\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
[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\xA0\w'"\u2200\u2203\xA6\u27F3\u27F2]+/]
]),
['eiffel','e']);