Skip to content

Parse backtick literals into typed Literal instances in AssemblyFormatParser#8

Merged
jonathanvdc merged 3 commits intomainfrom
copilot/add-mlir-assembly-format-parser
Mar 29, 2026
Merged

Parse backtick literals into typed Literal instances in AssemblyFormatParser#8
jonathanvdc merged 3 commits intomainfrom
copilot/add-mlir-assembly-format-parser

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 29, 2026

LiteralChunk.Value stored the raw string between backticks with no structured representation. This adds Literal.Parse(string) to decompose that string into typed Literal instances, and switches LiteralChunk.Value from string to IReadOnlyList<Literal>.

Model changes (LiteralChunk.cs)

  • LiteralChunk.Value: stringIReadOnlyList<Literal>
  • New WhitespaceLiteral(string spaces) added alongside existing PunctuationLiteral, KeywordLiteral, NewlineLiteral, EmptyLiteral
  • Literal.Parse(string text) — static parser with the following rules:
Input Output
"" [EmptyLiteral]
\n [NewlineLiteral]
\n\n [NewlineLiteral, NewlineLiteral]
" " / " " [WhitespaceLiteral(" ")] / [WhitespaceLiteral(" ")]
-> [PunctuationLiteral(Arrow)]
->( [PunctuationLiteral(Arrow), PunctuationLiteral(LParen)]
else [KeywordLiteral("else")]

-> takes longest-match priority over - (Minus). Consecutive spaces are grouped into a single WhitespaceLiteral.

Parser change (AssemblyFormatParser.cs)

ParseLiteral() now calls Literal.Parse(value) and passes the result to the LiteralChunk constructor.

Tests

Existing LiteralChunk.Value string comparisons updated to check PunctuationLiteral.TokenKind. Sixteen new Literal.Parse tests added covering all documented examples.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

@jonathanvdc jonathanvdc marked this pull request as ready for review March 29, 2026 03:37
Copilot AI changed the title [WIP] Add parser for MLIR ODS Model AssemblyFormat Literals Parse backtick literals into typed Literal instances in AssemblyFormatParser Mar 29, 2026
Copilot AI requested a review from jonathanvdc March 29, 2026 03:39
Copy link
Copy Markdown
Owner

@jonathanvdc jonathanvdc left a comment

Choose a reason for hiding this comment

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

Great work but the build is failing due to these changes. Can you debug why and fix the issue?

Copilot stopped work on behalf of jonathanvdc due to an error March 29, 2026 03:50
Copilot AI requested a review from jonathanvdc March 29, 2026 03:50
@jonathanvdc jonathanvdc merged commit 2e1a501 into main Mar 29, 2026
1 check passed
@jonathanvdc jonathanvdc deleted the copilot/add-mlir-assembly-format-parser branch March 29, 2026 03:51
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.

2 participants