Skip to content

Support full course module transpilation including float_io.occ#27

Merged
associate-1 merged 1 commit intomainfrom
feat/course-module-phase2
Feb 20, 2026
Merged

Support full course module transpilation including float_io.occ#27
associate-1 merged 1 commit intomainfrom
feat/course-module-phase2

Conversation

@associate-1
Copy link
Member

Summary

  • Implement Phase 2 features to transpile the complete KRoC course module with float_io.occ (598 parse errors → 0, go vet clean)
  • Add RETYPES declarations, transputer intrinsic helpers, array literals, untyped VAL abbreviations, multi-line expression continuation, and CAUSEERROR support
  • Add 13 new tests (5 parser, 4 codegen, 4 e2e) covering all new constructs

Lexer

  • Bracket [/] NEWLINE suppression via parenDepth
  • RETYPES keyword token
  • Multi-line expression continuation: isContinuationOp() suppresses NEWLINE/INDENT/DEDENT after binary operators and :=

AST

  • ArrayLiteral expression node ([1, 2, 3])
  • RetypesDecl statement node (VAL INT X RETYPES X :)

Parser

  • Untyped VAL abbreviations (VAL name IS expr :)
  • Array literal expressions ([e1, e2, ...])
  • RETYPES declarations (single VAL INT X RETYPES X : and array VAL [2]INT X RETYPES X :)

Codegen

  • Array literal → []int{...}
  • Untyped VAL → var x = expr
  • RETYPES with parameter renaming for same-name shadowing (Go can't := redeclare params)
  • 7 transputer intrinsic Go helpers (LONGPROD, LONGDIV, LONGSUM, LONGDIFF, NORMALISE, SHIFTRIGHT, SHIFTLEFT)
  • CAUSEERROR → panic("CAUSEERROR")
  • Go reserved word escaping (byte_byte, etc.)
  • Scoped nested proc signature collection (fixes same-named nested procs)
  • Fixed-size array params → slices for Go compatibility
  • Abbreviation _ = name suppression in function bodies

Test plan

  • go test ./... — all existing + 13 new tests pass
  • go vet /tmp/course_out.go — full course.module transpiles cleanly
  • go vet on course_nofloat.module — regression check passes

🤖 Generated with Claude Code

Implement Phase 2 features needed to transpile the complete KRoC course
module with float_io.occ (598 parse errors → 0, go vet clean). Adds
RETYPES declarations, transputer intrinsic helpers, array literals,
untyped VAL abbreviations, multi-line expression continuation, and
CAUSEERROR support across all pipeline stages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@associate-1 associate-1 merged commit 413a0f2 into main Feb 20, 2026
1 check passed
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

Comments