UNPKG

highlight-ts

Version:

Highlight.JS in TypeScript (and ES6).

127 lines 4.26 kB
"use strict"; /* Language: PHP Author: Victor Karamzin <Victor.Karamzin@enterra-inc.com> Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Ivan Sagalaev <maniac@softwaremaniacs.org> Category: common */ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var common_1 = require("../common"); var VARIABLE = { begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' }; var PREPROCESSOR = { className: 'meta', begin: /<\?(php)?|\?>/ }; var STRING = { className: 'string', contains: [common_1.BACKSLASH_ESCAPE, PREPROCESSOR], variants: [ { begin: 'b"', end: '"' }, { begin: 'b\'', end: '\'' }, tslib_1.__assign({}, common_1.APOS_STRING_MODE, { illegal: undefined }), tslib_1.__assign({}, common_1.QUOTE_STRING_MODE, { illegal: undefined }) ] }; var NUMBER = { variants: [common_1.BINARY_NUMBER_MODE, common_1.C_NUMBER_MODE] }; exports.PHP = { name: 'php', aliases: ['php3', 'php4', 'php5', 'php6'], case_insensitive: true, keywords: 'and include_once list abstract global private echo interface as static endswitch ' + 'array null if endwhile or const for endforeach self var while isset public ' + 'protected exit foreach throw elseif include __FILE__ empty require_once do xor ' + 'return parent clone use __CLASS__ __LINE__ else break print eval new ' + 'catch __METHOD__ case exception default die require __FUNCTION__ ' + 'enddeclare final try switch continue endfor endif declare unset true false ' + 'trait goto instanceof insteadof __DIR__ __NAMESPACE__ ' + 'yield finally', contains: [ common_1.HASH_COMMENT_MODE, common_1.COMMENT('//', '$', { contains: [PREPROCESSOR] }), common_1.COMMENT('/\\*', '\\*/', { contains: [ { className: 'doctag', begin: '@[A-Za-z]+' } ] }), common_1.COMMENT('__halt_compiler.+?;', undefined, { endsWithParent: true, keywords: '__halt_compiler', lexemes: common_1.UNDERSCORE_IDENT_RE }), { className: 'string', begin: /<<<['"]?\w+['"]?$/, end: /^\w+;?$/, contains: [ common_1.BACKSLASH_ESCAPE, { className: 'subst', variants: [ { begin: /\$\w+/ }, { begin: /\{\$/, end: /\}/ } ] } ] }, PREPROCESSOR, { className: 'keyword', begin: /\$this\b/ }, VARIABLE, { // swallow composed identifiers to avoid parsing them as keywords begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/ }, { className: 'function', beginKeywords: 'function', end: /[;{]/, excludeEnd: true, illegal: '\\$|\\[|%', contains: [ common_1.UNDERSCORE_TITLE_MODE, { className: 'params', begin: '\\(', end: '\\)', contains: [ 'self', VARIABLE, common_1.C_BLOCK_COMMENT_MODE, STRING, NUMBER ] } ] }, { className: 'class', beginKeywords: 'class interface', end: '{', excludeEnd: true, illegal: /[:\(\$"]/, contains: [ { beginKeywords: 'extends implements' }, common_1.UNDERSCORE_TITLE_MODE ] }, { beginKeywords: 'namespace', end: ';', illegal: /[\.']/, contains: [common_1.UNDERSCORE_TITLE_MODE] }, { beginKeywords: 'use', end: ';', contains: [common_1.UNDERSCORE_TITLE_MODE] }, { begin: '=>' // No markup, just a relevance booster }, STRING, NUMBER ] }; //# sourceMappingURL=php.js.map