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