Skip to content

Commit 88b1ce7

Browse files
Merge pull request #109 from hybridmachine/feature/asm-65c02-language
Add Assembly (65C02) language with WDC W65C02S syntax highlighting
2 parents 0c1ec6b + 13dbaba commit 88b1ce7

16 files changed

Lines changed: 990 additions & 2 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!-- ==========================================================================\
3+
|
4+
| Function-list parser for Assembly (65C02).
5+
| Matches any label terminated by ':' (with optional leading whitespace)
6+
| as a "subroutine". Heuristic only — 65C02 has no formal function
7+
| construct; refine later.
8+
|
9+
| See: https://npp-user-manual.org/docs/function-list/
10+
|
11+
\=========================================================================== -->
12+
<NotepadPlus>
13+
<functionList>
14+
<!-- =============================================== [ Assembly (65C02) ] -->
15+
16+
<parser
17+
displayName="Assembly (65C02)"
18+
id ="asm65c02_subroutine"
19+
commentExpr="(?x) # inline-comments mode
20+
(?m-s:;.*$) # ;-to-EOL line comment
21+
"
22+
>
23+
<function
24+
mainExpr="(?x) # inline-comments mode
25+
(?m)^\h* # optional leading whitespace
26+
\K # keep the text matched so far, out of the overall match
27+
[A-Za-z_][\w]* # valid label characters (no $ since WDC uses $ as hex prefix)
28+
(?=:) # up till the colon
29+
"
30+
/>
31+
</parser>
32+
</functionList>
33+
</NotepadPlus>

‎PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
3939
L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG,\
4040
L_TYPESCRIPT, L_JSON5, L_MSSQL, L_GDSCRIPT, L_HOLLYWOOD,\
4141
L_GOLANG, L_RAKU, L_TOML, L_SAS, L_ERRORLIST, \
42+
L_ASM_65C02, \
4243
// Don't use L_JS_EMBEDDED, use L_JAVASCRIPT instead
4344
// The end of enumerated language type, so it should be always at the end
4445
L_EXTERNAL};

‎PowerEditor/src/Notepad_plus.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4132,6 +4132,8 @@ LangType Notepad_plus::menuID2LangType(int cmdID)
41324132
return L_SAS;
41334133
case IDM_LANG_ERRORLIST:
41344134
return L_ERRORLIST;
4135+
case IDM_LANG_ASM_65C02:
4136+
return L_ASM_65C02;
41354137
case IDM_LANG_USER:
41364138
return L_USER;
41374139
default:

‎PowerEditor/src/Notepad_plus.rc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ BEGIN
10011001
MENUITEM "ASN.1", IDM_LANG_ASN1
10021002
MENUITEM "ASP", IDM_LANG_ASP
10031003
MENUITEM "Assembly", IDM_LANG_ASM
1004+
MENUITEM "Assembly (65C02)", IDM_LANG_ASM_65C02
10041005
MENUITEM "AutoIt", IDM_LANG_AU3
10051006
MENUITEM "AviSynth", IDM_LANG_AVS
10061007
MENUITEM "BaanC", IDM_LANG_BAANC
@@ -1105,6 +1106,7 @@ BEGIN
11051106
MENUITEM "ASN.1", IDM_LANG_ASN1
11061107
MENUITEM "ASP", IDM_LANG_ASP
11071108
MENUITEM "Assembly", IDM_LANG_ASM
1109+
MENUITEM "Assembly (65C02)", IDM_LANG_ASM_65C02
11081110
MENUITEM "AutoIt", IDM_LANG_AU3
11091111
MENUITEM "AviSynth", IDM_LANG_AVS
11101112
END

‎PowerEditor/src/Parameters.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8160,6 +8160,9 @@ int NppParameters::langTypeToCommandID(LangType lt) const
81608160
case L_ERRORLIST:
81618161
id = IDM_LANG_ERRORLIST; break;
81628162

8163+
case L_ASM_65C02:
8164+
id = IDM_LANG_ASM_65C02; break;
8165+
81638166
case L_SEARCHRESULT :
81648167
id = -1; break;
81658168

