]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/qml.js
1 /*! `qml` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
8 Requires: javascript.js, xml.js
9 Author: John Foster <jfoster@esri.com>
10 Description: Syntax highlighting for the Qt Quick QML scripting language, based mostly off
11 the JavaScript parser.
12 Website: https://doc.qt.io/qt-5/qmlapplications.html
17 const regex
= hljs
.regex
;
20 'in of on if for while finally var new function do return void else break catch '
21 + 'instanceof with throw case default try this switch continue typeof delete '
22 + 'let yield const export super debugger as async await import',
24 'true false null undefined NaN Infinity',
26 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent '
27 + 'encodeURI encodeURIComponent escape unescape Object Function Boolean Error '
28 + 'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError '
29 + 'TypeError URIError Number Math Date String RegExp Array Float32Array '
30 + 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array '
31 + 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require '
32 + 'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect '
33 + 'Behavior bool color coordinate date double enumeration font geocircle georectangle '
34 + 'geoshape int list matrix4x4 parent point quaternion real rect '
35 + 'size string url variant vector2d vector3d vector4d '
39 const QML_IDENT_RE
= '[a-zA-Z_][a-zA-Z0-9\\._]*';
41 // Isolate property statements. Ends at a :, =, ;, ,, a comment or end of line.
42 // Use property class.
45 begin: '\\bproperty\\b',
48 end: '(:|=|;|,|//|/\\*|$)',
53 // Isolate signal statements. Ends at a ) a comment or end of line.
54 // Use property class.
57 begin: '\\bsignal\\b',
60 end: '(\\(|:|=|;|,|//|/\\*|$)',
65 // id: is special in QML. When we see id: we want to mark the id: as attribute and
66 // emphasize the token following.
68 className: 'attribute',
77 // Find QML object attribute. An attribute is a QML identifier followed by :.
78 // Unfortunately it's hard to know where it ends, as it may contain scalars,
79 // objects, object definitions, or javascript. The true end is either when the parent
80 // ends or the next attribute is detected.
81 const QML_ATTRIBUTE
= {
82 begin: QML_IDENT_RE
+ '\\s*:',
86 className: 'attribute',
96 // Find QML object. A QML object is a QML identifier followed by { and ends at the matching }.
97 // All we really care about is finding IDENT followed by { and just mark up the IDENT and ignore the {.
99 begin: regex
.concat(QML_IDENT_RE
, /\s*\{/),
103 contains: [ hljs
.inherit(hljs
.TITLE_MODE
, { begin: QML_IDENT_RE
}) ]
109 case_insensitive: false,
114 begin: /^\s
*['"]use (strict|asm)['"]/
116 hljs.APOS_STRING_MODE,
117 hljs.QUOTE_STRING_MODE,
123 hljs.BACKSLASH_ESCAPE,
131 hljs.C_LINE_COMMENT_MODE,
132 hljs.C_BLOCK_COMMENT_MODE,
136 { begin: '\\b(0[bB][01]+)' },
137 { begin: '\\b(0[oO][0-7]+)' },
138 { begin: hljs.C_NUMBER_RE }
142 { // "value
" container
143 begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
144 keywords: 'return throw case',
146 hljs.C_LINE_COMMENT_MODE,
147 hljs.C_BLOCK_COMMENT_MODE,
161 className: 'function',
162 beginKeywords: 'function',
166 hljs.inherit(hljs.TITLE_MODE, { begin: /[A-Za-z$_][0-9A-Za-z$_]*/ }),
174 hljs.C_LINE_COMMENT_MODE,
175 hljs.C_BLOCK_COMMENT_MODE
182 // hack: prevents detection of keywords after dots
183 begin: '\\.' + hljs.IDENT_RE,
198 hljs.registerLanguage('qml', hljsGrammar);