Skip to content

Commit cddb3c7

Browse files
authored
Update active pseudo-grammar of the bicep language (#19169)
## Description Add typed variables Add interpolated multiline string Add resource derived type Remove decorators from assertDecl ## Checklist - [x] I have read and adhere to the [contribution guide](https://github.com/Azure/bicep/blob/main/CONTRIBUTING.md). ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/19169)
1 parent c3e48dc commit cddb3c7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

docs/grammar.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ parameterDefaultValue -> "=" expression
4949
5050
typeDecl -> decorator* "type" IDENTIFIER(name) "=" typeExpression NL
5151
52-
varDecl -> decorator* "var" IDENTIFIER(name) "=" expression NL
52+
varDecl -> decorator* "var" IDENTIFIER(name) typeExpression? "=" expression NL
5353
5454
resourceDecl -> decorator* "resource" IDENTIFIER(name) interpString(type) "existing"? "=" (ifCondition | object | forExpression) NL
5555
5656
moduleDecl -> decorator* "module" IDENTIFIER(name) interpString(type) "=" (ifCondition | object | forExpression) NL
5757
5858
testDecl -> "test" IDENTIFIER(name) interpString(type) "=" (object) NL
5959
60-
assertDecl -> decorator* "assert" IDENTIFIER(name) "=" expression NL
60+
assertDecl -> "assert" IDENTIFIER(name) "=" expression NL
6161
6262
outputDecl ->
6363
decorator* "output" IDENTIFIER(name) IDENTIFIER(type) "=" expression NL
@@ -127,7 +127,7 @@ primaryExpression ->
127127
functionCall |
128128
literalValue |
129129
interpString |
130-
multilineString |
130+
interpMultilineString |
131131
array |
132132
forExpression |
133133
object |
@@ -155,13 +155,18 @@ forExpression -> "[" "for" (IDENTIFIER(item) | forVariableBlock) "in" expression
155155
forVariableBlock -> "(" IDENTIFIER(item) "," IDENTIFIER(index) ")"
156156
forBody -> expression(body) | ifCondition
157157
158-
interpString -> stringLeftPiece ( expression stringMiddlePiece )* expression stringRightPiece | stringComplete
158+
interpString -> ( stringLeftPiece ( expression stringMiddlePiece )* expression stringRightPiece ) | stringComplete
159159
stringLeftPiece -> "'" STRINGCHAR* "${"
160160
stringMiddlePiece -> "}" STRINGCHAR* "${"
161161
stringRightPiece -> "}" STRINGCHAR* "'"
162162
stringComplete -> "'" STRINGCHAR* "'"
163163
164-
multilineString -> "'''" + MULTILINESTRINGCHAR+ + "'''"
164+
interpMultilineString -> ( interpMultilineStringLeftPiece ( expression interpMultilineStringMiddlePiece )* expression interpMultilineStringRightPiece ) | multilineString
165+
interpMultilineStringLeftPiece -> "$"+ "'''" MULTILINESTRINGCHAR* "$"+ "{"
166+
interpMultilineStringMiddlePiece -> "}" MULTILINESTRINGCHAR* "$"+ "{"
167+
interpMultilineStringRightPiece -> "}" MULTILINESTRINGCHAR* "'''"
168+
169+
multilineString -> "'''" MULTILINESTRINGCHAR* "'''"
165170
166171
literalValue -> NUMBER | "true" | "false" | "null"
167172
@@ -198,6 +203,7 @@ primaryTypeExpression ->
198203
typeReference ->
199204
ambientTypeReference |
200205
fullyQualifiedAmbientTypeReference |
206+
resourceDerivedType |
201207
IDENTIFIER(type) |
202208
IDENTIFIER(importedType) |
203209
IDENTIFIER(wildcardImport) "." IDENTIFIER(type) |
@@ -209,6 +215,8 @@ ambientTypeReference -> "string" | "int" | "bool" | "array" | "object"
209215
210216
fullyQualifiedAmbientTypeReference -> IDENTIFIER(sysNamespace) "." ambientTypeReference
211217
218+
resourceDerivedType -> ( "resourceInput" | "resourceOutput" ) "<" interpString(type) ">"
219+
212220
objectType -> "{" (NL+ ((objectTypeProperty | objectTypeAdditionalPropertiesMatcher) NL+ )* )? "}"
213221
objectTypeProperty -> decorator* ( IDENTIFIER(name) | stringComplete | multilineString ) ":" typeExpression
214222
objectTypeAdditionalPropertiesMatcher -> decorator* "*:" typeExpression

0 commit comments

Comments
 (0)