Skip to content

Comments

Support real-world occam syntax for course module transpilation#26

Merged
associate-1 merged 2 commits intomainfrom
feat/course-module-phase1
Feb 19, 2026
Merged

Support real-world occam syntax for course module transpilation#26
associate-1 merged 2 commits intomainfrom
feat/course-module-phase1

Conversation

@associate-1
Copy link
Member

Summary

  • Adds parser support for shared-type parameters, multi-line parameter lists, RESULT qualifier, fixed-size array params [n]TYPE, VAL []TYPE abbreviations, [arr FOR n] shorthand slices, MINUS keyword as prefix, and multi-statement VALOF bodies
  • Adds lexer-level INDENT/DEDENT/NEWLINE suppression inside parentheses (like Python)
  • Adds codegen fixes: dot→underscore identifier sanitization, string→[]byte auto-wrapping, package-level abbreviations, ref param auto-dereferencing, unique _ifmatched names, unused variable suppression
  • Adds preprocessor include-once tracking to prevent duplicate definitions
  • The course module (excluding float_io.occ) now transpiles with zero parse errors and passes go vet

Test plan

  • All existing tests pass (go test ./...)
  • course_nofloat.module transpiles with zero parse errors
  • Transpiled Go output passes go vet
  • Review generated Go code for correctness

🤖 Generated with Claude Code

associate-1 and others added 2 commits February 19, 2026 14:45
Parser:
- Shared-type parameters (CHAN INT in?, out! — re-use type after comma)
- Multi-line parameter lists (lexer suppresses INDENT/DEDENT/NEWLINE inside parens)
- RESULT qualifier in parameters (maps to pointer like non-VAL)
- Fixed-size array parameters [n]TYPE with ArraySize field
- VAL []TYPE open array abbreviations
- [arr FOR n] shorthand slices (defaults start to 0)
- MINUS keyword as prefix unary operator
- Multi-statement VALOF bodies

Codegen:
- goIdent() replaces dots with underscores in all identifiers
- String→[]byte auto-wrapping for []BYTE params
- Package-level var declarations for top-level abbreviations
- Ref param auto-dereferencing in expressions and receives
- Unique _ifmatched flag names per IF block
- Unused variable suppression with _ = varname

Preprocessor:
- Include-once tracking to prevent duplicate definitions

The course module (excluding float_io.occ) now transpiles with zero
parse errors and the Go output passes go vet cleanly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document new parser/codegen/preprocessor features added for course
module support, add course module testing instructions, and list
Phase 2 items (RETYPES, transputer intrinsics) in Not Yet Implemented.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@associate-1 associate-1 merged commit 40f906f into main Feb 19, 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