Skip to content

feat: add Azure Policy core JSON parser and expression parser#655

Merged
anakrish merged 1 commit intomicrosoft:mainfrom
anakrish:azure-policy-parser-core
Apr 2, 2026
Merged

feat: add Azure Policy core JSON parser and expression parser#655
anakrish merged 1 commit intomicrosoft:mainfrom
anakrish:azure-policy-parser-core

Conversation

@anakrish
Copy link
Copy Markdown
Collaborator

@anakrish anakrish commented Apr 1, 2026

Add the foundational parsing infrastructure for Azure Policy JSON:

  • ExprParser: ARM template expression parser for "[...]" strings,
    supporting function calls, dot access, index access, and literals
  • Parser (core): recursive-descent JSON tokenizer-to-AST parser that
    reads directly from Lexer tokens with no intermediate serde_json step
  • ParseError: structured error types with span context for diagnostics
  • Helper functions: field classification, operator kind parsing, and
    ARM template expression detection

These components are consumed by the policy-aware parsing modules
(constraint, policy_rule, policy_definition) in a subsequent PR.

Copy link
Copy Markdown

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

Introduces the initial Azure Policy parsing foundation by adding span-annotated AST types plus low-level JSON and ARM-template-expression parsing components under src/languages/azure_policy/.

Changes:

  • Added Azure Policy AST types (Constraint, Condition, ValueOrExpr, expression/count nodes, etc.) with Span propagation.
  • Added a core token-driven JSON parser (Parser) and associated parse error types.
  • Added an ARM template expression sub-parser (ExprParser) and wired new modules into azure_policy::mod.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/languages/azure_policy/mod.rs Exposes new ast, expr, and parser modules from the Azure Policy language entrypoint.
src/languages/azure_policy/ast/mod.rs Adds span-annotated AST types for policy definitions/rules/constraints/operators/fields.
src/languages/azure_policy/ast/value.rs Adds JSON value, expression AST, and count-related node types.
src/languages/azure_policy/expr.rs Implements an ARM template expression parser on top of the shared lexer.
src/languages/azure_policy/parser/mod.rs Adds parser module entrypoint plus helper classification functions (fields/operators/template-expr checks).
src/languages/azure_policy/parser/core.rs Implements the core JSON parser (Parser) and JSON→ValueOrExpr conversion helpers.
src/languages/azure_policy/parser/error.rs Defines ParseError and its Display formatting for span-aware parsing errors.

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

Copy link
Copy Markdown

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.


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

@anakrish anakrish force-pushed the azure-policy-parser-core branch 3 times, most recently from d85e23d to 270d4a6 Compare April 1, 2026 16:57
@anakrish anakrish changed the title Azure policy parser core feat: add Azure Policy core JSON parser and expression parser Apr 1, 2026
@anakrish anakrish requested a review from Copilot April 1, 2026 17:02
Copy link
Copy Markdown

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


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

Copy link
Copy Markdown

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


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

@anakrish anakrish force-pushed the azure-policy-parser-core branch 2 times, most recently from 807361e to 1cfd143 Compare April 1, 2026 18:23
@anakrish anakrish requested a review from Copilot April 1, 2026 18:25
Copy link
Copy Markdown

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


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

Copy link
Copy Markdown

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


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

Copy link
Copy Markdown

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


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

Add the foundational parsing infrastructure for Azure Policy JSON:

- ExprParser: ARM template expression parser for "[...]" strings,
  supporting function calls, dot access, index access, and literals
- Parser (core): recursive-descent JSON tokenizer-to-AST parser that
  reads directly from Lexer tokens with no intermediate serde_json step
- ParseError: structured error types with span context for diagnostics
- Helper functions: field classification, operator kind parsing, and
  ARM template expression detection

These components are consumed by the policy-aware parsing modules
(constraint, policy_rule, policy_definition) in a subsequent PR.
Copy link
Copy Markdown

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


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

@anakrish anakrish marked this pull request as ready for review April 2, 2026 15:28
@anakrish anakrish merged commit 64f71de into microsoft:main Apr 2, 2026
63 checks passed
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.

3 participants