mirror of
https://github.com/ksherlock/65816.tmbundle.git
synced 2024-06-07 22:29:27 +00:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0466fe1791 | ||
|
e87d04edcc | ||
|
135b909b0d | ||
|
5ceb1a3418 | ||
|
f85bd90adc | ||
|
4dda716df5 | ||
|
d2a2e53078 | ||
|
f3fb502073 | ||
|
a6f23cc030 | ||
|
9c9afb75ef | ||
|
c5f707686d | ||
|
6609004905 | ||
|
16a2e8f434 | ||
|
3c99a37d4f | ||
|
09b757b56d | ||
|
8310fda0ae | ||
|
6c27bd47f8 | ||
|
ae713828a7 | ||
|
8e49e49694 | ||
|
27a5a9ac77 | ||
|
8389c42dd7 | ||
|
d4f53acba8 | ||
|
3ba6eb1d9f | ||
|
0692c4a4e8 | ||
|
835888a663 |
|
@ -2,6 +2,22 @@
|
|||
{
|
||||
"caption": "Merlin To Text",
|
||||
"command": "merlin_to_text"
|
||||
},
|
||||
{
|
||||
"caption": "Merlin MacGen",
|
||||
"command": "merlin_mac_gen"
|
||||
},
|
||||
{
|
||||
"caption": "Merlin Fix Space",
|
||||
"command": "merlin_fixs"
|
||||
},
|
||||
{
|
||||
"caption": "ORCA/M MacGen",
|
||||
"command": "orca_mac_gen"
|
||||
},
|
||||
{
|
||||
"caption": "MPW Asm IIgs MacGen",
|
||||
"command": "mpw_mac_gen"
|
||||
}
|
||||
]
|
||||
|
||||
|
|
5
Preferences.sublime-settings
Normal file
5
Preferences.sublime-settings
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"merlin_macro_directories": ["/Library/GoldenGate/Libraries/Merlin"],
|
||||
"orca_macro_directories": ["/Library/GoldenGate/Libraries/AInclude/", "/Library/GoldenGate/Libraries/ORCAInclude"],
|
||||
"mpw_macro_directories": ["/Library/MPW/Interfaces/AIIGSIncludes/"]
|
||||
}
|
|
@ -34,7 +34,7 @@ contexts:
|
|||
scope: keyword.mnemonic.65816.alt
|
||||
|
||||
mnemonics-65c02-m740:
|
||||
- match: \b(?i:CLT|COM|LDM|RRF|SET|TST)\b
|
||||
- match: \b(?i:CLT|COM|LDM|RRF|SET|TST|MUL|DIV|CLB|SEB|BBC|BBS)\b
|
||||
scope: keyword.mnemonic.m740
|
||||
|
||||
mnemonics-sweet16:
|
||||
|
|
|
@ -114,13 +114,13 @@ contexts:
|
|||
- include: eol
|
||||
|
||||
numbers:
|
||||
- match: \d+
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01]+
|
||||
- match: \%[01]+\b
|
||||
scope: constant.numeric.binary
|
||||
- match: \@[0-7]+
|
||||
- match: \@[0-7]+\b
|
||||
scope: constant.numeric.octal
|
||||
|
||||
strings:
|
||||
|
|
|
@ -21,20 +21,20 @@ contexts:
|
|||
- match: '^({{ident}}){{ws}}((?i)PROC|PROCNAME|FUNC|INIT)\b'
|
||||
captures:
|
||||
1: entity.name.function
|
||||
2: keyword.directive
|
||||
2: meta.opcode keyword.directive
|
||||
push: operand-proc
|
||||
|
||||
|
||||
- match: '^({{ident}}){{ws}}((?i)STACKDP)\b'
|
||||
captures:
|
||||
1: entity.name.function
|
||||
2: keyword.directive
|
||||
2: meta.operand keyword.directive
|
||||
push: operand-stackdp
|
||||
|
||||
- match: '^({{ident}}){{ws}}((?i)RECORD)\b'
|
||||
captures:
|
||||
1: entity.name.record
|
||||
2: keyword.directive
|
||||
2: meta.operand keyword.directive
|
||||
push: operand-record
|
||||
|
||||
|
||||
|
@ -53,8 +53,11 @@ contexts:
|
|||
pop: true
|
||||
|
||||
opcode:
|
||||
- meta_content_scope: meta.opcode
|
||||
|
||||
- match: '{{ws}}'
|
||||
set: operand
|
||||
|
||||
- include: scope:source.asm.65816#mnemonics-6502
|
||||
- include: scope:source.asm.65816#mnemonics-65c02
|
||||
- include: scope:source.asm.65816#mnemonics-65816
|
||||
|
@ -62,11 +65,12 @@ contexts:
|
|||
- include: mnemonics-65816-alt
|
||||
|
||||
# toolbox macros
|
||||
# matches _ for toolbox completion.
|
||||
- match: \b_[A-Za-z0-9]+\b
|
||||
scope: support.function.macro.toolbox
|
||||
|
||||
|
||||
- match: \b((?i)DC|DCB|DS)([.](.))?
|
||||
- match: \b((?i)DCB|DC|DS)([.](.))?
|
||||
scope: meta.dc.directive
|
||||
captures:
|
||||
1: keyword.directive.data
|
||||
|
@ -215,12 +219,11 @@ contexts:
|
|||
|
||||
operand-print:
|
||||
- include: macro-parm
|
||||
- match: ','
|
||||
- match: \b(?i:ON|OFF|PUSH|POP)\b
|
||||
scope: constant.language
|
||||
set: expect-comment
|
||||
- match: \b(?i:NO)?(?i:GEN|PAGE|WARN|MCALL|OBJ|DATA|MDIR|HDR|LITS|STAT|SYM)\b
|
||||
scope: constant.language
|
||||
set: expect-comment
|
||||
- include: expect-comment
|
||||
|
||||
|
||||
|
@ -249,6 +252,8 @@ contexts:
|
|||
- include: expect-comment
|
||||
|
||||
operand:
|
||||
- meta_content_scope: meta.operand
|
||||
|
||||
- include: macro-parm
|
||||
|
||||
- include: numbers
|
||||
|
@ -266,13 +271,13 @@ contexts:
|
|||
|
||||
|
||||
numbers:
|
||||
- match: \d+
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01]+
|
||||
- match: \%[01]+\b
|
||||
scope: constant.numeric.binary
|
||||
- match: \@[0-7]+
|
||||
- match: \@[0-7]+\b
|
||||
scope: constant.numeric.octal
|
||||
|
||||
strings:
|
||||
|
|
|
@ -155,16 +155,16 @@ contexts:
|
|||
pop: true
|
||||
|
||||
numbers:
|
||||
- match: 0[0-7]+
|
||||
- match: \b0[0-7]+\b
|
||||
scope: constant.numeric.octal
|
||||
- match: 0[xX][0-9A-Fa-f]+
|
||||
- match: \b0[xX][0-9A-Fa-f]+\b
|
||||
scope: constant.numeric.hexadecimal
|
||||
- match: 0[qQ][0-3]+
|
||||
- match: \b0[qQ][0-3]+\b
|
||||
scope: constant.numeric.quarters
|
||||
- match: 0[bB][01]+
|
||||
- match: \b0[bB][01]+\b
|
||||
scope: constant.numeric
|
||||
|
||||
- match: \d+
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
|
||||
- match: \'([^'\n]|\\.)\'
|
||||
|
|
185
Syntaxes/Merlin-Linker.sublime-syntax
Normal file
185
Syntaxes/Merlin-Linker.sublime-syntax
Normal file
|
@ -0,0 +1,185 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
# AUX, ZIP, IMP, PFX, REZ - quick asm extensions.
|
||||
name: Merlin Link Script
|
||||
file_extensions:
|
||||
- S
|
||||
scope: source.linker.merlin
|
||||
|
||||
variables:
|
||||
ws: '[ \t]+'
|
||||
ident: '[:-~][0-~]*'
|
||||
|
||||
|
||||
contexts:
|
||||
prototype:
|
||||
- include: comment
|
||||
- include: eol
|
||||
main:
|
||||
|
||||
- meta_include_prototype: false
|
||||
|
||||
- match: ^[;*]
|
||||
push:
|
||||
- meta_scope: comment.line
|
||||
- match: \n
|
||||
pop: true
|
||||
|
||||
- match: '^{{ident}}'
|
||||
scope: entity.name.label
|
||||
|
||||
- match: '{{ws}}'
|
||||
push: opcode
|
||||
|
||||
eol:
|
||||
- match: '$'
|
||||
pop: true
|
||||
|
||||
comment:
|
||||
- match: (?<=[\t ]);
|
||||
push:
|
||||
- meta_scope: comment.line
|
||||
- match: \n
|
||||
pop: true
|
||||
- include: eol
|
||||
|
||||
expect-comment:
|
||||
- include: comment
|
||||
- match: \S
|
||||
scope: invalid.illegal.expect.comment
|
||||
|
||||
numbers:
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01_]+\b
|
||||
scope: constant.numeric.binary
|
||||
|
||||
strings:
|
||||
# special case for ''' and """
|
||||
- match: "(')'(')"
|
||||
captures:
|
||||
0: string.quoted.single
|
||||
1: punctuation.definition.string.begin
|
||||
2: punctuation.definition.string.end
|
||||
|
||||
- match: '(")"(")'
|
||||
captures:
|
||||
0: string.quoted.double
|
||||
1: punctuation.definition.string.begin
|
||||
2: punctuation.definition.string.end
|
||||
|
||||
- match: "'"
|
||||
scope: punctuation.definition.string.begin
|
||||
push:
|
||||
- meta_include_prototype: false
|
||||
- meta_scope: string.quoted.single
|
||||
- match: "'"
|
||||
scope: punctuation.definition.string.end
|
||||
pop: true
|
||||
- match: \n
|
||||
scope: invalid.illegal.newline.asm
|
||||
pop: true
|
||||
- match: '"'
|
||||
scope: punctuation.definition.string.begin
|
||||
push:
|
||||
- meta_include_prototype: false
|
||||
- meta_scope: string.quoted.double
|
||||
- match: '"'
|
||||
scope: punctuation.definition.string.end
|
||||
pop: true
|
||||
- match: \n
|
||||
scope: invalid.illegal.newline.asm
|
||||
pop: true
|
||||
|
||||
|
||||
opcode:
|
||||
- match: '{{ws}}'
|
||||
set: expect-comment
|
||||
|
||||
# numeric operand
|
||||
- match: \b(?i:ORG|ADR|DS|KND|KIND?|LKV|VER|DO|EQU|GEQU?|ALI|RTY|RID|RAT|AUX)\b
|
||||
scope: keyword.directive
|
||||
set: operand-number
|
||||
|
||||
- match: '='
|
||||
scope: keyword.directive
|
||||
set: operand-number
|
||||
|
||||
|
||||
- match: \b(?i:TYP)\b
|
||||
scope: keyword.directive
|
||||
set: operand-typ
|
||||
|
||||
# path operand
|
||||
- match: \b(?i:PUT|ASM|LINK?|LNK|SAV|IF|LIB|RES|FIL|IMP|PFX|REZ)\b
|
||||
scope: keyword.directive
|
||||
set: operand-path
|
||||
|
||||
- match: \b(?i:CMD)\b
|
||||
scope: keyword.directive
|
||||
set: operand-free-text
|
||||
|
||||
- match: \b(?i:KBD)\b
|
||||
scope: keyword.directive
|
||||
set: operand-string
|
||||
|
||||
- match: \b(?i:OVR)\b
|
||||
scope: keyword.directive
|
||||
set: operand-ovr
|
||||
|
||||
# no operand
|
||||
- match: \b(?i:END|DAT|ENT|EXT|NOL|FAS|ELS|FIN)\b
|
||||
scope: keyword.directive
|
||||
set: operand-none
|
||||
|
||||
- match: \b(?i:POS|LEN)\b
|
||||
scope: keyword.directive
|
||||
set: operand-label
|
||||
|
||||
|
||||
|
||||
operand-none:
|
||||
- include: expect-comment
|
||||
|
||||
operand-label:
|
||||
- match: '{{ident}}'
|
||||
scope: entity.name.label
|
||||
set: expect-comment
|
||||
- include: expect-comment
|
||||
|
||||
operand-ovr:
|
||||
# OVR ALL | OFF | <blank>
|
||||
- match: \b(?i:ALL|OFF)\b
|
||||
scope: constant.language
|
||||
set: expect-comment
|
||||
- include: expect-comment
|
||||
|
||||
operand-path:
|
||||
- match: \S+
|
||||
scope: string.unquoted
|
||||
set: expect-comment
|
||||
- include: expect-comment
|
||||
|
||||
operand-free-text:
|
||||
- match: '.'
|
||||
scope: string.unquoted
|
||||
|
||||
operand-typ:
|
||||
# TYP <short name or number>
|
||||
- include: numbers
|
||||
- match: \b(?i:BAD|BIN|TXT|DIR|ADB|AWP|ASP|GSB|TDF|BDF|SRC|OBJ|LIB|S16|RTL|EXE|PIF|TIF|NDA|CDA|TOL|DRV|DOC|PNT|PIC|FON|PAS|CMD)\b
|
||||
scope: constant.language
|
||||
- include: expect-comment
|
||||
|
||||
operand-number:
|
||||
- include: numbers
|
||||
- match: '{{ident}}'
|
||||
scope: entity.name.label
|
||||
set: expect-comment
|
||||
- include: expect-comment
|
||||
|
||||
operand-string:
|
||||
- include: strings
|
||||
- include: expect-comment
|
|
@ -7,6 +7,7 @@ scope: source.asm.65816.merlin
|
|||
variables:
|
||||
ws: '[ \t]+'
|
||||
ident: '[:-~][0-~]*'
|
||||
lident: '[\]:][0-~]*'
|
||||
|
||||
contexts:
|
||||
prototype:
|
||||
|
@ -27,7 +28,7 @@ contexts:
|
|||
|
||||
- match: '^({{ident}}){{ws}}((?i)MAC)\b'
|
||||
captures:
|
||||
1: entity.name.macro
|
||||
1: entity.name.function
|
||||
2: keyword.directive
|
||||
push: operand
|
||||
|
||||
|
@ -50,10 +51,12 @@ contexts:
|
|||
2: keyword.directive
|
||||
push: operand
|
||||
|
||||
- match: '^{{lident}}'
|
||||
scope: entity.name.label.local
|
||||
|
||||
|
||||
- match: '^{{ident}}'
|
||||
scope: entity.name.label
|
||||
scope: entity.name.function
|
||||
|
||||
|
||||
opcode:
|
||||
|
@ -73,7 +76,7 @@ contexts:
|
|||
scope: support.function.smart-macro.toolbox
|
||||
|
||||
|
||||
- match: \b(?i:DFB|DB|DDB|DA|DW|ADR|ADRL|DS)\b
|
||||
- match: \b(?i:DFB|DB|DDB|DA|DW|ADR|ADRL|DL|DS)\b
|
||||
scope: keyword.directive.data
|
||||
|
||||
- match: \b(?i:HEX)\b
|
||||
|
@ -89,9 +92,14 @@ contexts:
|
|||
- match: =|<<<|--\^|>>>
|
||||
scope: keyword.directive
|
||||
|
||||
- match: \b(?i:PMC|ORG|REL|TYP|DUM|DEND|END|CHK|DAT|ERR|EXT|EXD|OBJ|VAR|AST|DAT|PAG|SKP|CHK|ERR|KBD|PAU|SW|USR)\b
|
||||
- match: \b(?i:PMC|ORG|REL|TYP|DUM|DEND|END|CHK|DAT|ERR|EXT|EXD|OBJ|VAR|AST|DAT|PAG|SKP|CHK|ERR|KBD|PAU|SW|USR|MAC|EOM)\b
|
||||
scope: keyword.directive
|
||||
|
||||
# IF MX..
|
||||
# IF char=]\d
|
||||
- match: \b(?i:IF)\b
|
||||
scope: keyword.control.conditional
|
||||
set: if-operand
|
||||
|
||||
- match: \b(?i:DO|ELSE|IF|FIN)\b
|
||||
scope: keyword.control.conditional
|
||||
|
@ -108,6 +116,9 @@ contexts:
|
|||
scope: keyword.directive
|
||||
set: operand-off
|
||||
|
||||
- match: \b(?i:MX)\b
|
||||
scope: keyword.directive
|
||||
|
||||
- match: \b(?i:CAS)\b
|
||||
scope: keyword.directive
|
||||
set: operand-cas
|
||||
|
@ -142,8 +153,22 @@ contexts:
|
|||
operand:
|
||||
- include: numbers
|
||||
- include: strings
|
||||
- match: ']\d+'
|
||||
scope: variable.other
|
||||
#- include: macro-parm
|
||||
|
||||
if-operand:
|
||||
|
||||
- match: \b(?i:MX)\b
|
||||
scope: constant.language
|
||||
- match: '(.)[,=](]\d+)'
|
||||
captures:
|
||||
1: string.unquoted
|
||||
2: variable.other
|
||||
|
||||
- include: numbers
|
||||
|
||||
|
||||
operand-hex:
|
||||
- match: '[0-9A-Fa-f]{2}'
|
||||
scope: constant.numeric.hex
|
||||
|
@ -162,6 +187,8 @@ contexts:
|
|||
- match: '[0-9A-Fa-f]{2}'
|
||||
scope: constant.numeric.hex
|
||||
- match: ','
|
||||
- match: ']\d+'
|
||||
scope: variable.other
|
||||
- include: expect-comment
|
||||
|
||||
|
||||
|
@ -220,7 +247,7 @@ contexts:
|
|||
scope: invalid.illegal.expect.comment
|
||||
|
||||
comment:
|
||||
- match: ;
|
||||
- match: (?<=[\t ]);
|
||||
push:
|
||||
- meta_scope: comment.line
|
||||
- match: \n
|
||||
|
@ -233,14 +260,27 @@ contexts:
|
|||
scope: keyword.mnemonic.65816.alt
|
||||
|
||||
numbers:
|
||||
- match: \d+
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01_]+
|
||||
- match: \%[01_]+\b
|
||||
scope: constant.numeric.binary
|
||||
|
||||
strings:
|
||||
# special case for ''' and """
|
||||
- match: "(')'(')"
|
||||
captures:
|
||||
0: string.quoted.single
|
||||
1: punctuation.definition.string.begin
|
||||
2: punctuation.definition.string.end
|
||||
|
||||
- match: '(")"(")'
|
||||
captures:
|
||||
0: string.quoted.double
|
||||
1: punctuation.definition.string.begin
|
||||
2: punctuation.definition.string.end
|
||||
|
||||
- match: "'"
|
||||
scope: punctuation.definition.string.begin
|
||||
push:
|
||||
|
|
113
Syntaxes/Micol.sublime-syntax
Normal file
113
Syntaxes/Micol.sublime-syntax
Normal file
|
@ -0,0 +1,113 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
name: Micol Macro Assembler
|
||||
scope: source.asm.65816.micol
|
||||
|
||||
# https://archive.org/details/Micol-Macro_Assembler_V2.01/
|
||||
|
||||
variables:
|
||||
ws: '[ \t]+'
|
||||
ident: '[A-Za-z][A-Za-z0-9_]*'
|
||||
|
||||
contexts:
|
||||
|
||||
prototype:
|
||||
- include: eol
|
||||
|
||||
main:
|
||||
- meta_include_prototype: false
|
||||
|
||||
- match: ^[;]
|
||||
push:
|
||||
- meta_scope: comment.line
|
||||
- match: \n
|
||||
pop: true
|
||||
|
||||
- match: '{{ws}}'
|
||||
push: opcode
|
||||
|
||||
# all labels need an opcode.
|
||||
# LABEL is a reserved label.
|
||||
|
||||
- match: ^{{ident}}
|
||||
scope: entity.name.label
|
||||
|
||||
opcode:
|
||||
- match: '{{ws}}'
|
||||
set: operand
|
||||
|
||||
- include: scope:source.asm.65816#mnemonics-6502
|
||||
- include: scope:source.asm.65816#mnemonics-65c02
|
||||
- include: scope:source.asm.65816#mnemonics-65816
|
||||
- include: mnemonics-65816-alt
|
||||
|
||||
- match: <<<|>>>
|
||||
scope: keyword.directive
|
||||
|
||||
- match: \b(?i:EQU|ORG|PRG|EJT|LST|NLT|NPR|PRI|EMU|I08|I16|M08|M16|NAT)\b
|
||||
scope: keyword.directive
|
||||
|
||||
- match: \b(?i:RES|ABS|ASC|BYT|LWD|WOR)\b
|
||||
scope: keyword.directive.data
|
||||
|
||||
# macro
|
||||
- match: \b(?i:EXP|MAC|TMC)\b
|
||||
scope: keyword.directive
|
||||
|
||||
- match: \b(?i:CHN|INS)\b
|
||||
scope: keyword.control.import
|
||||
set: operand-path
|
||||
|
||||
- match: \b(?i:ELS|IFF|STP)\b
|
||||
scope: keyword.control.conditional
|
||||
|
||||
|
||||
mnemonics-65816-alt:
|
||||
- match: \b(?i:DEA|INA)\b
|
||||
scope: keyword.mnemonic.65816.alt
|
||||
|
||||
operand:
|
||||
- include: numbers
|
||||
- include: strings
|
||||
|
||||
|
||||
# LABFW, LABBK, A, X, Y are reserved labels.
|
||||
- match: \b(?i:LABEL|LABBK|LABFW|A|X|Y)\b
|
||||
scope: entity.name.label
|
||||
# scope: variable.language
|
||||
|
||||
# macro parms
|
||||
- match: \?[0-9A-Za-z]\b
|
||||
scope: variable.other
|
||||
|
||||
operand-path:
|
||||
- match: \S+
|
||||
scope: string.unquoted
|
||||
|
||||
|
||||
numbers:
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01]+\b
|
||||
scope: constant.numeric.binary
|
||||
- match: \@[0-7]+\b
|
||||
scope: constant.numeric.oct
|
||||
|
||||
strings:
|
||||
- match: "'"
|
||||
scope: punctuation.definition.string.begin
|
||||
push:
|
||||
- meta_include_prototype: false
|
||||
- meta_scope: string.quoted.single
|
||||
- match: "'"
|
||||
scope: punctuation.definition.string.end
|
||||
pop: true
|
||||
- match: '\n'
|
||||
scope: invalid.illegal.newline.asm
|
||||
pop: true
|
||||
|
||||
eol:
|
||||
- match: '$'
|
||||
pop: true
|
|
@ -122,15 +122,15 @@ contexts:
|
|||
|
||||
|
||||
numbers:
|
||||
- match: \d+
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01]+
|
||||
- match: \%[01]+\b
|
||||
scope: constant.numeric.binary
|
||||
|
||||
macro-parm:
|
||||
- match: '&\d'
|
||||
- match: '&\d\b'
|
||||
scope: variable.other
|
||||
|
||||
strings:
|
||||
|
|
|
@ -59,7 +59,7 @@ contexts:
|
|||
scope: keyword.directive
|
||||
set: operand-dc
|
||||
|
||||
- match: \b(?i:APPEND|COPY|KEEP|MCOPY)\b
|
||||
- match: \b(?i:APPEND|COPY|KEEP|MCOPY|MLOAD|MDROP)\b
|
||||
scope: keyword.control.import
|
||||
set: operand-path
|
||||
|
||||
|
@ -286,13 +286,13 @@ contexts:
|
|||
|
||||
|
||||
numbers:
|
||||
- match: \d+
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01]+
|
||||
- match: \%[01]+\b
|
||||
scope: constant.numeric.binary
|
||||
- match: \@[0-7]+
|
||||
- match: \@[0-7]+\b
|
||||
scope: constant.numeric.octal
|
||||
|
||||
strings:
|
||||
|
|
282
Syntaxes/SNASM.sublime-syntax
Normal file
282
Syntaxes/SNASM.sublime-syntax
Normal file
|
@ -0,0 +1,282 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
name: SN Assembler
|
||||
scope: source.asm.65816.sn
|
||||
|
||||
# @ is the default local prefix, but /opt l can change it. : was common.
|
||||
variables:
|
||||
ws: '[ \t]+'
|
||||
ident: '[A-Za-z_.][A-Za-z0-9_.]*'
|
||||
local: '[@:][A-Za-z0-9_.]+'
|
||||
|
||||
|
||||
|
||||
contexts:
|
||||
prototype:
|
||||
- include: comment
|
||||
- include: eol
|
||||
main:
|
||||
|
||||
- meta_include_prototype: false
|
||||
|
||||
- match: '{{ws}}'
|
||||
push: opcode
|
||||
|
||||
- match: '^({{ident}}){{ws}}((?i)MODULE)\b'
|
||||
captures:
|
||||
1: entity.name.function
|
||||
2: keyword.directive
|
||||
push: operand
|
||||
|
||||
- match: '^({{ident}}){{ws}}((?i)MACRO)\b'
|
||||
captures:
|
||||
1: entity.name.function
|
||||
2: keyword.directive
|
||||
push: operand-macro
|
||||
|
||||
|
||||
|
||||
- match: '^{{ident}}'
|
||||
scope: entity.name.function
|
||||
|
||||
- match: '^{{local}}'
|
||||
scope: entity.name.label.local
|
||||
|
||||
|
||||
- include: comment
|
||||
|
||||
|
||||
opcode:
|
||||
- match: '{{ws}}'
|
||||
set: operand
|
||||
|
||||
- include: scope:source.asm.65816#mnemonics-6502
|
||||
- include: scope:source.asm.65816#mnemonics-65c02
|
||||
- include: scope:source.asm.65816#mnemonics-65c02s
|
||||
- include: scope:source.asm.65816#mnemonics-65816
|
||||
- include: mnemonics-65816-alt
|
||||
|
||||
- match: \b(?i:DB|DW|DT|DL)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:HEX)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:DS|DCB)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
# reserve space
|
||||
- match: \b(?i:RSRESET|RSSET|RB|RW)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
|
||||
|
||||
- match: \b(?i:EQU|SET)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:MACRO|ENDM|MEXIT|SHIFT)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:SECTION|GRP)\b
|
||||
scope: keyword.directive
|
||||
set: operand-section
|
||||
|
||||
- match: \b(?i:ORG|END|OPT|MX)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:XDEF|XREF)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:ASSUME)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
|
||||
- match: \b(?i:MODULE|MODEND)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:REPT|ENDR)\b
|
||||
scope: keyword.directive.keyword.control
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:CASE|ENDCASE)\b
|
||||
scope: keyword.directive.keyword.control
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:WHILE|ENDW)\b
|
||||
scope: keyword.directive.keyword.control
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:DO|UNTIL)\b
|
||||
scope: keyword.directive.keyword.control
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:IF|ELSE|ENDIF|ENDC)\b
|
||||
scope: keyword.directive.keyword.control
|
||||
set: operand
|
||||
|
||||
|
||||
- match: \b(?i:PUBLIC)\b
|
||||
scope: keyword.directive
|
||||
set: operand-on-off
|
||||
|
||||
|
||||
- match: \b(?i:LIST|NOLIST)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:INFORM)\b
|
||||
scope: keyword.directive
|
||||
set: operand
|
||||
|
||||
- match: \b(?i:INCLUDE|INCBIN)\b
|
||||
scope: keyword.directive
|
||||
set: operand-path
|
||||
|
||||
|
||||
operand:
|
||||
- include: numbers
|
||||
- include: strings
|
||||
|
||||
|
||||
- match: \b(?i:__MX|__RS|_RADIX|_RCOUNT|_FILENAME|_CURRENT_FILE|_CURRENT_LINE)\b
|
||||
scope: keyword.directive
|
||||
|
||||
- match: \b(?i:NARG)\b
|
||||
scope: keyword.directive
|
||||
|
||||
- match: \b(?i:_YEAR|_MONTH|_DAY|_WEEKDAY|_HOURS|_MINUTES|_SECONDS)\b
|
||||
scope: support.constant
|
||||
|
||||
- match: \b(?i:DEF|REF|TYPE|STRCMP|STRICMP|STRLEN|SUBSTR|GROUPEND|SECTEND|GROUPORG|SECTSIZE|GROUPSIZE|ALIGNMENT|SECT|OFFSET|FILESIZE|SQRT)\b
|
||||
scope: support.function
|
||||
|
||||
|
||||
operand-section:
|
||||
- match: '\b{{ident}}\b'
|
||||
scope: entity.name.function
|
||||
set: expect-comment
|
||||
- include: expect-comment
|
||||
|
||||
operand-on-off:
|
||||
- match: \b(?i:ON|OFF)\b
|
||||
scope: constant.language
|
||||
set: expect-comment
|
||||
- include: expect-comment
|
||||
|
||||
|
||||
|
||||
operand-ascii:
|
||||
- meta_include_prototype: false
|
||||
- match: '{{ws}}'
|
||||
- match: '([^\r\n|]+)'
|
||||
scope: string.unquoted
|
||||
- match: \|
|
||||
set: comment
|
||||
- include: eol
|
||||
|
||||
operand-fcc:
|
||||
- match: (\S)
|
||||
scope: punctuation.definition.string.begin
|
||||
push:
|
||||
- meta_include_prototype: false
|
||||
- meta_scope: string.quoted
|
||||
- match: \1
|
||||
scope: punctuation.definition.string.end
|
||||
pop: true
|
||||
- match: \n
|
||||
scope: invalid.illegal
|
||||
pop: true
|
||||
|
||||
operand-path:
|
||||
- include: strings
|
||||
|
||||
operand-macro:
|
||||
- match: '\b{{ident}}\b'
|
||||
scope: variable.parameter
|
||||
|
||||
# comment char
|
||||
# ...
|
||||
# char
|
||||
operand-comment:
|
||||
- meta_include_prototype: false
|
||||
|
||||
- match: (\S)
|
||||
scope: punctuation.definition.comment.begin.asm
|
||||
set: [comment, comment-block]
|
||||
|
||||
- match: \n
|
||||
scope: invalid.illegal.newline.asm
|
||||
pop: true
|
||||
|
||||
comment-block:
|
||||
- meta_include_prototype: false
|
||||
- meta_scope: comment.block
|
||||
- match: \1
|
||||
scope: punctuation.definition.comment.end.asm
|
||||
pop: true # pops to comment.
|
||||
|
||||
|
||||
numbers:
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01]+\b
|
||||
scope: constant.numeric.binary
|
||||
|
||||
strings:
|
||||
- match: "'"
|
||||
scope: punctuation.definition.string.begin
|
||||
push:
|
||||
- meta_include_prototype: false
|
||||
- meta_scope: string.quoted.single
|
||||
- match: "'"
|
||||
scope: punctuation.definition.string.end
|
||||
pop: true
|
||||
- match: \n
|
||||
scope: invalid.illegal.newline.asm
|
||||
pop: true
|
||||
- match: '"'
|
||||
scope: punctuation.definition.string.begin
|
||||
push:
|
||||
- meta_include_prototype: false
|
||||
- meta_scope: string.quoted.double
|
||||
- match: '"'
|
||||
scope: punctuation.definition.string.end
|
||||
pop: true
|
||||
- match: \n
|
||||
scope: invalid.illegal.newline.asm
|
||||
pop: true
|
||||
|
||||
expect-comment:
|
||||
- include: comment
|
||||
- match: \S
|
||||
scope: invalid.illegal.expect.comment
|
||||
|
||||
comment:
|
||||
- match: ;
|
||||
push:
|
||||
- meta_scope: comment.line.partial
|
||||
- match: \n
|
||||
pop: true
|
||||
- include: eol
|
||||
|
||||
|
||||
mnemonics-65816-alt:
|
||||
- match: \b(?i:BLT|BGE|CPA|DEA|INA|SWA|TAD|TAS|TDA|TSA)\b
|
||||
scope: keyword.mnemonic.65816.alt
|
||||
|
||||
|
||||
eol:
|
||||
- match: '$'
|
||||
pop: true
|
|
@ -191,11 +191,11 @@ contexts:
|
|||
|
||||
|
||||
numbers:
|
||||
- match: \d+
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01]+
|
||||
- match: \%[01]+\b
|
||||
scope: constant.numeric.binary
|
||||
|
||||
strings:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
name: CA65
|
||||
file_extensions: []
|
||||
scope: source.asm.ca65
|
||||
|
||||
variables:
|
||||
|
@ -240,3 +241,13 @@ contexts:
|
|||
- match: \b(?i:RTN|SET|LD|LDD|ST|STD|POP|POPD|STP|ADD|SUB|CPR|INR|DCR|BR|BNC|BC|BP|BM|BZ|BNZ|BM1|BNM1|BK|RS|BS)\b
|
||||
scope: keyword.mnemonic.sweet16
|
||||
set: operand
|
||||
|
||||
mnemonics-macpack-generic:
|
||||
- match: \b(?i:ADD|SUB|BGE|BLT|BGT|BLE|BNZ|BZE)\b
|
||||
scope: keyword.mnemonic.macpack.generic
|
||||
set: operand
|
||||
|
||||
mnemonics-macpack-longbranch:
|
||||
- match: \b(?i:JEQ|JNE|JMI|JPL|JCS|JCC|JVS|JVC)\b
|
||||
scope: keyword.mnemonic.macpack.longbranch
|
||||
set: operand
|
||||
|
|
220
Syntaxes/sc-asm.sublime-syntax
Normal file
220
Syntaxes/sc-asm.sublime-syntax
Normal file
|
@ -0,0 +1,220 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
name: S-C Assembler
|
||||
file_extensions: []
|
||||
scope: source.asm.sc-asm
|
||||
|
||||
variables:
|
||||
ws: '[ \t]+'
|
||||
xws: '[ \t\x08]*'
|
||||
ident: '[A-Za-z][A-Za-z0-9.]*'
|
||||
lident: '.[0-9]{1,2}'
|
||||
|
||||
contexts:
|
||||
prototype:
|
||||
- include: eol
|
||||
main:
|
||||
|
||||
- meta_include_prototype: false
|
||||
|
||||
- match: ^[*]
|
||||
push:
|
||||
- meta_scope: comment.line
|
||||
- match: \n
|
||||
pop: true
|
||||
|
||||
|
||||
# assembler commands. there are others but these are used by a2osx...
|
||||
- match: '^{{xws}}((?i)NEW|AUTO|MANUAL|MAN|ASM)\b'
|
||||
captures:
|
||||
1: keyword.directive
|
||||
# scope: keyword.directive
|
||||
push:
|
||||
- match: $
|
||||
pop: true
|
||||
|
||||
- match: '^{{xws}}((?i)SAVE|LOAD)\b'
|
||||
captures:
|
||||
1: keyword.directive
|
||||
# scope: keyword.directive
|
||||
push: operand-path
|
||||
|
||||
|
||||
|
||||
|
||||
- match: '{{ws}}'
|
||||
push: opcode
|
||||
|
||||
- match: '^{{ws}}((?i)\.MA)\s({{ident}})'
|
||||
captures:
|
||||
2: keyword.directive
|
||||
1: entity.name.function
|
||||
push: eol
|
||||
|
||||
|
||||
- match: '^({{ident}}){{ws}}\.((?i)EQ)\b'
|
||||
captures:
|
||||
1: entity.name.constant
|
||||
2: keyword.directive
|
||||
push: operand
|
||||
|
||||
- match: '^{{lident}}'
|
||||
scope: entity.name.label.local
|
||||
|
||||
|
||||
- match: '^{{ident}}'
|
||||
scope: entity.name.function
|
||||
|
||||
|
||||
opcode:
|
||||
- match: '{{ws}}'
|
||||
set: operand
|
||||
- include: scope:source.asm.65816#mnemonics-6502
|
||||
- include: scope:source.asm.65816#mnemonics-65c02
|
||||
- include: scope:source.asm.65816#mnemonics-65c02s
|
||||
- include: scope:source.asm.65816#mnemonics-65816
|
||||
- include: mnemonics-6502-alt
|
||||
|
||||
|
||||
- match: \.(?i:DA)\b
|
||||
scope: keyword.directive.data
|
||||
set: operand
|
||||
|
||||
- match: \.(?i:HS)\b
|
||||
scope: keyword.directive.data
|
||||
set: operand-hex
|
||||
|
||||
- match: \.(?i:AS|AT|AZ)\b
|
||||
scope: keyword.directive.data
|
||||
set: operand-string
|
||||
|
||||
- match: \.(?i:OP)\b
|
||||
scope: keyword.directive
|
||||
set: operand-op
|
||||
|
||||
|
||||
- match: \.(?i:INB|IN|TF)\b
|
||||
scope: keyword.control.import
|
||||
set: operand-path
|
||||
|
||||
|
||||
- match: \.(?i:LIST)\b
|
||||
scope: keyword.directive
|
||||
set: operand-list
|
||||
|
||||
|
||||
- match: \.(?i:AC|AS|AT|AZ|BS|DA|DO|DUMMY|ED|ELSE|EM|EN|EP|EQ|FIN|HS|IN|INB|LIST|MA|OP|OR|PG|PH|TA|TF|TI|US)\b
|
||||
scope: keyword.directive
|
||||
|
||||
|
||||
|
||||
- match: '>{{ident}}'
|
||||
scope: variable.function.macro
|
||||
set: operand
|
||||
|
||||
|
||||
|
||||
operand:
|
||||
- include: numbers
|
||||
- include: strings
|
||||
- match: ']\d+'
|
||||
scope: variable.other
|
||||
#- include: macro-parm
|
||||
|
||||
|
||||
|
||||
operand-op:
|
||||
- match: '(?i:6502|SW16|65C02|65R02|65802|65816)'
|
||||
scope: constant.language
|
||||
set: comment
|
||||
- include: error
|
||||
|
||||
operand-hex:
|
||||
- match: '[0-9A-Fa-f]{2}'
|
||||
scope: constant.numeric.hex
|
||||
- include: expect-comment
|
||||
|
||||
|
||||
operand-path:
|
||||
- match: \S+
|
||||
scope: string.unquoted
|
||||
set: expect-comment
|
||||
- include: expect-comment
|
||||
|
||||
# -? delimiter (anything but delimiter)* delimiter
|
||||
# pop: 1 needed for \1 backref matching.
|
||||
operand-string:
|
||||
|
||||
- match: '-?([^ \t-])'
|
||||
scope: punctuation.definition.string.begin
|
||||
push: [comment, operand-string-inner]
|
||||
|
||||
# - include: expect-comment
|
||||
|
||||
operand-string-inner:
|
||||
- meta_scope: string.quoted
|
||||
- match: \1
|
||||
scope: punctuation.definition.string.end
|
||||
pop: true
|
||||
|
||||
|
||||
operand-list:
|
||||
# .LIST ON | OFF | CON | COFF | MON | MOFF | XON | XOFF
|
||||
- match: \b(?i:[CMX]?ON|[CMX]?OFF)\b
|
||||
scope: constant.language
|
||||
set: comment
|
||||
|
||||
- include: error
|
||||
|
||||
|
||||
|
||||
error:
|
||||
- match: \S
|
||||
scope: invalid.illegal.expect.comment
|
||||
|
||||
|
||||
expect-comment:
|
||||
- include: comment
|
||||
- match: \S
|
||||
scope: invalid.illegal.expect.comment
|
||||
|
||||
comment:
|
||||
- match: (?<=[\t ])
|
||||
push:
|
||||
- meta_scope: comment.line
|
||||
- match: \n
|
||||
pop: true
|
||||
- include: eol
|
||||
|
||||
|
||||
mnemonics-6502-alt:
|
||||
- match: \b(?i:BLT|BGE)\b
|
||||
scope: keyword.mnemonic.6502.alt
|
||||
|
||||
numbers:
|
||||
- match: \b\d+\b
|
||||
scope: constant.numeric
|
||||
- match: \$[0-9a-fA-F]+\b
|
||||
scope: constant.numeric.hex
|
||||
- match: \%[01_]+\b
|
||||
scope: constant.numeric.binary
|
||||
|
||||
strings:
|
||||
|
||||
- match: "'"
|
||||
scope: punctuation.definition.string.begin
|
||||
push:
|
||||
- meta_include_prototype: false
|
||||
- meta_scope: string.quoted.single
|
||||
- match: "'"
|
||||
scope: punctuation.definition.string.end
|
||||
pop: true
|
||||
- match: \n
|
||||
scope: invalid.illegal.newline.asm
|
||||
pop: true
|
||||
|
||||
|
||||
eol:
|
||||
- match: '$'
|
||||
pop: true
|
||||
|
524
mac-gen.py
Normal file
524
mac-gen.py
Normal file
|
@ -0,0 +1,524 @@
|
|||
import sublime
|
||||
import sublime_plugin
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
def each_line(file):
|
||||
f = open(file, "r", encoding="ascii")
|
||||
try:
|
||||
while True:
|
||||
x = f.readline()
|
||||
if not x: break
|
||||
x = x.rstrip("\r\n")
|
||||
yield x
|
||||
except Exception as e:
|
||||
raise e
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
def macro_files(dirs, filter):
|
||||
|
||||
rv = []
|
||||
for root in dirs:
|
||||
try:
|
||||
tmp = [x for x in os.listdir(root) if filter(x)]
|
||||
tmp.sort(key=str.upper)
|
||||
tmp = [os.path.join(root, x) for x in tmp]
|
||||
tmp = [x for x in tmp if os.path.isfile(x)]
|
||||
|
||||
rv += tmp
|
||||
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
return rv
|
||||
|
||||
re_pmc = re.compile('^[^.,/\\- ]*')
|
||||
re_dot_s = re.compile('\\.S$', re.IGNORECASE)
|
||||
re_ws = re.compile('[\t ]+')
|
||||
re_comment = re.compile('^[\t ]*[;*]')
|
||||
|
||||
|
||||
class MerlinMacGen(sublime_plugin.TextCommand):
|
||||
|
||||
opcodes = {
|
||||
'BRL', 'COP', 'JML', 'JMPL', 'JSL', 'MVN', 'MVP', 'MX', 'PEA',
|
||||
'PEI', 'PER', 'REP', 'SEP', 'WDM', 'XCE', 'ADR', 'ADRL', 'ASC',
|
||||
'AST', 'BRK', 'CHK', 'CYC', 'DA', 'DAT', 'DB', 'DCI', 'DDB', 'DEND',
|
||||
'DFB', 'DL', 'DS', 'DSK', 'DUM', 'DW', 'END', 'ENT', 'EQU', 'ERR', 'EXP',
|
||||
'EXT', 'FLS', 'HEX', 'INV', 'KBD', 'LST', 'LSTL', 'LUP', 'OBJ',
|
||||
'ORG', 'PAG', 'PAU', 'PMC', 'PUT', 'REL', 'REV', 'SAV', 'SKP',
|
||||
'STR', 'TR', 'TTL', 'TYP', 'USE', 'USR', 'VAR', 'XC', 'XREF','=',
|
||||
'>>>', 'DO', 'ELS', 'EOM', 'FIN', 'IF', 'MAC', '--^', '<<<',
|
||||
'CLC', 'CLD', 'CLI', 'CLV', 'DEX', 'DEY', 'INX', 'INY', 'NOP',
|
||||
'PHA', 'PHB', 'PHD', 'PHK', 'PHX', 'PHY', 'PLA', 'PLB', 'PLD',
|
||||
'PLP', 'PLX', 'PLY', 'RTI', 'RTL', 'RTS', 'SEC', 'SED', 'SEI',
|
||||
'STP', 'SWA', 'TAD', 'TAS', 'TAX', 'TAY', 'TCD', 'TCS', 'TDA',
|
||||
'TDC', 'TSA', 'TSC', 'TSX', 'TXA', 'TXS', 'TXY', 'TYA', 'TYX',
|
||||
'WAI', 'XBA', 'BCC', 'BCS', 'BEQ', 'BGE', 'BLT', 'BMI', 'BNE',
|
||||
'BPL', 'BRA', 'BVC', 'BVS', 'ADCL', 'ANDL', 'CMPL', 'EORL',
|
||||
'LDAL', 'ORAL', 'SBCL', 'STAL', 'ADC', 'AND', 'ASL', 'BIT',
|
||||
'CMP', 'CPX', 'CPY', 'DEC', 'EOR', 'INC', 'JMP', 'JSR', 'LDA',
|
||||
'LDX', 'LDY', 'LSR', 'ORA', 'ROL', 'ROR', 'SBC', 'STA', 'STX',
|
||||
'STY', 'STZ', 'TRB', 'TSB', 'PHP', 'STRL', 'FLO', 'EXD', 'CAS',
|
||||
''
|
||||
}
|
||||
|
||||
def front_matter(self):
|
||||
buffer = ""
|
||||
name = self.view.file_name()
|
||||
if name:
|
||||
buffer += "* Generated from " + os.path.basename(name) + " on " + time.asctime() + "\n"
|
||||
else:
|
||||
buffer += "* Generated on " + time.asctime() + "\n"
|
||||
buffer += "\n"
|
||||
return buffer
|
||||
|
||||
def missing_matter(self, missing):
|
||||
buffer = ""
|
||||
if len(missing) == 0:
|
||||
return ""
|
||||
|
||||
buffer = "* Missing Macros\n"
|
||||
|
||||
missing = list(missing)
|
||||
missing.sort
|
||||
for macro in missing:
|
||||
buffer += "* " + macro + "\n"
|
||||
|
||||
buffer += "\n"
|
||||
return buffer
|
||||
|
||||
|
||||
def run(self, edit):
|
||||
|
||||
view = self.view
|
||||
|
||||
missing = set()
|
||||
known = set()
|
||||
self.build_missing(known, missing)
|
||||
|
||||
if len(missing) == 0: return
|
||||
|
||||
buffer = ""
|
||||
dirlist = view.settings().get('merlin_macro_directories', [])
|
||||
files = macro_files(dirlist, lambda x: x[-2:].upper() == ".S")
|
||||
print(files)
|
||||
|
||||
|
||||
for f in files:
|
||||
buffer += self.one_macro_file(f, known, missing)
|
||||
if len(missing) == 0: break;
|
||||
|
||||
|
||||
buffer = self.front_matter() + self.missing_matter(missing) + buffer
|
||||
|
||||
view = view.window().new_file()
|
||||
view.insert(edit, 0, buffer)
|
||||
|
||||
def build_missing(self, known, missing):
|
||||
|
||||
view = self.view
|
||||
all = sublime.Region(0, view.size())
|
||||
for r in view.lines(all):
|
||||
text = view.substr(r).rstrip()
|
||||
|
||||
if text == "" or re_comment.match(text):
|
||||
continue
|
||||
|
||||
tokens = re.split(re_ws, text, maxsplit=2)
|
||||
if len(tokens) < 2:
|
||||
continue
|
||||
|
||||
# _macro args
|
||||
# PMC _macro,args << . / , - ( Space are separtors.
|
||||
# >>> _macro
|
||||
|
||||
label = tokens[0].upper()
|
||||
opcode = tokens[1].upper()
|
||||
|
||||
if opcode == "" or opcode[0] == ";":
|
||||
continue
|
||||
|
||||
if opcode == 'MAC':
|
||||
# label MAC
|
||||
if label != "":
|
||||
known.add(label)
|
||||
continue
|
||||
|
||||
if opcode in {'PMC', '>>>'} and len(tokens) > 2:
|
||||
tmp = tokens[2].upper()
|
||||
opcode = re_pmc.match(tmp).group(0)
|
||||
if opcode == "":
|
||||
continue
|
||||
|
||||
|
||||
if opcode in self.opcodes:
|
||||
continue
|
||||
if opcode in known:
|
||||
continue
|
||||
missing.add(opcode)
|
||||
|
||||
|
||||
|
||||
|
||||
def one_macro_file(self, file, known, missing):
|
||||
inmac = False
|
||||
buffer = ""
|
||||
|
||||
for text in each_line(file):
|
||||
|
||||
text = text.rstrip()
|
||||
|
||||
if inmac:
|
||||
buffer += text + "\n"
|
||||
|
||||
if text == "": continue
|
||||
if re_comment.match(text): continue
|
||||
|
||||
tokens = re.split(re_ws, text, maxsplit=2)
|
||||
|
||||
if len(tokens) < 2: continue
|
||||
|
||||
label = tokens[0].upper()
|
||||
opcode = tokens[1].upper()
|
||||
|
||||
|
||||
if opcode == "" or opcode[0] == ";": continue
|
||||
|
||||
if opcode == "MAC" and label != "":
|
||||
# print(label,file=sys.stderr)
|
||||
# print(label in missing, file=sys.stderr)
|
||||
|
||||
if inmac:
|
||||
known.add(label)
|
||||
missing.discard(label)
|
||||
elif label in missing:
|
||||
inmac = True
|
||||
known.add(label)
|
||||
missing.discard(label)
|
||||
buffer += text + "\n"
|
||||
continue
|
||||
|
||||
if opcode in { '<<<', 'EOM' }:
|
||||
inmac = False
|
||||
continue
|
||||
|
||||
if not inmac: continue
|
||||
|
||||
if opcode in {'PMC', '>>>'} and len(tokens) > 2:
|
||||
tmp = tokens[2].upper()
|
||||
opcode = re_pmc.match(tmp).group(0)
|
||||
if opcode == "":
|
||||
continue
|
||||
|
||||
if opcode in self.opcodes: continue
|
||||
if opcode in known: continue
|
||||
missing.add(opcode)
|
||||
|
||||
return buffer
|
||||
|
||||
|
||||
class OrcaMacGen(sublime_plugin.TextCommand):
|
||||
|
||||
|
||||
opcodes = {
|
||||
'ADC', 'AND', 'CMP', 'EOR', 'LDA', 'ORA', 'SBC', 'ASL', 'LSR',
|
||||
'ROR', 'ROL', 'BIT', 'CPX', 'CPY', 'DEC', 'INC', 'LDX', 'LDY',
|
||||
'STA', 'STX', 'STY', 'JMP', 'JSR', 'STZ', 'TRB', 'TSB', 'JSL',
|
||||
'JML', 'COP', 'MVN', 'MVP', 'PEA', 'PEI', 'REP', 'SEP', 'PER',
|
||||
'BRL', 'BRA', 'BEQ', 'BMI', 'BNE', 'BPL', 'BVC', 'BVS', 'BCC',
|
||||
'BCS', 'CLI', 'CLV', 'DEX', 'DEY', 'INX', 'INY', 'NOP', 'PHA',
|
||||
'PLA', 'PHP', 'PLP', 'RTI', 'RTS', 'SEC', 'SED', 'SEI', 'TAX',
|
||||
'TAY', 'TSX', 'TXA', 'TXS', 'TYA', 'BRK', 'CLC', 'CLD', 'PHX',
|
||||
'PHY', 'PLX', 'PLY', 'DEA', 'INA', 'PHB', 'PHD', 'PHK', 'PLB',
|
||||
'PLD', 'WDM', 'RTL', 'STP', 'TCD', 'TCS', 'TDC', 'TSC', 'TXY',
|
||||
'TYX', 'WAI', 'XBA', 'XCE', 'CPA', 'BLT', 'BGE', 'GBLA', 'GBLB',
|
||||
'GBLC', 'LCLA', 'LCLB', 'LCLC', 'SETA', 'SETB', 'SETC', 'AMID',
|
||||
'ASEARCH', 'AINPUT', 'AIF', 'AGO', 'ACTR', 'MNOTE', 'ANOP', 'DS',
|
||||
'ORG', 'OBJ', 'EQU', 'GEQU', 'MERR', 'DIRECT', 'KIND', 'SETCOM',
|
||||
'EJECT', 'ERR', 'GEN', 'MSB', 'LIST', 'SYMBOL', 'PRINTER',
|
||||
'65C02', '65816', 'LONGA', 'LONGI', 'DATACHK', 'CODECHK',
|
||||
'DYNCHK', 'IEEE', 'NUMSEX', 'CASE', 'OBJCASE', 'ABSADDR',
|
||||
'INSTIME', 'TRACE', 'EXPAND', 'DC', 'USING', 'ENTRY', 'OBJEND',
|
||||
'DATA', 'PRIVDATA', 'END', 'ALIGN', 'START', 'PRIVATE', 'MEM',
|
||||
'TITLE', 'RENAME', 'KEEP', 'COPY', 'APPEND', 'MCOPY', 'MDROP',
|
||||
'MLOAD', 'MACRO', 'MEXIT', 'MEND'
|
||||
}
|
||||
|
||||
|
||||
def run(self, edit):
|
||||
|
||||
view = self.view
|
||||
|
||||
known = set()
|
||||
missing = set()
|
||||
self.build_missing(known, missing)
|
||||
|
||||
if len(missing) == 0: return
|
||||
|
||||
buffer = ""
|
||||
dirlist = view.settings().get('orca_macro_directories', [])
|
||||
files = macro_files(dirlist, lambda x: x[:4].upper() == "M16.")
|
||||
#print(files)
|
||||
for f in files:
|
||||
buffer += self.one_macro_file(f, known, missing)
|
||||
if len(missing) == 0: break;
|
||||
|
||||
buffer = self.front_matter() + self.missing_matter(missing) + buffer
|
||||
|
||||
view = view.window().new_file()
|
||||
view.insert(edit, 0, buffer)
|
||||
|
||||
|
||||
def build_missing(self, known, missing):
|
||||
|
||||
view = self.view
|
||||
all = sublime.Region(0, view.size())
|
||||
for r in view.lines(all):
|
||||
text = view.substr(r).rstrip()
|
||||
|
||||
if text == "": continue
|
||||
if text[0] in "!*": continue
|
||||
if re_comment.match(text): continue
|
||||
tokens = re.split(re_ws, text, maxsplit=2)
|
||||
if len(tokens) < 2: continue
|
||||
|
||||
label = tokens[0].upper()
|
||||
opcode = tokens[1].upper()
|
||||
|
||||
if opcode in self.opcodes: continue
|
||||
missing.add(opcode)
|
||||
|
||||
|
||||
def one_macro_file(self, file, known, missing):
|
||||
buffer = ""
|
||||
state = 0
|
||||
|
||||
for text in each_line(file):
|
||||
|
||||
if state == 2:
|
||||
buffer += text + "\n"
|
||||
|
||||
if text == "": continue
|
||||
if re_comment.match(text): continue
|
||||
|
||||
|
||||
tokens = re.split(re_ws, text, maxsplit=2)
|
||||
if len(tokens) < 2: continue
|
||||
|
||||
label = tokens[0].upper()
|
||||
opcode = tokens[1].upper()
|
||||
|
||||
|
||||
if state == 0:
|
||||
if opcode == 'MACRO': state = 1
|
||||
elif state == 1:
|
||||
if opcode in missing:
|
||||
known.add(opcode)
|
||||
missing.discard(opcode)
|
||||
buffer += "\tMACRO\n"
|
||||
buffer += text + "\n"
|
||||
state = 2
|
||||
else:
|
||||
state = 0
|
||||
|
||||
elif state == 2:
|
||||
if opcode == 'MEND': state = 0
|
||||
if opcode not in self.opcodes and opcode not in known:
|
||||
missing.add(opcode)
|
||||
|
||||
|
||||
return buffer
|
||||
|
||||
def front_matter(self):
|
||||
buffer = ""
|
||||
name = self.view.file_name()
|
||||
if name:
|
||||
buffer += "* Generated from " + os.path.basename(name) + " on " + time.asctime() + "\n"
|
||||
else:
|
||||
buffer += "* Generated on " + time.asctime() + "\n"
|
||||
buffer += "\n"
|
||||
return buffer
|
||||
|
||||
def missing_matter(self, missing):
|
||||
buffer = ""
|
||||
if len(missing) == 0:
|
||||
return ""
|
||||
|
||||
buffer = "* Missing Macros\n"
|
||||
|
||||
missing = list(missing)
|
||||
missing.sort
|
||||
for macro in missing:
|
||||
buffer += "* " + macro + "\n"
|
||||
|
||||
buffer += "\n"
|
||||
return buffer
|
||||
|
||||
|
||||
|
||||
class MpwMacGen(sublime_plugin.TextCommand):
|
||||
|
||||
|
||||
opcodes = {
|
||||
'ACTR', 'ADC', 'AERROR', 'ALIGN', 'AND', 'ANOP', 'ASL',
|
||||
'BBC0', 'BBC1', 'BBC2', 'BBC3', 'BBC4', 'BBC5', 'BBC6', 'BBC7',
|
||||
'BBR0', 'BBR1', 'BBR2', 'BBR3', 'BBR4', 'BBR5', 'BBR6', 'BBR7',
|
||||
'BBS0', 'BBS1', 'BBS2', 'BBS3', 'BBS4', 'BBS5', 'BBS6', 'BBS7',
|
||||
'BCC', 'BCS', 'BEQ', 'BGE', 'BIT', 'BLANKS', 'BLT', 'BMI', 'BNE',
|
||||
'BPL', 'BRA', 'BRK', 'BRL', 'BVC', 'BVS', 'CASE',
|
||||
'CLB0', 'CLB1', 'CLB2', 'CLB3', 'CLB4', 'CLB5', 'CLB6', 'CLB7',
|
||||
'CLC', 'CLD', 'CLI', 'CLT', 'CLV', 'CMP', 'CODECHK', 'COM', 'COP', 'CPA',
|
||||
'CPX', 'CPY', 'CYCLE', 'DATACHK', 'DC', 'DCB', 'DS', 'DEA', 'DEC', 'DEX', 'DEY',
|
||||
'DIRECT', 'DUMP', 'EJECT', 'ELSE', 'ELSEIF', 'END', 'ENDF', 'ENDFUNC',
|
||||
'ENDI', 'ENDIF', 'ENDINIT', 'ENDM', 'ENDMACRO', 'ENDP', 'ENDPROC',
|
||||
'ENDR', 'ENDS', 'ENDSTACK', 'ENDW', 'ENDWHILE', 'ENDWITH', 'ENTRY',
|
||||
'EOR', 'EQU', 'EXITM', 'EXPORT', 'FUNC', 'GBLA', 'GBLC', 'GOTO',
|
||||
'IF', 'IMPORT', 'INA', 'INC', 'INCLUDE', 'INIT', 'INX', 'INY', 'JML', 'JMP',
|
||||
'JSL', 'JSR', 'LCLA', 'LCLC', 'LDA', 'LDM', 'LDX', 'LDY', 'LEAVE',
|
||||
'LOAD', 'LONGA', 'LONGI', 'LSR', 'MACHINE', 'MACRO', 'MEND', 'MEXIT',
|
||||
'MSB', 'MVN', 'MVP', 'NOP', 'ORA', 'ORG', 'PAGESIZE', 'PEA', 'PEI',
|
||||
'PER', 'PHA', 'PHB', 'PHD', 'PHK', 'PHP', 'PHX', 'PHY', 'PLA', 'PLB',
|
||||
'PLD', 'PLP', 'PLX', 'PLY', 'PRINT', 'PROC', 'RECORD', 'REP', 'RMB0',
|
||||
'RMB1', 'RMB2', 'RMB3', 'RMB4', 'RMB5', 'RMB6', 'RMB7', 'ROL', 'ROR',
|
||||
'RRF', 'RTI', 'RTL', 'RTS', 'SBC', 'SEB0', 'SEB1', 'SEB2', 'SEB3',
|
||||
'SEB4', 'SEB5', 'SEB6', 'SEB7', 'SEC', 'SED', 'SEG', 'SEGATTR', 'SEI',
|
||||
'SEP', 'SET', 'SETA', 'SETC', 'SETT', 'SMB0', 'SMB1', 'SMB2', 'SMB3',
|
||||
'SMB4', 'SMB5', 'SMB6', 'SMB7', 'SPACE', 'STA', 'STACKDP', 'STP',
|
||||
'STRING', 'STX', 'STY', 'STZ', 'SWA', 'TAD', 'TAS', 'TAX', 'TAY', 'TCD',
|
||||
'TCS', 'TDA', 'TDC', 'TITLE', 'TRB', 'TSA', 'TSB', 'TSC', 'TST', 'TSX',
|
||||
'TXA', 'TXS', 'TXY', 'TYA', 'TYX', 'WAI', 'WHILE', 'WITH', 'WRITE',
|
||||
'WRITELN', 'XBA', 'XCE'
|
||||
}
|
||||
|
||||
|
||||
def run(self, edit):
|
||||
|
||||
view = self.view
|
||||
|
||||
known = set()
|
||||
missing = set()
|
||||
self.build_missing(known, missing)
|
||||
|
||||
if len(missing) == 0: return
|
||||
|
||||
buffer = ""
|
||||
dirlist = view.settings().get('mpw_macro_directories', [])
|
||||
files = macro_files(dirlist, lambda x: x[:4].upper() == "M16.")
|
||||
#print(files)
|
||||
for f in files:
|
||||
buffer += self.one_macro_file(f, known, missing)
|
||||
if len(missing) == 0: break;
|
||||
|
||||
buffer = self.front_matter() + self.missing_matter(missing) + buffer
|
||||
|
||||
view = view.window().new_file()
|
||||
view.insert(edit, 0, buffer)
|
||||
|
||||
|
||||
def build_missing(self, known, missing):
|
||||
|
||||
state = 0
|
||||
view = self.view
|
||||
all = sublime.Region(0, view.size())
|
||||
for r in view.lines(all):
|
||||
text = view.substr(r).rstrip()
|
||||
|
||||
if text == "": continue
|
||||
if re_comment.match(text): continue
|
||||
tokens = re.split(re_ws, text, maxsplit=2)
|
||||
if len(tokens) < 2: continue
|
||||
|
||||
label = tokens[0].upper()
|
||||
opcode = tokens[1].upper()
|
||||
ix = opcode.find('.')
|
||||
if ix >= 0: opcode = opcode[:ix]
|
||||
|
||||
if opcode == "MACRO":
|
||||
state = 1
|
||||
continue
|
||||
if opcode == "MEND":
|
||||
state = 0
|
||||
continue
|
||||
if state == 1:
|
||||
known.add(opcode)
|
||||
missing.discard(opcode)
|
||||
state = 0
|
||||
continue
|
||||
|
||||
|
||||
|
||||
if opcode in self.opcodes: continue
|
||||
if opcode in known: continue
|
||||
missing.add(opcode)
|
||||
|
||||
|
||||
def one_macro_file(self, file, known, missing):
|
||||
buffer = ""
|
||||
state = 0
|
||||
|
||||
for text in each_line(file):
|
||||
|
||||
if state == 2:
|
||||
buffer += text + "\n"
|
||||
|
||||
if text == "": continue
|
||||
if re_comment.match(text): continue
|
||||
|
||||
|
||||
tokens = re.split(re_ws, text, maxsplit=2)
|
||||
if len(tokens) < 2: continue
|
||||
|
||||
label = tokens[0].upper()
|
||||
opcode = tokens[1].upper()
|
||||
|
||||
|
||||
if state == 0:
|
||||
if opcode == 'MACRO': state = 1
|
||||
elif state == 1:
|
||||
if opcode in missing:
|
||||
known.add(opcode)
|
||||
missing.discard(opcode)
|
||||
buffer += "\tMACRO\n"
|
||||
buffer += text + "\n"
|
||||
state = 2
|
||||
else:
|
||||
state = 0
|
||||
|
||||
elif state == 2:
|
||||
if opcode == 'MEND': state = 0
|
||||
if opcode not in self.opcodes and opcode not in known:
|
||||
missing.add(opcode)
|
||||
|
||||
|
||||
return buffer
|
||||
|
||||
def front_matter(self):
|
||||
buffer = ""
|
||||
name = self.view.file_name()
|
||||
if name:
|
||||
buffer += "* Generated from " + os.path.basename(name) + " on " + time.asctime() + "\n"
|
||||
else:
|
||||
buffer += "* Generated on " + time.asctime() + "\n"
|
||||
buffer += "\n"
|
||||
return buffer
|
||||
|
||||
def missing_matter(self, missing):
|
||||
buffer = ""
|
||||
if len(missing) == 0:
|
||||
return ""
|
||||
|
||||
buffer = "* Missing Macros\n"
|
||||
|
||||
missing = list(missing)
|
||||
missing.sort
|
||||
for macro in missing:
|
||||
buffer += "* " + macro + "\n"
|
||||
|
||||
buffer += "\n"
|
||||
return buffer
|
86
merlin-fixs.py
Normal file
86
merlin-fixs.py
Normal file
|
@ -0,0 +1,86 @@
|
|||
import sublime
|
||||
import sublime_plugin
|
||||
|
||||
SPACE = [" ", "\t"]
|
||||
QUOTES = ["'", '"']
|
||||
|
||||
|
||||
#
|
||||
# need to do something clever for ; comments to put in comment field?
|
||||
#
|
||||
def fixs(s):
|
||||
|
||||
f = 0
|
||||
q = None
|
||||
sp = False
|
||||
comment = False
|
||||
|
||||
rv = ''
|
||||
if not len(s): return s
|
||||
if s[0] == "*": comment = True
|
||||
if s[0] == ";": comment = True ; rv = "\t\t\t"
|
||||
for c in s:
|
||||
|
||||
if comment:
|
||||
if c == "\t": c = " "
|
||||
rv += c
|
||||
continue
|
||||
|
||||
if q:
|
||||
rv += c
|
||||
if c == q: q = None
|
||||
continue
|
||||
|
||||
if c in QUOTES:
|
||||
rv += c
|
||||
q = c
|
||||
sp = False
|
||||
continue
|
||||
|
||||
if c in SPACE:
|
||||
if sp: continue
|
||||
f += 1
|
||||
c = "\t"
|
||||
sp = True
|
||||
rv += c
|
||||
continue
|
||||
|
||||
if sp:
|
||||
if c == ';':
|
||||
comment = True
|
||||
rv += "\t" * (3-f)
|
||||
elif f == 3:
|
||||
comment = True
|
||||
rv += "; "
|
||||
sp = False
|
||||
rv += c
|
||||
|
||||
return rv;
|
||||
|
||||
|
||||
class MerlinFixs(sublime_plugin.TextCommand):
|
||||
|
||||
def is_enabled(self):
|
||||
scope = self.view.scope_name(0)
|
||||
lang = scope.split(' ')[0]
|
||||
return lang == 'source.asm.65816.merlin' or lang == "source.linker.merlin"
|
||||
|
||||
|
||||
def run(self, edit):
|
||||
view = self.view
|
||||
all = sublime.Region(0, view.size())
|
||||
|
||||
# disable space indentation.
|
||||
view.settings().set('translate_tabs_to_spaces', False)
|
||||
|
||||
data = []
|
||||
for r in view.lines(all):
|
||||
text = view.substr(r).rstrip()
|
||||
|
||||
data.append(fixs(text))
|
||||
|
||||
|
||||
data.append('')
|
||||
text = '\n'.join(data)
|
||||
|
||||
view.replace(edit, all, text)
|
34
sc-asm directives.sublimes-completions
Normal file
34
sc-asm directives.sublimes-completions
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"scope": "source.asm.sc-asm meta.directive",
|
||||
"completions":
|
||||
[
|
||||
".ac",
|
||||
".as",
|
||||
".at",
|
||||
".az",
|
||||
".bs",
|
||||
".da",
|
||||
".do",
|
||||
".dummy",
|
||||
".ed",
|
||||
".else",
|
||||
".em",
|
||||
".en",
|
||||
".ep",
|
||||
".eq",
|
||||
".fin",
|
||||
".hs",
|
||||
".in",
|
||||
".inb",
|
||||
".list",
|
||||
".ma",
|
||||
".op",
|
||||
".or",
|
||||
".pg",
|
||||
".ph",
|
||||
".ta",
|
||||
".tf",
|
||||
".ti",
|
||||
".us"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user