feat: add multiply (*) operator#339
Merged
Merged
Conversation
Introduce `*` as an infix data-expression operator that binds tighter than `+`/`-` and looser than prefix `!`, left-associative. - Grammar: `data_mul` token in `data_infix` - AST: `MulOp` node + `DataExpr::MulOp` - Parsing: `mul_op_parse` and a dedicated Pratt precedence level - Analysis and lowering to `tx3-tir`'s `BuiltInOp::Mul` - Spec (v1beta0): lexical, grammar, and type-system updates Semantics: `Int * Int`, plus `AnyAsset * Int` / `Int * AnyAsset` asset-quantity scaling. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the multiply (
*) operator to the Tx3 data-expression language.tx3.pest):data_multoken added todata_infix. Disambiguated from theinput*block flag by grammatical context.MulOpnode andDataExpr::MulOpvariant.mul_op_parseplus a dedicated Pratt precedence level —*binds tighter than+/-, looser than prefix!, left-associative.tx3-tir'sBuiltInOp::Mul.Semantics:
Int * Int(product),AnyAsset * IntandInt * AnyAsset(scale asset quantities).AnyAsset * AnyAssetis undefined.Tests
Parser tests for the basic form and precedence (
2 + 3 * 4→2 + (3*4);3 * 4 + 2→(3*4) + 2). Full suite green (171 + 4 doc-tests). Verified end-to-end throughtx3c build --emit tir-json:quantity * 2 + 445lowers toAdd[Mul[quantity, 2], 445].Depends on
tx3-lang/tir#1 (
BuiltInOp::Mul). Bump thetx3-tirdependency to the release that includes it before merging.🤖 Generated with Claude Code