]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/zephir.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / zephir.js
1 /*! `zephir` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Zephir
7 Description: Zephir, an open source, high-level language designed to ease the creation and maintainability of extensions for PHP with a focus on type and memory safety.
8 Author: Oleg Efimov <efimovov@gmail.com>
9 Website: https://zephir-lang.com/en
10 Category: web
11 Audit: 2020
12 */
13
14 /** @type LanguageFn */
15 function zephir(hljs) {
16 const STRING = {
17 className: 'string',
18 contains: [ hljs.BACKSLASH_ESCAPE ],
19 variants: [
20 hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null }),
21 hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null })
22 ]
23 };
24 const TITLE_MODE = hljs.UNDERSCORE_TITLE_MODE;
25 const NUMBER = { variants: [
26 hljs.BINARY_NUMBER_MODE,
27 hljs.C_NUMBER_MODE
28 ] };
29 const KEYWORDS =
30 // classes and objects
31 'namespace class interface use extends '
32 + 'function return '
33 + 'abstract final public protected private static deprecated '
34 // error handling
35 + 'throw try catch Exception '
36 // keyword-ish things their website does NOT seem to highlight (in their own snippets)
37 // 'typeof fetch in ' +
38 // operators/helpers
39 + 'echo empty isset instanceof unset '
40 // assignment/variables
41 + 'let var new const self '
42 // control
43 + 'require '
44 + 'if else elseif switch case default '
45 + 'do while loop for continue break '
46 + 'likely unlikely '
47 // magic constants
48 // https://github.com/phalcon/zephir/blob/master/Library/Expression/Constants.php
49 + '__LINE__ __FILE__ __DIR__ __FUNCTION__ __CLASS__ __TRAIT__ __METHOD__ __NAMESPACE__ '
50 // types - https://docs.zephir-lang.com/0.12/en/types
51 + 'array boolean float double integer object resource string '
52 + 'char long unsigned bool int uint ulong uchar '
53 // built-ins
54 + 'true false null undefined';
55
56 return {
57 name: 'Zephir',
58 aliases: [ 'zep' ],
59 keywords: KEYWORDS,
60 contains: [
61 hljs.C_LINE_COMMENT_MODE,
62 hljs.COMMENT(
63 /\/\*/,
64 /\*\//,
65 { contains: [
66 {
67 className: 'doctag',
68 begin: /@[A-Za-z]+/
69 }
70 ] }
71 ),
72 {
73 className: 'string',
74 begin: /<<<['"]?\w+['"]?$/,
75 end: /^\w+;/,
76 contains: [ hljs.BACKSLASH_ESCAPE ]
77 },
78 {
79 // swallow composed identifiers to avoid parsing them as keywords
80 begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/ },
81 {
82 className: 'function',
83 beginKeywords: 'function fn',
84 end: /[;{]/,
85 excludeEnd: true,
86 illegal: /\$|\[|%/,
87 contains: [
88 TITLE_MODE,
89 {
90 className: 'params',
91 begin: /\(/,
92 end: /\)/,
93 keywords: KEYWORDS,
94 contains: [
95 'self',
96 hljs.C_BLOCK_COMMENT_MODE,
97 STRING,
98 NUMBER
99 ]
100 }
101 ]
102 },
103 {
104 className: 'class',
105 beginKeywords: 'class interface',
106 end: /\{/,
107 excludeEnd: true,
108 illegal: /[:($"]/,
109 contains: [
110 { beginKeywords: 'extends implements' },
111 TITLE_MODE
112 ]
113 },
114 {
115 beginKeywords: 'namespace',
116 end: /;/,
117 illegal: /[.']/,
118 contains: [ TITLE_MODE ]
119 },
120 {
121 beginKeywords: 'use',
122 end: /;/,
123 contains: [ TITLE_MODE ]
124 },
125 { begin: /=>/ // No markup, just a relevance booster
126 },
127 STRING,
128 NUMBER
129 ]
130 };
131 }
132
133 return zephir;
134
135 })();
136 ;
137 export default hljsGrammar;