Skip to content

Add Assembly (65C02) language with WDC W65C02S syntax highlighting - #109

Merged
hybridmachine merged 15 commits into
macos-portfrom
feature/asm-65c02-language
May 13, 2026
Merged

Add Assembly (65C02) language with WDC W65C02S syntax highlighting#109
hybridmachine merged 15 commits into
macos-portfrom
feature/asm-65c02-language

Conversation

@hybridmachine

Copy link
Copy Markdown
Owner

Summary

  • Adds Assembly (65C02) as a first-class language in PaperWasp, reusing Lexilla's SCLEX_ASM lexer with WDC W65C02S keyword lists (NMOS 6502 + CMOS 65C02 + WDC WAI/STP + Rockwell SMB/RMB/BBR/BBS).
  • Wires the language into both the upstream Notepad++ source (enum, command ID, menus, descriptor, langs.model.xml, stylers.model.xml, function-list parser) and the macOS port's runtime tables (g_languages, s_asmStyles, extension routing).
  • Extends the macOS LangDef struct with a backward-compatible keywordsExtra[6] so LexAsm's 8 keyword classes (opcodes, math, registers, directives, directive-operands, ext, fold-open, fold-close) all flow through applyLanguageToView() — existing 34 g_languages rows continue to compile via aggregate zero-init.
  • .asm, .a65, .s65 auto-detect as Assembly (65C02). x86 Assembly remains available via the Languages menu.

Spec: docs/superpowers/specs/2026-05-11-asm-65c02-language-design.md
Plan: docs/superpowers/plans/2026-05-11-asm-65c02-language.md

Architecture notes

  • L_ASM_65C02 is appended immediately before L_EXTERNAL in LangType, preserving every existing enum value (plugin ABI stable).
  • IDM_LANG_ASM_65C02 = IDM_LANG + 94 — collision-free.
  • Style colors copy the upstream <LexerType name="asm"> defaults for Windows; the macOS s_asmStyles[] mirrors them with BGR conversions and dark-mode variants from the VS Code palette already used in neighboring lexers.
  • Function-list parser uses the standard label-at-column-0 heuristic; refinement deferred.

Out of scope (v1)

  • 65816 long-mode (longa/longi/shorta/shorti), 24-bit operands.
  • WDC linker control file (.lkr) highlighting.
  • Auto-completion API list.
  • Build integration (invoking WDC65xx from the editor).

Test plan

  • Open /tmp/claude/sample_65c02.asm (or any 65C02 source) in PaperWasp — language auto-detects as Assembly (65C02).
  • Opcodes (`lda`, `sta`, `jsr`, `bra`, `wai`) render in the CPU INSTRUCTION color.
  • Registers (`a`, `x`, `y`, `s`) render in the REGISTER color.
  • Directives (`chip`, `equ`, `ds`, `org`, `end`) render in the DIRECTIVE color.
  • `;` comments render in the COMMENT color.
  • Hex literals (`$01FF`, `$C000`) render as numbers.
  • Folding works on `if … endif` and `macro … mend` blocks.
  • Function List panel lists top-level labels.
  • Manually switching the buffer language to Assembly (x86) and back to Assembly (65C02) behaves without crash.
  • Both `PaperWasp` and `PaperWasp_package` Xcode targets build cleanly.

🤖 Generated with Claude Code

Brian Tabone and others added 14 commits May 12, 2026 00:11
Spec and step-by-step plan for adding a first-class L_ASM_65C02 language
that reuses Lexilla SCLEX_ASM with WDC W65C02S keyword lists.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
LexAsm (used by Assembly (65C02), added in a follow-up commit) consumes
eight keyword lists. Append a null-initialized keywordsExtra[] array to
LangDef and forward each non-null entry via SCI_SETKEYWORDS in
applyLanguageToView. Existing g_languages rows are untouched and
continue to compile via aggregate zero-init.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add LANG_ASM_65C02 index, a g_languages row pointing at Lexilla's `asm`
lexer with the full eight WDC W65C02S keyword classes (opcodes, registers,
directives, fold pairs), and .asm/.a65/.s65 extension detection.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add s_asmStyles[] mapping SCE_ASM_* style IDs to BGR foreground colors
(light + dark variants) and register the table under the "asm" lexer
name in s_allLexerStyles[]. Color choices mirror the upstream
stylers.model.xml defaults converted from RGB to BGR; dark variants
align with the VS Code palette used by neighboring lexer entries.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The descriptor row's 5th field is the Lexilla lexer ID; Lexilla only
registers "asm" for SCLEX_ASM. Passing "asm65c02" made CreateLexer
return null and disabled highlighting on Windows. Reuse the "asm"
lexer name, matching how L_SCHEME shares "lisp".

