OLD | NEW |
| (Empty) |
1 // Copyright (C) 2011 Zimin A.V. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 | |
16 /** | |
17 * @fileoverview | |
18 * Registers a language handler for the Nemerle language. | |
19 * http://nemerle.org | |
20 * @author Zimin A.V. | |
21 */ | |
22 (function () { | |
23 // http://nemerle.org/wiki/index.php?title=Base_keywords | |
24 var keywords = 'abstract|and|as|base|catch|class|def|delegate|enum|event|exter
n|false|finally|' | |
25 + 'fun|implements|interface|internal|is|macro|match|matches|module|muta
ble|namespace|new|' | |
26 + 'null|out|override|params|partial|private|protected|public|ref|sealed
|static|struct|' | |
27 + 'syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatil
e|when|where|with|' | |
28 + 'assert|assert2|async|break|checked|continue|do|else|ensures|for|fore
ach|if|late|lock|new|nolate|' | |
29 + 'otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unles
s|using|while|yield'; | |
30 | |
31 PR['registerLangHandler'](PR['createSimpleLexer']( | |
32 // shortcutStylePatterns | |
33 [ | |
34 [PR['PR_STRING'], /^(?:\'(?:[^\\\'\r\n]|\\.)*\'|\"(?:[^\\\"\r\n]|\\.)*(?
:\"|$))/, null, '"'], | |
35 [PR['PR_COMMENT'], /^#(?:(?:define|elif|else|endif|error|ifdef|include|i
fndef|line|pragma|undef|warning)\b|[^\r\n]*)/, null, '#'], | |
36 [PR['PR_PLAIN'], /^\s+/, null, ' \r\n\t\xA0'] | |
37 ], | |
38 // fallthroughStylePatterns | |
39 [ | |
40 [PR['PR_STRING'], /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null], | |
41 [PR['PR_STRING'], /^<#(?:[^#>])*(?:#>|$)/, null], | |
42 [PR['PR_STRING'], /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]
+\.h|[a-z]\w*)>/, null], | |
43 [PR['PR_COMMENT'], /^\/\/[^\r\n]*/, null], | |
44 [PR['PR_COMMENT'], /^\/\*[\s\S]*?(?:\*\/|$)/, null], | |
45 [PR['PR_KEYWORD'], new RegExp('^(?:' + keywords + ')\\b'), null], | |
46 [PR['PR_TYPE'], /^(?:array|bool|byte|char|decimal|double|float|int|list|
long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/, null], | |
47 [PR['PR_LITERAL'], /^@[a-z_$][a-z_$@0-9]*/i, null], | |
48 [PR['PR_TYPE'], /^@[A-Z]+[a-z][A-Za-z_$@0-9]*/, null], | |
49 [PR['PR_PLAIN'], /^'?[A-Za-z_$][a-z_$@0-9]*/i, null], | |
50 [PR['PR_LITERAL'], new RegExp( | |
51 '^(?:' | |
52 // A hex number | |
53 + '0x[a-f0-9]+' | |
54 // or an octal or decimal number, | |
55 + '|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)' | |
56 // possibly in scientific notation | |
57 + '(?:e[+\\-]?\\d+)?' | |
58 + ')' | |
59 // with an optional modifier like UL for unsigned long | |
60 + '[a-z]*', 'i'), null, '0123456789'], | |
61 | |
62 [PR['PR_PUNCTUATION'], /^.[^\s\w\.$@\'\"\`\/\#]*/, null] | |
63 ]), | |
64 ['n', 'nemerle']); | |
65 })(); | |
OLD | NEW |