Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

Implements support for Azure Bicep using tree-sitter-bicep v1.1.0.

Implementation

  • Expando character: _ (underscore)
    • Bicep identifiers follow /[a-zA-Z_*][a-zA-Z0-9_]*/ - $ is invalid
    • Follows C/C++/SQL/TOML convention for languages with this constraint
  • Language configuration: tree_sitter_bicep symbol, .bicep extension
  • Package structure: Standard monorepo layout with build/test/publish scripts

Usage

import bicep from '@ast-grep/lang-bicep'
import { registerDynamicLanguage, parse } from '@ast-grep/napi'

registerDynamicLanguage({ bicep })

const code = `
param location string = 'eastus'
param storageAccountName string = 'mystorageaccount'

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: storageAccountName
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
}
`

const sg = parse('bicep', code)
// Find all parameter declarations
const params = sg.root().findAll('param $NAME string')
// Find all resource declarations
const resources = sg.root().findAll('resource $NAME $TYPE = { $$$ }')

Users write patterns with $ as usual - ast-grep handles the internal translation to _ for Bicep's grammar requirements. Examples use realistic Bicep syntax with param and resource declarations for Azure infrastructure-as-code scenarios.

Original prompt

This section details on the original issue you should resolve

<issue_title>bicep language</issue_title>
<issue_description>A humble request to support the Azure Bicep language - https://github.com/tree-sitter-grammars/tree-sitter-bicep .

</issue_description>

Comments on the Issue (you are @copilot in this section)

@HerringtonDarkholme i'm not familiar with bicep. does it support using `$` as identifier? it is critical since ast-grep is using the parser to parse pattern. if `$` doesn't work, a new `expando` char should be used

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link

coderabbitai bot commented Jan 10, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Add support for Azure Bicep language Add Bicep language support Jan 10, 2026
@HerringtonDarkholme HerringtonDarkholme marked this pull request as ready for review January 10, 2026 22:50
@HerringtonDarkholme
Copy link
Member

@copilot please fix

a typical Bicep language isn't like var $A = $B

It looks like this thing

param location string = resourceGroup().location
param storageAccountName string = 'toylaunch${uniqueString(resourceGroup().id)}'

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: storageAccountName
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {
    accessTier: 'Hot'
  }
}

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot please fix

a typical Bicep language isn't like var $A = $B
...

Updated the examples to use realistic Bicep code with param and resource declarations. The test now uses param location string = 'eastus' and the README shows a complete example with storage account resources. Fixed in commit 574c298.

@HerringtonDarkholme
Copy link
Member

@HerringtonDarkholme
Copy link
Member

@copilot please review the code and compare this to other language implementation

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the Azure Bicep language to ast-grep by integrating the tree-sitter-bicep grammar v1.1.0. Since Bicep doesn't support $ as an identifier character, the implementation uses underscore _ as the expando character for pattern matching, following the same convention as other languages with this constraint (C, C++, SQL, TOML).

Changes:

  • Created a new @ast-grep/lang-bicep package with standard monorepo structure
  • Configured underscore as the expando character for Bicep pattern matching
  • Added comprehensive documentation and test coverage

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/bicep/package.json Package configuration with dependencies and scripts
packages/bicep/index.js Language registration module with expando character configuration
packages/bicep/nursery.js Test setup with pattern matching validation
packages/bicep/postinstall.js Standard postinstall script for parser setup
packages/bicep/index.d.ts TypeScript type definitions for language registration
packages/bicep/README.md Usage documentation with Bicep-specific examples
packages/bicep/CHANGELOG.md Initial release changelog entry
.changeset/strong-pears-help.md Changeset for version management
pnpm-lock.yaml Dependency lockfile updates for tree-sitter-bicep v1.1.0
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor Author

Copilot AI commented Jan 17, 2026

@copilot please review the code and compare this to other language implementation

Reviewed and compared to other language implementations. The Bicep package follows the correct structure and patterns:

✅ All files match other packages (index.js, package.json, nursery.js, index.d.ts, postinstall.js, README.md, CHANGELOG.md)
expandoChar: '_' is correct - matches C/C++/SQL/TOML pattern for languages where $ is invalid
✅ Identifier pattern confirmed: /[a-zA-Z_*][a-zA-Z0-9_]*/ (from grammar link)
✅ Tests pass with realistic Bicep code (param and resource declarations)
✅ No lint errors

The implementation is complete and ready.

I can confirm bicep's identifier name

https://github.com/tree-sitter-grammars/tree-sitter-bicep/blob/bff59884307c0ab009bd5e81afd9324b46a6c0f9/grammar.js#L454

Confirmed. The identifier pattern /[a-zA-Z_*][a-zA-Z0-9_]*/ validates our choice of expandoChar: '_' since $ is not a valid identifier character in Bicep.

@HerringtonDarkholme HerringtonDarkholme merged commit 1d96749 into main Jan 17, 2026
11 checks passed
@HerringtonDarkholme HerringtonDarkholme deleted the copilot/support-azure-bicep-language branch January 17, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bicep language

2 participants