A Peggyjs grammar/parser generator for Azure Bicep. Converts bicep templates to an AST.
The grammar is currently quite rough around the edges, work very much still in progress.
- Implement proper unicode ranges for string chars
- Fix string indexed member expressions
- Complete AST ts types
- Handle in-built functions granularly
npm i
npm run test
Bicep input | Parsed AST |
---|---|
param yourName string
var hello = 'Hello World! - Hi'
output helloWorld string = '${hello} ${yourName}' |
{
"type": "BICEP",
"body": [
{
"type": "ParameterDeclaration",
"name": "yourName",
"decorators": [],
"dataType": "string",
"expression": []
},
{
"type": "VariableDeclaration",
"name": "hello",
"decorators": [],
"expression": {
"type": "String",
"value": "Hello World! - Hi"
}
},
{
"type": "OutputDeclaration",
"id": "helloWorld",
"decorators": [],
"dataType": "string",
"expression": {
"type": "TemplateLiteral",
"expressions": [
{
"type": "Identifier",
"name": "hello"
},
{
"type": "Identifier",
"name": "yourName"
}
],
"quasis": [
{
"type": "TemplateElement",
"value": "",
"tail": false
},
{
"type": "TemplateElement",
"value": " ",
"tail": false
},
{
"type": "TemplateElement",
"value": "",
"tail": true
}
]
}
}
]
} |
Examples sourced from the Azure Bicep repo
186/203
test files successfully parsed