From e26df9d508296abdbb3c244c0d60fff61702a0f1 Mon Sep 17 00:00:00 2001 From: Ephellon Date: Thu, 17 Aug 2017 22:03:37 -0500 Subject: [PATCH] Create lang-paramour.js --- src/lang-paramour.js | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/lang-paramour.js diff --git a/src/lang-paramour.js b/src/lang-paramour.js new file mode 100644 index 00000000..9935393f --- /dev/null +++ b/src/lang-paramour.js @@ -0,0 +1,58 @@ +/** + * @license + * Copyright (C) 2015 Google Inc. + * + * 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 Paramour + * + * + * To use, include prettify.js and this file in your HTML page. + * Then put your code in an HTML tag like + *
(my paramour code)
+ * This file supports the following language extensions: + * lang-paramour - Paramour + * + * @author cerech@google.com + * @author GitHub @ephellon + */ + +PR['registerLangHandler']( + PR['createSimpleLexer']( + [ + //whitespace + [PR['PR_PLAIN'], /^[ \n\r\t\v\f\0]+/, null, ' \n\r\t\v\f\0'], + //string literals + [PR['PR_STRING'], /^"(?:[^"\\]|(?:\\.)|(?:\\\((?:[^"\\)]|\\.)*\)))*"/, null, '"'] + ], + [ + //floating point literals + [PR['PR_LITERAL'], /^(?:(?:0x[\da-fA-F][\da-fA-F_]*\.[\da-fA-F][\da-fA-F_]*[pP]?)|(?:\d[\d_]*\.\d[\d_]*[eE]?))[+-]?\d[\d_]*/, null], + //integer literals + [PR['PR_LITERAL'], /^-?(?:(?:0(?:(?:b[01][01_]*)|(?:o[0-7][0-7_]*)|(?:x[\da-fA-F][\da-fA-F_]*)))|(?:\d[\d_]*))/, null], + //some other literals + [PR['PR_LITERAL'], /^(?:true|false|nil)\b/, null], + //keywords + [PR['PR_KEYWORD'], /^\b(?:__COLUMN__|__FILE__|__FUNCTION__|__LINE__|#available|#else|#elseif|#endif|#if|#line|arch|arm|arm64|associativity|as|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|extension|fallthrough|final|for|func|get|guard|import|indirect|infix|init|inout|internal|i386|if|in|iOS|iOSApplicationExtension|is|lazy|left|let|mutating|none|nonmutating|operator|optional|OSX|OSXApplicationExtension|override|postfix|precedence|prefix|private|protocol|Protocol|public|required|rethrows|return|right|safe|self|set|static|struct|subscript|super|switch|throw|try|Type|typealias|unowned|unsafe|var|weak|watchOS|while|willSet|x86_64)\b/, null], + //double slash comments + [PR['PR_COMMENT'], /^\/\/.*?[\n\r]/, null], + //slash star comments + [PR['PR_COMMENT'], /^\/\*[\s\S]*?(?:\*\/|$)/, null], + //punctuation + [PR['PR_PUNCTUATION'], /^<<=|<=|<<|>>=|>=|>>|===|==|\.\.\.|&&=|\.\.<|!==|!=|&=|~=|~|\(|\)|\[|\]|{|}|@|#|;|\.|,|:|\|\|=|\?\?|\|\||&&|&\*|&\+|&-|&=|\+=|-=|\/=|\*=|\^=|%=|\|=|->|`|==|\+\+|--|\/|\+|!|\*|%|<|>|&|\||\^|\?|=|-|_/, null], + [PR['PR_TYPE'], /^\b(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/, null] //borrowing the type regex given by the main program for C-family languages + ]), + ['paramour']);