Skip to content

Modernize to Go 1.27 and split the parser - #57

Merged
jenska merged 1 commit into
mainfrom
modernize-go-1.27
Sep 3, 2026
Merged

jenska merged 1 commit into
mainfrom
modernize-go-1.27

Conversation

@jenska

@jenska jenska commented Sep 3, 2026

Copy link
Copy Markdown
Owner

What changed

Go 1.27

  • go.mod go 1.26 → go 1.27
  • CI matrix 1.26.x → 1.27.x
  • README Go badge and install instructions

Standard-library modernization

Applied current idioms across the codebase (verified clean with gopls modernize):

  • maps.Copy instead of manual copy loops
  • slices.Contains instead of linear search loops
  • slices.Clone instead of append([]T(nil), s...)
  • min() instead of if-clamp
  • strings.Cut instead of IndexByte + slicing
  • errors.AsType[*Error] (Go 1.27) instead of errors.As with a separate declaration
  • range-over-int in tests; removed a map[bool]string lookup trick in canonical.go

Structural

  • Merged the two duplicated size-validation helpers (sizeAllowed in assemble.go, sizeAllowedList in parser.go) into a single sizeAllowed(allowed, sz) with an empty-list guard.
  • Split the 1,393-line internal/asm/parser.go into focused files — pure code movement, no behavior change:
    • parser.go (272) — Parser type, entry points, token stream, register helpers
    • parser_labels.go — local/global label handling
    • parser_stmt.go — statements, constants, instructions, padding
    • parser_macro.go — macro expansion
    • parser_operand.go — form/operand/size parsing
    • parser_ea.go — effective-address parsing
  • gofmt the previously unformatted additional_api_test.go.

Notes for reviewers

  • Public API is unchanged.
  • The m68kdasm dependency mentioned in the original request was intentionally left out: it is not a dependency of this project, and m68kdasm v1.1.0 in fact depends on m68kasm.
  • Verification: go build ./..., go vet ./..., go test ./... (incl. tests/e2e), benchmark compilation, and a bin/srec/elf CLI smoke test all pass.

🤖 Generated with Claude Code

- Bump the module and CI matrix to Go 1.27; update README badge/instructions.
- Adopt current standard-library idioms across the codebase: maps.Copy,
  slices.Contains, slices.Clone, min(), strings.Cut, errors.AsType[*Error],
  and range-over-int in tests. Verified clean with gopls modernize.
- Merge the duplicated size-validation helpers into a single
  sizeAllowed(allowed, sz) with an empty-list guard.
- Split the 1.4k-line internal/asm/parser.go into focused files
  (parser_labels, parser_stmt, parser_macro, parser_operand, parser_ea);
  pure code movement, no behavior change.
- gofmt the previously unformatted additional_api_test.go.

Public API is unchanged. go build/vet/test (incl. e2e), benchmark
compilation, and a bin/srec/elf CLI smoke test all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jenska
jenska merged commit 449b83e into main Sep 3, 2026
1 check passed
@jenska
jenska deleted the modernize-go-1.27 branch September 13, 2026 15:19
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.

1 participant