-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e289ec6
commit c1dce99
Showing
13 changed files
with
360 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// based loosely upon: https://github.com/Azure/bicep/blob/main/src/textmate/bicep.tmlanguage | ||
Prism.languages.bicep = { | ||
'comment': [ | ||
{ | ||
// multiline comments eg /* ASDF */ | ||
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, | ||
lookbehind: true, | ||
greedy: true | ||
}, | ||
{ | ||
// singleline comments eg // ASDF | ||
pattern: /(^|[^\\:])\/\/.*/, | ||
lookbehind: true, | ||
greedy: true | ||
} | ||
], | ||
'string': { | ||
// this doesn't handle string interpolalation or multiline strings as yet | ||
pattern: /'(?:\\.|[^'\\\r\n])*'/, | ||
greedy: true | ||
}, | ||
'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i, | ||
'boolean': /\b(?:true|false)\b/, | ||
'keyword': /\b(?:targetScope|resource|module|param|var|output|for|in|if|existing|null)\b/, // https://github.com/Azure/bicep/blob/114a3251b4e6e30082a58729f19a8cc4e374ffa6/src/textmate/bicep.tmlanguage#L184 | ||
'function': /\b(?:array|concat|contains|createArray|empty|first|intersection|last|length|max|min|range|skip|take|union)(?:\$|\b)/, // https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-array | ||
'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/, | ||
'punctuation': /[{}[\];(),.:]/, | ||
'decorator': /@\w+\b/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h2>Variable assignment</h2> | ||
<pre><code>var foo = 'bar'</code></pre> | ||
|
||
<h2>Operators</h2> | ||
<pre><code>(1 + 2 * 3)/4 >= 3 && 4 < 5 || 6 > 7</code></pre> | ||
|
||
<h2>Keywords</h2> | ||
<pre><code>resource appServicePlan 'Microsoft.Web/serverfarms@2020-09-01' existing = = if (diagnosticsEnabled) { | ||
name: logAnalyticsWsName | ||
} | ||
module cosmosDb './cosmosdb.bicep' = { | ||
name: 'cosmosDbDeploy' | ||
} | ||
param env string | ||
var oneNumber = 123 | ||
output databaseName string = cosmosdbDatabaseName | ||
for item in cosmosdbAllowedIpAddresses: { | ||
ipAddressOrRange: item | ||
}</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
true | ||
false | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "true"], | ||
["boolean", "false"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for booleans. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@secure() | ||
param demoPassword string | ||
@allowed([ | ||
'one' | ||
'two' | ||
]) | ||
param demoEnum string | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["decorator", "@secure"], ["punctuation", "("], ["punctuation", ")"], | ||
["keyword", "param"], " demoPassword string\r\n", | ||
["decorator", "@allowed"], ["punctuation", "("], ["punctuation", "["], | ||
["string", "'one'"], | ||
["string", "'two'"], | ||
["punctuation", "]"], ["punctuation", ")"], | ||
["keyword", "param"], " demoEnum string" | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for functions. Also checks for unicode characters in identifiers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
array | ||
concat | ||
contains | ||
createArray | ||
empty | ||
first | ||
intersection | ||
last | ||
length | ||
max | ||
min | ||
range | ||
skip | ||
take | ||
union | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "array"], | ||
["function", "concat"], | ||
["function", "contains"], | ||
["function", "createArray"], | ||
["function", "empty"], | ||
["function", "first"], | ||
["function", "intersection"], | ||
["function", "last"], | ||
["function", "length"], | ||
["function", "max"], | ||
["function", "min"], | ||
["function", "range"], | ||
["function", "skip"], | ||
["function", "take"], | ||
["function", "union"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for functions. Based upon https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
targetScope | ||
resource appServicePlan 'Microsoft.Web/serverfarms@2020-09-01' existing = = if (diagnosticsEnabled) { | ||
name: logAnalyticsWsName | ||
} | ||
module cosmosDb './cosmosdb.bicep' = { | ||
name: 'cosmosDbDeploy' | ||
} | ||
param env string | ||
var oneNumber = 123 | ||
output databaseName string = cosmosdbDatabaseName | ||
for item in cosmosdbAllowedIpAddresses: { | ||
ipAddressOrRange: item | ||
} | ||
if | ||
null | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "targetScope"], | ||
|
||
["keyword", "resource"], | ||
" appServicePlan ", | ||
["string", "'Microsoft.Web/serverfarms@2020-09-01'"], | ||
["keyword", "existing"], | ||
["operator", "="], | ||
["operator", "="], | ||
["keyword", "if"], | ||
["punctuation", "("], | ||
"diagnosticsEnabled", | ||
["punctuation", ")"], | ||
["punctuation", "{"], | ||
|
||
"\r\n name", | ||
["operator", ":"], | ||
" logAnalyticsWsName\r\n", | ||
|
||
["punctuation", "}"], | ||
|
||
["keyword", "module"], | ||
" cosmosDb ", | ||
["string", "'./cosmosdb.bicep'"], | ||
["operator", "="], | ||
["punctuation", "{"], | ||
|
||
"\r\n name", | ||
["operator", ":"], | ||
["string", "'cosmosDbDeploy'"], | ||
|
||
["punctuation", "}"], | ||
|
||
["keyword", "param"], | ||
" env string\r\n", | ||
|
||
["keyword", "var"], | ||
" oneNumber ", | ||
["operator", "="], | ||
["number", "123"], | ||
|
||
["keyword", "output"], | ||
" databaseName string ", | ||
["operator", "="], | ||
" cosmosdbDatabaseName\r\n", | ||
|
||
["keyword", "for"], | ||
" item ", | ||
["keyword", "in"], | ||
" cosmosdbAllowedIpAddresses", | ||
["operator", ":"], | ||
["punctuation", "{"], | ||
|
||
"\r\n\tipAddressOrRange", | ||
["operator", ":"], | ||
" item\r\n", | ||
|
||
["punctuation", "}"], | ||
|
||
["keyword", "if"], | ||
|
||
["keyword", "null"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all keywords. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
42 | ||
3.14159 | ||
4e10 | ||
3.2E+6 | ||
2.1e-10 | ||
0b1101 | ||
0o571 | ||
0xbabe | ||
0xBABE | ||
|
||
NaN | ||
Infinity | ||
|
||
123n | ||
0x123n | ||
|
||
1_000_000_000_000 | ||
1_000_000.220_720 | ||
0b0101_0110_0011_1000 | ||
0o12_34_56 | ||
0x40_76_38_6A_73 | ||
4_642_473_943_484_686_707n | ||
0.000_001 | ||
1e10_000 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "42"], | ||
["number", "3.14159"], | ||
["number", "4e10"], | ||
["number", "3.2E+6"], | ||
["number", "2.1e-10"], | ||
["number", "0"], "b1101\r\n", | ||
["number", "0"], "o571\r\n", | ||
["number", "0"], "xbabe\r\n", | ||
["number", "0"], "xBABE\r\n\r\nNaN\r\nInfinity\r\n\r\n", | ||
|
||
["number", "123"], "n\r\n", | ||
["number", "0"], "x123n\r\n\r\n", | ||
|
||
["number", "1"], | ||
"_000_000_000_000\r\n", | ||
|
||
["number", "1"], | ||
"_000_000", | ||
["punctuation", "."], | ||
["number", "220"], | ||
"_720\r\n", | ||
|
||
["number", "0"], | ||
"b0101_0110_0011_1000\r\n", | ||
|
||
["number", "0"], | ||
"o12_34_56\r\n", | ||
|
||
["number", "0"], | ||
"x40_76_38_6A_73\r\n", | ||
|
||
["number", "4"], | ||
"_642_473_943_484_686_707n\r\n", | ||
|
||
["number", "0.000"], | ||
"_001\r\n", | ||
|
||
["number", "1e10"], | ||
"_000" | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for decimal numbers, binary numbers, octal numbers, hexadecimal numbers. | ||
Also checks for keywords representing numbers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
- -- -= | ||
+ ++ += | ||
< <= << <<= | ||
> >= >> >>= >>> >>>= | ||
= == === => | ||
! != !== | ||
& && &= &&= | ||
| || |= ||= | ||
* ** *= **= | ||
/ /= ~ | ||
^ ^= % %= | ||
? : ... | ||
?? ?. ??= | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["operator", "-"], ["operator", "--"], ["operator", "-="], | ||
["operator", "+"], ["operator", "++"], ["operator", "+="], | ||
["operator", "<"], ["operator", "<="], ["operator", "<<"], ["operator", "<<="], | ||
["operator", ">"], ["operator", ">="], ["operator", ">>"], ["operator", ">>="], ["operator", ">>>"], ["operator", ">>>="], | ||
["operator", "="], ["operator", "=="], ["operator", "==="], ["operator", "=>"], | ||
["operator", "!"], ["operator", "!="], ["operator", "!=="], | ||
["operator", "&"], ["operator", "&&"], ["operator", "&="], ["operator", "&&="], | ||
["operator", "|"], ["operator", "||"], ["operator", "|="], ["operator", "||="], | ||
["operator", "*"], ["operator", "**"], ["operator", "*="], ["operator", "**="], | ||
["operator", "/"], ["operator", "/="], ["operator", "~"], | ||
["operator", "^"], ["operator", "^="], ["operator", "%"], ["operator", "%="], | ||
["operator", "?"], ["operator", ":"], ["operator", "..."], | ||
["operator", "??"], ["operator", "?."], ["operator", "??="] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all operators. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'Microsoft.Web/sites/config@2020-12-01' | ||
'https://${frontDoorName}.azurefd.net/.auth/login/aad/callback' | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "'Microsoft.Web/sites/config@2020-12-01'"], | ||
["string", "'https://${frontDoorName}.azurefd.net/.auth/login/aad/callback'"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var oneString = 'abc' | ||
var oneNumber = 123 | ||
var numbers = [ | ||
123 | ||
] | ||
var oneObject = { | ||
abc: 123 | ||
} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "var"], " oneString ", ["operator", "="], ["string", "'abc'"], | ||
["keyword", "var"], " oneNumber ", ["operator", "="], ["number", "123"], | ||
["keyword", "var"], " numbers ", ["operator", "="], ["punctuation", "["], | ||
["number", "123"], | ||
["punctuation", "]"], | ||
["keyword", "var"], " oneObject ", ["operator", "="], ["punctuation", "{"], | ||
"\r\n\tabc", ["operator", ":"], ["number", "123"], | ||
["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for vars. |