source: node_modules/refractor/lang/hcl.js

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: 2.1 KB
Line 
1'use strict'
2
3module.exports = hcl
4hcl.displayName = 'hcl'
5hcl.aliases = []
6function hcl(Prism) {
7 Prism.languages.hcl = {
8 comment: /(?:\/\/|#).*|\/\*[\s\S]*?(?:\*\/|$)/,
9 heredoc: {
10 pattern: /<<-?(\w+\b)[\s\S]*?^[ \t]*\1/m,
11 greedy: true,
12 alias: 'string'
13 },
14 keyword: [
15 {
16 pattern:
17 /(?:data|resource)\s+(?:"(?:\\[\s\S]|[^\\"])*")(?=\s+"[\w-]+"\s+\{)/i,
18 inside: {
19 type: {
20 pattern: /(resource|data|\s+)(?:"(?:\\[\s\S]|[^\\"])*")/i,
21 lookbehind: true,
22 alias: 'variable'
23 }
24 }
25 },
26 {
27 pattern:
28 /(?:backend|module|output|provider|provisioner|variable)\s+(?:[\w-]+|"(?:\\[\s\S]|[^\\"])*")\s+(?=\{)/i,
29 inside: {
30 type: {
31 pattern:
32 /(backend|module|output|provider|provisioner|variable)\s+(?:[\w-]+|"(?:\\[\s\S]|[^\\"])*")\s+/i,
33 lookbehind: true,
34 alias: 'variable'
35 }
36 }
37 },
38 /[\w-]+(?=\s+\{)/
39 ],
40 property: [/[-\w\.]+(?=\s*=(?!=))/, /"(?:\\[\s\S]|[^\\"])+"(?=\s*[:=])/],
41 string: {
42 pattern:
43 /"(?:[^\\$"]|\\[\s\S]|\$(?:(?=")|\$+(?!\$)|[^"${])|\$\{(?:[^{}"]|"(?:[^\\"]|\\[\s\S])*")*\})*"/,
44 greedy: true,
45 inside: {
46 interpolation: {
47 pattern: /(^|[^$])\$\{(?:[^{}"]|"(?:[^\\"]|\\[\s\S])*")*\}/,
48 lookbehind: true,
49 inside: {
50 type: {
51 pattern:
52 /(\b(?:count|data|local|module|path|self|terraform|var)\b\.)[\w\*]+/i,
53 lookbehind: true,
54 alias: 'variable'
55 },
56 keyword: /\b(?:count|data|local|module|path|self|terraform|var)\b/i,
57 function: /\w+(?=\()/,
58 string: {
59 pattern: /"(?:\\[\s\S]|[^\\"])*"/,
60 greedy: true
61 },
62 number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i,
63 punctuation: /[!\$#%&'()*+,.\/;<=>@\[\\\]^`{|}~?:]/
64 }
65 }
66 }
67 },
68 number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i,
69 boolean: /\b(?:false|true)\b/i,
70 punctuation: /[=\[\]{}]/
71 }
72}
Note: See TracBrowser for help on using the repository browser.