Skip to content

Define one numeric literal contract across the frontend #479

Closed

Description

@LunaStev

Problem

Wave does not currently have one numeric-literal contract across the lexer, parser, semantic constant evaluation, and LLVM lowering. The lexer recognizes binary, hexadecimal, decimal, and a limited decimal-float form, while later stages contain handling for spellings such as octal prefixes and digit separators that the lexer cannot consistently produce.

This mismatch already contributes to parser-only failures such as the default-parameter radix panic and makes it unclear whether 0o755, 1_000, exponent notation, and type suffixes are language features or dead implementation paths.

The grammar should be frozen before alpha instead of letting each compiler stage define a different subset.

Scope

  • Write the normative integer and floating-point literal grammar.
  • Decide the alpha contract for binary, octal, decimal, hexadecimal, digit separators, exponents, and suffixes.
  • Implement one shared parsing representation used by default values, constants, semantic validation, and lowering.
  • Reject invalid digits, separator placement, overflow, and unsupported suffixes with source diagnostics.
  • Add table-driven lexer/parser/semantic tests and end-to-end cases.

Acceptance criteria

  • Every documented literal spelling has matching positive tests through typed HIR.
  • Every downstream numeric parser accepts exactly the token spellings emitted by the lexer.
  • Invalid literals cannot panic or reach backend-only parsing errors.
  • The default-parameter crash issue can close by using this contract rather than duplicating it.

Related: #405, #474

Activity

  1. added
    enhancement
    refactor
    technical debt
    on Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementrefactortechnical debt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions