feat: Calendar Era — date literals, date arithmetic, date comparison, today injection#53
Merged
Merged
Conversation
Adds `date` as a third scalar value type alongside number and string, threaded through the full pipeline: lexer (TokenType.DATE, _DATE_RE), parser (DateLiteral, calendar validation, bare-date starting/until), interpreter (storage, display, comparison, arithmetic, within-tolerance, today injection), analyzer (date types, _require_comparable, date-aware arithmetic checks, list_of_dates parity with existing list types), and renderer (bare ISO 8601 round-trip). Zero new reserved words — DATE is a literal type, accounted the same way as NUMBER. Also extends highest/lowest to dates (interpreter.py) and mirrors the new date-comparison guard into listener.py's duplicate _apply_op, both needed for goal-form parity but not explicitly enumerated in the spec's file list. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
rmichaelthomas
added a commit
that referenced
this pull request
Jul 15, 2026
feat: Calendar Era — date literals, date arithmetic, date comparison, today injection
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
dateas a third scalar value type (alongside number and string), threaded through the full pipeline: lexer → parser → interpreter → analyzer → renderer.TokenType.DATEis a literal type, accounted the same way asNUMBER—ALL_RESERVEDcount is unchanged by this build (61 → 61; note: the count was already 61 onmainbefore this PR, not 60 as CLAUDE.md's stale note says — pre-existing drift, unrelated to this change).2025-07-01, bare ISO 8601), calendar validation at parse time, date arithmetic (plus/minusin whole days,date minus date→ day count), date comparison (all condition operators),withinon dates (day-count tolerance),todayas a product-layer injected value (run(..., inject={"today": ...}), wired into the CLI automatically).starting/untilnow accept bare dates in addition to quoted dates.highest/lowestand list operations (list_of_dates) to dates for parity with numbers/strings — needed for the spec's goal forms but not explicitly itemized in its file-by-file list.listener.py's duplicate_apply_op(Phase 2 reactive path), per that file's existing "both copies must stay in sync" contract.Test plan
pytest tests/— 1615 passed, 0 failed (1557 pre-existing + 58 new intests/test_date.py)TokenType.DATEexists;ALL_RESERVEDcount unchanged by this PRstarting/untilbare-date canonicalizationKnown gaps (disclosed, not fixed here)
"123") already fails render round-trip onmain(canonical rendering drops quotes when "unambiguous", so re-parsing yields a different literal type). Adding dates introduces the identical case for"2025-07-01". Pre-existing_emit_stringlimitation, not date-specific — left out of scope for this PR.🤖 Generated with Claude Code