1/** 2 * @license 3 * Copyright (C) 2014 Paulo Moura 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 Logtalk. 21 * http://logtalk.org/ 22 * @author Paulo Moura 23 */ 24 25PR['registerLangHandler']( 26 PR['createSimpleLexer']( 27 [ 28 // double-quoted strings. 29 [PR['PR_STRING'], /^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/, null, '"'], 30 // atoms (don't break on underscores!) 31 [PR['PR_LITERAL'], /^[a-z][a-zA-Z0-9_]*/], 32 // quoted atoms 33 [PR['PR_LITERAL'], /^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/, null, "'"], 34 // numbers 35 [PR['PR_LITERAL'], /^(?:0'.|0b[0-1]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i, null, '0123456789'] 36 ], 37 [ 38 // single-line comments begin with % 39 [PR['PR_COMMENT'], /^%[^\r\n]*/, null, '%'], 40 // block comments are delimited by /* and */ 41 [PR['PR_COMMENT'], /^\/\*[\s\S]*?\*\//], 42 // directives 43 [PR['PR_KEYWORD'], /^\s*:-\s(c(a(lls|tegory)|oinductive)|p(ublic|r(ot(ocol|ected)|ivate))|e(l(if|se)|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|od(e|ule)|ultifile)|reexport|s(et_(logtalk|prolog)_flag|ynchronized)|o(bject|p)|use(s|_module))/], 44 [PR['PR_KEYWORD'], /^\s*:-\s(e(lse|nd(if|_(category|object|protocol)))|built_in|dynamic|synchronized|threaded)/], 45 // variables 46 [PR['PR_TYPE'], /^[A-Z_][a-zA-Z0-9_]*/], 47 // operators 48 [PR['PR_PUNCTUATION'], /^[.,;{}:^<>=\\/+*?#!-]/] 49 ]), 50 ['logtalk', 'lgt']); 51