Skip to content

ttl: add infix expression parser/type-checker for Go-like operators #219

@kdy1

Description

@kdy1

Summary

The lexer defines operator tokens, but parser/sema currently do not implement infix operator parsing and typing with precedence.

Evidence

Contract Evidence:

  • docs/project-ttl-language.md:97
  • cmds/ttlc/internal/parser/parser.go:354

Current Gap

The lexer defines operator tokens, but parser/sema currently do not implement infix operator parsing and typing with precedence.

Proposed Scope

  • Not documented yet.

Acceptance Criteria

  • Add AST support for infix/binary expressions.
  • Parse +, -, *, / (and precedence/associativity) in expression grammar.
  • Add semantic checks for operator operand/result compatibility.
  • Produce stable diagnostics for invalid operator combinations.

Test Scenarios

  • Precedence test: multiplication binds tighter than addition.
  • Parenthesized expressions override default precedence.
  • Invalid operand type combinations emit type errors.

Out of Scope

  • Full Go operator surface beyond agreed phase scope.
  • Constant-folding optimization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions