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