@@ -15,55 +15,47 @@ var Terraform = internal.Register(MustNewLexer(
15
15
},
16
16
Rules {
17
17
"root" : {
18
- Include ( "string" ) ,
19
- Include ( "punctuation" ) ,
20
- Include ( "curly" ) ,
21
- Include ( "basic" ) ,
22
- Include ( "whitespace" ) ,
23
- {`[0-9]+ ` , LiteralNumber , nil },
24
- },
25
- "basic" : {
26
- {Words (`\b ` , `\b` , `true ` , `false ` ), KeywordType , nil },
27
- {`\s*/\* ` , CommentMultiline , Push ( "comment" ) },
28
- {`\s*#.*\n ` , CommentSingle , nil },
29
- {`(.*?)(\s*)(=) ` , ByGroups ( NameAttribute , Text , Operator ) , nil },
30
- {Words (`\b ` , `\b` , `variable` , `resource` , `provider` , `provisioner` , `module` ), KeywordReserved , Push ( "function" ) },
31
- {Words (`\b ` , `\b` , `ingress` , `egress` , `listener` , `default` , `connection` , `alias` ), KeywordDeclaration , nil },
32
- {`\$\{ ` , LiteralStringInterpol , Push ( "var_builtin" ) },
33
- },
34
- "function" : {
35
- {`(\s+)(".*")(\s+)` , ByGroups ( Text , LiteralString , Text ) , nil },
36
- Include ( "punctuation" ) ,
37
- Include ( "curly" ) ,
38
- },
39
- "var_builtin" : {
40
- {`\$\{ ` , LiteralStringInterpol , Push ()},
41
- {Words ( `\b` , `\b ` , `concat` , `file` , `join` , `lookup` , `element` ), NameBuiltin , nil },
42
- Include ( "string" ) ,
43
- Include ( "punctuation" ),
44
- {`\s+ ` , Text , nil },
45
- {`\} ` , LiteralStringInterpol , Pop (1 )},
18
+ { `[\[\](),.{}]` , Punctuation , nil } ,
19
+ { `-?[0-9]+` , LiteralNumber , nil } ,
20
+ { `=>` , Punctuation , nil } ,
21
+ { Words ( `` , `\b` , `true` , `false` ), KeywordConstant , nil } ,
22
+ { `/(?s)\*(((?!\*/).)*)\*/` , CommentMultiline , nil } ,
23
+ {`\s*(#|//).*\n ` , CommentSingle , nil },
24
+ { `([a-zA-Z]\w*)(\s*)(=(?!>))` , ByGroups ( NameAttribute , Text , Text ), nil },
25
+ { Words ( `^\s*` , `\b` , `variable` , `data` , `resource` , `provider` , `provisioner` , `module` , `output` ), KeywordReserved , nil },
26
+ {Words (`` , `\b` , `for ` , `in ` ), Keyword , nil },
27
+ {Words ( ` ` , `` , `count` , `data` , `var` , `module` , `each` ), NameBuiltin , nil },
28
+ {Words ( `` , `\b ` , `abs` , `ceil` , `floor` , `log` , `max` , `min` , `parseint` , `pow` , `signum` , ), NameBuiltin , nil },
29
+ {Words ( `` , `\b ` , `chomp` , `format` , `formatlist` , `indent` , `join` , `lower` , `regex` , `regexall` , `replace` , `split` , `strrev` , `substr` , `title` , `trim` , `trimprefix` , `trimsuffix` , `trimspace` , `upper` ), NameBuiltin , nil },
30
+ {Words (`[^.] ` , `\b` , `chunklist` , `coalesce` , `coalescelist` , `compact` , `concat` , `contains` , `distinct` , `element` , `flatten` , `index` , `keys` , `length` , `list` , `lookup` , `map` , `matchkeys` , `merge` , `range` , `reverse` , `setintersection` , `setproduct` , `setsubtract` , `setunion` , `slice` , `sort` , `transpose` , `values` , `zipmap` ), NameBuiltin , nil },
31
+ {Words (`[^.] ` , `\b` , `base64decode` , `base64encode` , `base64gzip` , `csvdecode` , `jsondecode` , `jsonencode` , `urlencode` , `yamldecode` , `yamlencode` ), NameBuiltin , nil },
32
+ {Words ( ` ` , `\b` , `abspath` , `dirname` , `pathexpand` , `basename` , `file` , `fileexists` , `fileset` , `filebase64` , `templatefile` ), NameBuiltin , nil },
33
+ { Words ( `` , `\b` , `formatdate` , `timeadd` , `timestamp` ), NameBuiltin , nil },
34
+ { Words ( `` , `\b` , `base64sha256` , `base64sha512` , `bcrypt` , `filebase64sha256` , `filebase64sha512` , `filemd5` , `filesha1` , `filesha256` , `filesha512` , `md5` , `rsadecrypt` , `sha1` , `sha256` , `sha512` , `uuid` , `uuidv5` ), NameBuiltin , nil },
35
+ {Words ( `` , `\b` , `cidrhost` , `cidrnetmask` , `cidrsubnet` ), NameBuiltin , nil },
36
+ { Words ( `` , `\b` , `can` , `tobool` , `tolist` , `tomap` , `tonumber` , `toset` , `tostring` , `try` ), NameBuiltin , nil } ,
37
+ { `=(?!>)|\+|-|\*|\/|:|!|%|>|<(?!<)|>=|<=|==|!=|&&|\||\?` , Operator , nil } ,
38
+ { `\n|\s+|\\\n` , Text , nil },
39
+ { `[a-zA-Z]\w*` , NameOther , nil },
40
+ {`" ` , LiteralStringDouble , Push ("string" )},
41
+ {`(?s)(<<-?)(\w+)(\n\s*(?:(?!\2).)*\s*\n\s*)(\2) ` , ByGroups ( Operator , Operator , String , Operator ) , nil },
42
+ } ,
43
+ "declaration" : {
44
+ {`(\s*)("(?:\\\\|\\"|[^"])*")(\s*) ` , ByGroups ( Text , NameVariable , Text ) , nil },
45
+ {`\{ ` , Punctuation , Pop (1 )},
46
46
},
47
47
"string" : {
48
- {`(".*")` , ByGroups (LiteralStringDouble ), nil },
49
- },
50
- "punctuation" : {
51
- {`[\[\](),.]` , Punctuation , nil },
52
- },
53
- "curly" : {
54
- {`\{` , TextPunctuation , nil },
55
- {`\}` , TextPunctuation , nil },
56
- },
57
- "comment" : {
58
- {`[^*/]` , CommentMultiline , nil },
59
- {`/\*` , CommentMultiline , Push ()},
60
- {`\*/` , CommentMultiline , Pop (1 )},
61
- {`[*/]` , CommentMultiline , nil },
62
- },
63
- "whitespace" : {
64
- {`\n` , Text , nil },
65
- {`\s+` , Text , nil },
66
- {`\\\n` , Text , nil },
48
+ {`"` , LiteralStringDouble , Pop (1 )},
49
+ {`\\\\` , LiteralStringDouble , nil },
50
+ {`\\\\"` , LiteralStringDouble , nil },
51
+ {`\$\{` , LiteralStringInterpol , Push ("interp-inside" )},
52
+ {`\$` , LiteralStringDouble , nil },
53
+ {`[^"\\\\$]+` , LiteralStringDouble , nil },
54
+ },
55
+ "interp-inside" : {
56
+ {`\}` , LiteralStringInterpol , Pop (1 )},
57
+ Include ("root" ),
67
58
},
59
+
68
60
},
69
61
))
0 commit comments