Also add .a65 and .s65 to the upstream langs.model.xml ext list so
Windows routing matches the macOS port's guessLanguage().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 13, 2026 01:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new first-class Assembly (65C02) language to PaperWasp, reusing Lexilla’s SCLEX_ASM lexer with WDC W65C02S-oriented keyword sets, and wires it through both the Windows/Notepad++ plumbing and the macOS port’s language tables/styling.

Changes:

  • Introduces L_ASM_65C02 / IDM_LANG_ASM_65C02, adds menu items, and maps language↔command IDs.
  • Adds asm65c02 keyword/styler models and a function-list parser (asm65c02.xml).
  • Extends macOS language definitions to support LexAsm’s additional word lists (sets 2–7) and adds an ASM style table.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
PowerEditor/src/stylers.model.xml Adds asm65c02 lexer style definitions matching ASM style IDs.
PowerEditor/src/ScintillaComponent/ScintillaEditView.h Adds setAsm65C02Lexer() wrapper to configure SCLEX_ASM with all 8 word lists.
PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp Adds language descriptor row and routes L_ASM_65C02 through codepage handling + defineDocType.
PowerEditor/src/Parameters.cpp Maps L_ASM_65C02IDM_LANG_ASM_65C02.
PowerEditor/src/Notepad_plus.rc Adds “Assembly (65C02)” to language menus.
PowerEditor/src/Notepad_plus.cpp Maps IDM_LANG_ASM_65C02L_ASM_65C02.
PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h Appends L_ASM_65C02 to the LangType enum.
PowerEditor/src/menuCmdID.h Defines IDM_LANG_ASM_65C02.
PowerEditor/src/langs.model.xml Adds asm65c02 keyword lists and associates extensions (asm a65 s65).
PowerEditor/installer/functionList/asm65c02.xml Adds function-list parser for 65C02 labels.
macos/platform/lexer_styles.mm Adds ASM style mapping and applies keyword sets 2–7 via keywordsExtra.
macos/platform/language_defs.mm Adds Assembly (65C02) language row and routes .asm/.a65/.s65 detection.
macos/platform/language_defs.h Extends LangDef with keywordsExtra[6] and adds LANG_ASM_65C02.
docs/superpowers/specs/2026-05-11-asm-65c02-language-design.md Design spec for the new language integration.
docs/superpowers/plans/2026-05-11-asm-65c02-language.md Implementation plan / verification checklist.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{L"lisp", L"Lisp", L"List Processing language file", L_LISP, "lisp"},
{L"scheme", L"Scheme", L"Scheme file", L_SCHEME, "lisp"},
{L"asm", L"Assembly", L"Assembly language source file", L_ASM, "asm"},
{L"asm65c02", L"Assembly (65C02)", L"WDC 65C02 assembly source file", L_ASM_65C02, "asm"},
Comment on lines +42 to 45
L_ASM_65C02, \
// Don't use L_JS_EMBEDDED, use L_JAVASCRIPT instead
// The end of enumerated language type, so it should be always at the end
L_EXTERNAL};
<!-- ==========================================================================\
|
| Function-list parser for Assembly (65C02).
| Matches any column-0 label terminated by ':' as a "subroutine".
The _langNameInfoArray is indexed by LangType enum value (lines 1588,
2327 read [langType]). The asm65c02 descriptor row was inserted after
L_ASM=32, but L_ASM_65C02=95 — every row after L_ASM was therefore
mapped to the wrong language. Move the row to its enum-ordered position
between L_ERRORLIST and L_EXTERNAL.

The vendored ComparePlus copy of Notepad_plus_msgs.h falls out of sync
with the host whenever the LangType enum grows. Append L_ASM_65C02
there so the plugin sees the same enum values as the host.

Tighten the asm65c02.xml header comment to match the regex behavior
(labels may be indented; the parser is not column-0-only).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hybridmachine
hybridmachine merged commit 88b1ce7 into macos-port May 13, 2026
13 of 30 checks passed
@hybridmachine
hybridmachine deleted the feature/asm-65c02-language branch May 13, 2026 01:37
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