main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | 'use strict'
|
---|
2 |
|
---|
3 | module.exports = gn
|
---|
4 | gn.displayName = 'gn'
|
---|
5 | gn.aliases = ['gni']
|
---|
6 | function gn(Prism) {
|
---|
7 | // https://gn.googlesource.com/gn/+/refs/heads/main/docs/reference.md#grammar
|
---|
8 | Prism.languages.gn = {
|
---|
9 | comment: {
|
---|
10 | pattern: /#.*/,
|
---|
11 | greedy: true
|
---|
12 | },
|
---|
13 | 'string-literal': {
|
---|
14 | pattern: /(^|[^\\"])"(?:[^\r\n"\\]|\\.)*"/,
|
---|
15 | lookbehind: true,
|
---|
16 | greedy: true,
|
---|
17 | inside: {
|
---|
18 | interpolation: {
|
---|
19 | pattern:
|
---|
20 | /((?:^|[^\\])(?:\\{2})*)\$(?:\{[\s\S]*?\}|[a-zA-Z_]\w*|0x[a-fA-F0-9]{2})/,
|
---|
21 | lookbehind: true,
|
---|
22 | inside: {
|
---|
23 | number: /^\$0x[\s\S]{2}$/,
|
---|
24 | variable: /^\$\w+$/,
|
---|
25 | 'interpolation-punctuation': {
|
---|
26 | pattern: /^\$\{|\}$/,
|
---|
27 | alias: 'punctuation'
|
---|
28 | },
|
---|
29 | expression: {
|
---|
30 | pattern: /[\s\S]+/,
|
---|
31 | inside: null // see below
|
---|
32 | }
|
---|
33 | }
|
---|
34 | },
|
---|
35 | string: /[\s\S]+/
|
---|
36 | }
|
---|
37 | },
|
---|
38 | keyword: /\b(?:else|if)\b/,
|
---|
39 | boolean: /\b(?:false|true)\b/,
|
---|
40 | 'builtin-function': {
|
---|
41 | // a few functions get special highlighting to improve readability
|
---|
42 | pattern:
|
---|
43 | /\b(?:assert|defined|foreach|import|pool|print|template|tool|toolchain)(?=\s*\()/i,
|
---|
44 | alias: 'keyword'
|
---|
45 | },
|
---|
46 | function: /\b[a-z_]\w*(?=\s*\()/i,
|
---|
47 | constant:
|
---|
48 | /\b(?:current_cpu|current_os|current_toolchain|default_toolchain|host_cpu|host_os|root_build_dir|root_gen_dir|root_out_dir|target_cpu|target_gen_dir|target_os|target_out_dir)\b/,
|
---|
49 | number: /-?\b\d+\b/,
|
---|
50 | operator: /[-+!=<>]=?|&&|\|\|/,
|
---|
51 | punctuation: /[(){}[\],.]/
|
---|
52 | }
|
---|
53 | Prism.languages.gn['string-literal'].inside['interpolation'].inside[
|
---|
54 | 'expression'
|
---|
55 | ].inside = Prism.languages.gn
|
---|
56 | Prism.languages.gni = Prism.languages.gn
|
---|
57 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.