...

Source file src/github.com/alecthomas/chroma/lexers/b/bicep.go

Documentation: github.com/alecthomas/chroma/lexers/b

     1  package b
     2  
     3  import (
     4  	"strings"
     5  
     6  	. "github.com/alecthomas/chroma" // nolint
     7  	"github.com/alecthomas/chroma/lexers/internal"
     8  )
     9  
    10  // Bicep lexer.
    11  var Bicep = internal.Register(MustNewLazyLexer(
    12  	&Config{
    13  		Name:      "Bicep",
    14  		Aliases:   []string{"bicep"},
    15  		Filenames: []string{"*.bicep"},
    16  	},
    17  	bicepRules,
    18  ))
    19  
    20  func bicepRules() Rules {
    21  	bicepFunctions := []string{
    22  		"any",
    23  		"array",
    24  		"concat",
    25  		"contains",
    26  		"empty",
    27  		"first",
    28  		"intersection",
    29  		"items",
    30  		"last",
    31  		"length",
    32  		"min",
    33  		"max",
    34  		"range",
    35  		"skip",
    36  		"take",
    37  		"union",
    38  		"dateTimeAdd",
    39  		"utcNow",
    40  		"deployment",
    41  		"environment",
    42  		"loadFileAsBase64",
    43  		"loadTextContent",
    44  		"int",
    45  		"json",
    46  		"extensionResourceId",
    47  		"getSecret",
    48  		"list",
    49  		"listKeys",
    50  		"listKeyValue",
    51  		"listAccountSas",
    52  		"listSecrets",
    53  		"pickZones",
    54  		"reference",
    55  		"resourceId",
    56  		"subscriptionResourceId",
    57  		"tenantResourceId",
    58  		"managementGroup",
    59  		"resourceGroup",
    60  		"subscription",
    61  		"tenant",
    62  		"base64",
    63  		"base64ToJson",
    64  		"base64ToString",
    65  		"dataUri",
    66  		"dataUriToString",
    67  		"endsWith",
    68  		"format",
    69  		"guid",
    70  		"indexOf",
    71  		"lastIndexOf",
    72  		"length",
    73  		"newGuid",
    74  		"padLeft",
    75  		"replace",
    76  		"split",
    77  		"startsWith",
    78  		"string",
    79  		"substring",
    80  		"toLower",
    81  		"toUpper",
    82  		"trim",
    83  		"uniqueString",
    84  		"uri",
    85  		"uriComponent",
    86  		"uriComponentToString",
    87  	}
    88  
    89  	return Rules{
    90  		"root": {
    91  			{`//[^\n\r]+`, CommentSingle, nil},
    92  			{`/\*.*?\*/`, CommentMultiline, nil},
    93  			{`([']?\w+[']?)(:)`, ByGroups(NameProperty, Punctuation), nil},
    94  			{`\b('(resourceGroup|subscription|managementGroup|tenant)')\b`, KeywordNamespace, nil},
    95  			{`'[\w\$\{\(\)\}\.]{1,}?'`, LiteralStringInterpol, nil},
    96  			{`('''|').*?('''|')`, LiteralString, nil},
    97  			{`\b(allowed|batchSize|description|maxLength|maxValue|metadata|minLength|minValue|secure)\b`, NameDecorator, nil},
    98  			{`\b(az|sys)\.`, NameNamespace, nil},
    99  			{`\b(` + strings.Join(bicepFunctions, "|") + `)\b`, NameFunction, nil},
   100  			// https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functions-logical
   101  			{`\b(bool)(\()`, ByGroups(NameFunction, Punctuation), nil},
   102  			{`\b(for|if|in)\b`, Keyword, nil},
   103  			{`\b(module|output|param|resource|var)\b`, KeywordDeclaration, nil},
   104  			{`\b(array|bool|int|object|string)\b`, KeywordType, nil},
   105  			// https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/operators
   106  			{`(>=|>|<=|<|==|!=|=~|!~|::|&&|\?\?|!|-|%|\*|\/|\+)`, Operator, nil},
   107  			{`[\(\)\[\]\.:\?{}@=]`, Punctuation, nil},
   108  			{`[\w_-]+`, Text, nil},
   109  			{`\s+`, TextWhitespace, nil},
   110  		},
   111  	}
   112  }
   113  

View as plain text