‎PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ LanguageNameInfo ScintillaEditView::_langNameInfoArray[L_EXTERNAL + 1] = {
198198
{L"toml", L"TOML", L"Tom's Obvious Minimal Language file", L_TOML, "toml"},
199199
{L"sas", L"SAS", L"SAS file", L_SAS, "sas"},
200200
{L"errorlist", L"ErrorList", L"ErrorList", L_ERRORLIST, "errorlist"},
201+
{L"asm65c02", L"Assembly (65C02)", L"WDC 65C02 assembly source file", L_ASM_65C02, "asm"},
201202
{L"ext", L"External", L"External", L_EXTERNAL, "null"}
202203
};
203204

@@ -1817,7 +1818,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
18171818
{
18181819
if (getCurrentBuffer()->getUnicodeMode() == uni8Bit)
18191820
{
1820-
if (typeDoc == L_CSS || typeDoc == L_CAML || typeDoc == L_ASM || typeDoc == L_MATLAB)
1821+
if (typeDoc == L_CSS || typeDoc == L_CAML || typeDoc == L_ASM || typeDoc == L_ASM_65C02 || typeDoc == L_MATLAB)
18211822
execute(SCI_SETCODEPAGE, CP_ACP);
18221823
else
18231824
execute(SCI_SETCODEPAGE, _codepage);
@@ -1974,6 +1975,9 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
19741975
case L_ASM :
19751976
setAsmLexer(); break;
19761977

1978+
case L_ASM_65C02 :
1979+
setAsm65C02Lexer(); break;
1980+
19771981
case L_DIFF :
19781982
setDiffLexer(); break;
19791983

@@ -2474,7 +2478,7 @@ void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask)
24742478
if (isCJK())
24752479
{
24762480
LangType typeDoc = buffer->getLangType();
2477-
if (typeDoc == L_CSS || typeDoc == L_CAML || typeDoc == L_ASM || typeDoc == L_MATLAB)
2481+
if (typeDoc == L_CSS || typeDoc == L_CAML || typeDoc == L_ASM || typeDoc == L_ASM_65C02 || typeDoc == L_MATLAB)
24782482
enc = CP_ACP; //you may also want to set charsets here, not yet implemented
24792483
else
24802484
enc = _codepage;

‎PowerEditor/src/ScintillaComponent/ScintillaEditView.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,13 @@ friend class Finder;
858858
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.asm.comment.explicit"), reinterpret_cast<LPARAM>("1"));
859859
}
860860

861+
void setAsm65C02Lexer(){
862+
setLexer(L_ASM_65C02, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6 | LIST_7);
863+
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.asm.syntax.based"), reinterpret_cast<LPARAM>("1"));
864+
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.asm.comment.multiline"), reinterpret_cast<LPARAM>("1"));
865+
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.asm.comment.explicit"), reinterpret_cast<LPARAM>("1"));
866+
}
867+
861868
void setDiffLexer(){
862869
setLexer(L_DIFF, LIST_NONE);
863870
}

‎PowerEditor/src/langs.model.xml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@
3333
<!-- name="DIRECTIVES, FOLD CLOSE" Keywords that close a fold region; these must *also* be in the DIRECTIVES category -->
3434
<Keywords name="type6">.endif .endsw end endp</Keywords>
3535
</Language>
36+
<Language name="asm65c02" ext="asm a65 s65" commentLine=";" commentStart="" commentEnd="">
37+
<!-- CPU INSTRUCTION: W65C02S = NMOS 6502 + CMOS additions + WDC (WAI/STP) + Rockwell (SMB/RMB/BBR/BBS). LexAsm matches case-insensitive by default. -->
38+
<Keywords name="instre1">adc and asl bcc bcs beq bit bmi bne bpl brk bvc bvs clc cld cli clv cmp cpx cpy dec dex dey eor inc inx iny jmp jsr lda ldx ldy lsr nop ora pha php pla plp rol ror rti rts sbc sec sed sei sta stx sty tax tay tsx txa txs tya bra phx phy plx ply stz trb tsb wai stp smb0 smb1 smb2 smb3 smb4 smb5 smb6 smb7 rmb0 rmb1 rmb2 rmb3 rmb4 rmb5 rmb6 rmb7 bbr0 bbr1 bbr2 bbr3 bbr4 bbr5 bbr6 bbr7 bbs0 bbs1 bbs2 bbs3 bbs4 bbs5 bbs6 bbs7</Keywords>
39+
<!-- MATH INSTRUCTION: unused (no FPU on 65C02) -->
40+
<Keywords name="instre2"></Keywords>
41+
<!-- REGISTER -->
42+
<Keywords name="type1">a x y s sp p pc</Keywords>
43+
<!-- DIRECTIVE: WDC Assembler/Linker directives -->
44+
<Keywords name="type2">equ db dw dd ds fill org chip endasm end include import export extern global public record macro mend mexit mlist mnolist if ifdef ifndef else elseif endif list nolist title subttl page lf clrlst radix code data bss udata dpage ipage</Keywords>
45+
<!-- DIRECTIVE OPERAND: unused in v1 -->
46+
<Keywords name="type3"></Keywords>
47+
<!-- EXT INSTRUCTION: unused in v1 -->
48+
<Keywords name="type4"></Keywords>
49+
<!-- FOLD OPEN: must also appear in type2 -->
50+
<Keywords name="type5">macro if ifdef ifndef</Keywords>
51+
<!-- FOLD CLOSE: must also appear in type2 -->
52+
<Keywords name="type6">mend endif</Keywords>
53+
</Language>
3654
<Language name="asn1" ext="mib" commentLine="" commentStart="" commentEnd="">
3755
<Keywords name="instre1">ACCESS AGENT AUGMENTS BEGIN BITS CAPABILITIES CHOICE COMPLIANCE CONTACT CONVENTION DEFINITIONS DEFVAL DESCRIPTION DISPLAY END ENTERPRISE EXPORTS FALSE FROM GROUP GROUPS HINT IDENTITY IMPLIED IMPORTS INCLUDES INDEX INFO LAST MANDATORY MAX MIN MODULE NOTATION NOTIFICATION NULL OBJECTS OBJECT-TYPE OF ORGANIZATION PRODUCT RELEASE REFERENCE REQUIRES REVISION SEQUENCE SIZE STATUS SUPPORTS SYNTAX TEXTUAL TRAP TYPE TRAP-TYPE UPDATED VALUE VARIABLES VARIATION WRITE</Keywords>
3856
<Keywords name="instre2">accessible create current deprecated for mandatory not notify not-accessible obsolete only optional read read-only read-write write</Keywords>

‎PowerEditor/src/menuCmdID.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@
571571
#define IDM_LANG_TOML (IDM_LANG + 91)
572572
#define IDM_LANG_SAS (IDM_LANG + 92)
573573
#define IDM_LANG_ERRORLIST (IDM_LANG + 93)
574+
#define IDM_LANG_ASM_65C02 (IDM_LANG + 94)
574575

575576
#define IDM_LANG_EXTERNAL (IDM_LANG + 165)
576577
#define IDM_LANG_EXTERNAL_LIMIT (IDM_LANG + 179)

‎PowerEditor/src/stylers.model.xml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@
8989
<WordsStyle name="CHARACTER" styleID="12" fgColor="808000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
9090
<WordsStyle name="EXT INSTRUCTION" styleID="14" fgColor="804000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="type4" />
9191
</LexerType>
92+
<LexerType name="asm65c02" desc="Assembly (65C02)" ext="">
93+
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
94+
<WordsStyle name="COMMENT" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
95+
<WordsStyle name="NUMBER" styleID="2" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
96+
<WordsStyle name="STRING" styleID="3" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
97+
<WordsStyle name="OPERATOR" styleID="4" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
98+
<WordsStyle name="IDENTIFIER" styleID="5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
99+
<WordsStyle name="CPU INSTRUCTION" styleID="6" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
100+
<WordsStyle name="MATH INSTRUCTION" styleID="7" fgColor="0080C0" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre2" />
101+
<WordsStyle name="REGISTER" styleID="8" fgColor="8080FF" bgColor="FFFFCC" fontName="" fontStyle="1" fontSize="" keywordClass="type1" />
102+
<WordsStyle name="DIRECTIVE" styleID="9" fgColor="0080FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" keywordClass="type2" />
103+
<WordsStyle name="DIRECTIVE OPERAND" styleID="10" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="type3" />
104+
<WordsStyle name="COMMENT BLOCK" styleID="11" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
105+
<WordsStyle name="CHARACTER" styleID="12" fgColor="808000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
106+
<WordsStyle name="EXT INSTRUCTION" styleID="14" fgColor="804000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="type4" />
107+
</LexerType>
92108
<LexerType name="autoit" desc="AutoIt" ext="">
93109
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
94110
<WordsStyle name="COMMENT LINE" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />

0 commit comments

Comments
 (0)