clean up mpw asm

This commit is contained in:
Kelvin Sherlock 2017-09-17 15:19:33 -04:00
parent 28379552af
commit 4cf6a12954

View File

@ -9,24 +9,33 @@ variables:
ident: '[A-Za-z@_~][A-Za-z0-9@_~%$#]*' ident: '[A-Za-z@_~][A-Za-z0-9@_~%$#]*'
contexts: contexts:
prototype:
- include: eol
- include: comment
main: main:
- include: label - meta_include_prototype: false
label:
- match: '{{ws}}' - match: '{{ws}}'
push: opcode push: opcode
- match: '^({{ident}}){{ws}}((?i)PROC|PROCNAME|FUNC|INIT|STACKDP)\b' - match: '^({{ident}}){{ws}}((?i)PROC|PROCNAME|FUNC|INIT)\b'
captures: captures:
1: entity.name.function 1: entity.name.function
2: keyword.directive 2: keyword.directive
push: operand push: operand-proc
- match: '^({{ident}}){{ws}}((?i)STACKDP)\b'
captures:
1: entity.name.function
2: keyword.directive
push: operand-stackdp
- match: '^({{ident}}){{ws}}((?i)RECORD)\b' - match: '^({{ident}}){{ws}}((?i)RECORD)\b'
captures: captures:
1: entity.name.record 1: entity.name.record
2: keyword.directive 2: keyword.directive
push: operand push: operand-record
@ -37,7 +46,7 @@ contexts:
scope: variable.other scope: variable.other
- match: ^[*]|; - match: ^[;*]
push: push:
- meta_scope: comment.line - meta_scope: comment.line
- match: \n - match: \n
@ -46,11 +55,10 @@ contexts:
opcode: opcode:
- match: '{{ws}}' - match: '{{ws}}'
set: operand set: operand
- include: comment - include: scope:source.asm.65816#mnemonics-6502
- include: mnemonics-6502 - include: scope:source.asm.65816#mnemonics-65c02
- include: mnemonics-65c02 - include: scope:source.asm.65816#mnemonics-65816
- include: mnemonics-65816 - include: scope:source.asm.65816#mnemonics-65816-long
- include: mnemonics-65816-long
- include: mnemonics-65816-alt - include: mnemonics-65816-alt
# toolbox macros # toolbox macros
@ -66,41 +74,68 @@ contexts:
- match: \b((?i)CODECHK|DATACHK|LONGA|LONGI|MSB)\b - match: \b((?i)CODECHK|DATACHK|LONGA|LONGI|MSB)\b
scope: keyword.directive scope: keyword.directive
set: operand_on_off set: operand-on-off
- match: \b((?i)STRING)\b - match: \b((?i)STRING)\b
scope: keyword.directive.data scope: keyword.directive.data
set: operand_string set: operand-string
- match: \b(?i:ENTRY)\b - match: \b(?i:ENTRY)\b
scope: keyword.directive scope: keyword.directive
set: operand_entry set: operand-entry
- match: \b(?i:EXPORT|IMPORT)\b
scope: keyword.directive
set: operand-export
- match: \b(?i:MACHINE)\b - match: \b(?i:MACHINE)\b
scope: keyword.directive scope: keyword.directive
set: operand_machine set: operand-machine
- match: \b(?i:BLANKS)\b - match: \b(?i:BLANKS)\b
scope: keyword.directive scope: keyword.directive
set: operand_blanks set: operand-blanks
- match: \b(?i:CASE)\b - match: \b(?i:CASE)\b
scope: keyword.directive scope: keyword.directive
set: operand_case set: operand-case
- match: \b(?i:PRINT)\b - match: \b(?i:PRINT)\b
scope: keyword.directive scope: keyword.directive
set: operand_print set: operand-print
- match: \b(?i:IMPORT|INCLUDE)\b - match: \b(?i:PROC|PROCNAME|INIT|FUNC)\b
scope: keyword.directive
set: operand-proc
- match: \b(?i:RECORD)\b
scope: keyword.directive
set: operand-record
- match: \b(?i:STACKDP)\b
scope: keyword.directive
set: operand-stackdp
- match: \b(?i:SEGATTR)\b
scope: keyword.directive
set: operand-segattr
- match: \b(?i:SEG|TITLE)\b
scope: keyword.directive
set: operand-string-expr
- match: \b(?i:LOAD|DUMP|INCLUDE)\b
scope: keyword.control.import scope: keyword.control.import
set: operand-string-expr
- match: \b(?i:ALIGN|BLANKS|CASE|CODE|CODECHK|DATACHK|DIRECT|DUMP|EJECT|END|ENDF|ENDFUNC|ENDI|ENDP|ENDPROC|END_PROC|ENDR|ENDSTACK|ENDS|ENDWITH|ENTRY|EQU|EXPORT|FUNC|IMPORT|INCLUDE|INIT|LOAD|LONGA|LONGI|MACHINE|MSB|ORG|PAGESIZE|PRINT|PROC|RECORD|SEG|SEGATTR|SET|SPACE|STACKDP|STRING|TITLE|WITH)\b - match: \b(?i:ALIGN|BLANKS|CASE|CODE|CODECHK|DATACHK|DIRECT|DUMP|EJECT|END|ENDF|ENDFUNC|ENDI|ENDP|ENDPROC|END_PROC|ENDR|ENDSTACK|ENDS|ENDWITH|ENTRY|EQU|EXPORT|FUNC|IMPORT|INCLUDE|INIT|LOAD|LONGA|LONGI|MACHINE|MSB|ORG|PAGESIZE|PRINT|PROC|RECORD|SEG|SEGATTR|SET|SPACE|STACKDP|STRING|TITLE|WITH)\b
scope: keyword.directive scope: keyword.directive
- match: \b(?i:IF|ELSEIF)\b - match: \b(?i:IF|ELSEIF)\b
scope: keyword.control.conditional scope: keyword.control.conditional
set: operand_if set: operand-if
- match: \b(?i:CYCLE|LEAVE|ELSE|ENDIF|ENDWHILE|THEN|WHILE)\b - match: \b(?i:CYCLE|LEAVE|ELSE|ENDIF|ENDWHILE|THEN|WHILE)\b
scope: keyword.control.conditional scope: keyword.control.conditional
@ -119,80 +154,107 @@ contexts:
- match: '&{{ident}}\b' - match: '&{{ident}}\b'
scope: variable.other scope: variable.other
operand_on_off: operand-on-off:
- include: comment
- include: macro-parm - include: macro-parm
- match: \b(?i:ON|OFF)\b - match: \b(?i:ON|OFF)\b
scope: constant.language scope: constant.language
- match: \S set: expect-comment
scope: invalid.illegal.operand - include: expect-comment
operand_string: operand-string:
- include: comment
- include: macro-parm - include: macro-parm
- match: \b(?i:ASIS|PASCAL|C|GS/OS)\b - match: \b(?i:ASIS|PASCAL|C|GS/OS)\b
scope: constant.language scope: constant.language
- match: \S set: expect-comment
scope: invalid.illegal.operand - include: expect-comment
operand_machine: operand-proc:
- include: comment - match: \b(?i:ENTRY|EXPORT|ALIGN|ORG|NOSKIP|SKIP|TEMPORG)\b
scope: constant.language
- include: operand
operand-record:
- include: operand-proc
- match: \b(?i:IMPORT|INCR|INCREMENT|DECR|DECREMENT)\b
scope: constant.language
operand-segattr:
- match: \b(?i:NORELOAD|RELOAD|NOBANK|BANK|NOSPECIAL|SPECIAL|STATIC|DYNAMIC)\b
scope: constant.language
- include: operand
operand-stackdp:
- match: \b(?i:ENTRY|EXPORT)\b
scope: constant.language
set: expect-comment
- include: expect-comment
operand-machine:
- include: macro-parm - include: macro-parm
- match: \b(?i:M65816|M6502|M65C02|M65CX02|M740)\b - match: \b(?i:M65816|M6502|M65C02|M65CX02|M740)\b
scope: constant.language scope: constant.language
- match: \S set: expect-comment
scope: invalid.illegal.operand - include: expect-comment
operand_case: operand-case:
- include: comment
- include: macro-parm - include: macro-parm
- match: \b(?i:ON|OFF|YES|NO|Y|N|OBJECT|OBJ)\b - match: \b(?i:ON|OFF|YES|NO|Y|N|OBJECT|OBJ)\b
scope: constant.language scope: constant.language
- match: \S set: expect-comment
scope: invalid.illegal.operand - include: expect-comment
operand_blanks:
- include: comment operand-blanks:
- include: macro-parm - include: macro-parm
- match: \b(?i:ON|OFF|YES|NO|Y|N)\b - match: \b(?i:ON|OFF|YES|NO|Y|N)\b
scope: constant.language scope: constant.language
- match: \S set: expect-comment
scope: invalid.illegal.operand - include: expect-comment
operand_print:
- include: comment operand-print:
- include: macro-parm - include: macro-parm
- match: \b(?i:ON|OFF|PUSH|POP)\b - match: \b(?i:ON|OFF|PUSH|POP)\b
scope: constant.language scope: constant.language
set: expect-comment
- match: \b(?i:NO)?(?i:GEN|PAGE|WARN|MCALL|OBJ|DATA|MDIR|HDR|LITS|STAT|SYM)\b - match: \b(?i:NO)?(?i:GEN|PAGE|WARN|MCALL|OBJ|DATA|MDIR|HDR|LITS|STAT|SYM)\b
scope: constant.language scope: constant.language
- match: \S set: expect-comment
scope: invalid.illegal.operand - include: expect-comment
operand_entry:
- include: comment operand-entry:
- match: \b(?i:CODE|DATA)\b
scope: constant.language
- match: '\b{{ident}}\b' - match: '\b{{ident}}\b'
scope: entity.name.function scope: entity.name.function
operand-export:
- match: \b(?i:CODE|DATA|EQU)\b
scope: constant.language
- match: '\b{{ident}}\b'
scope: entity.name.function
operand_if: operand-if:
- match: \b(?i:THEN)\b - match: \b(?i:THEN)\b
scope: keyword.control.conditional scope: keyword.control.conditional
- include: operand - include: operand
operand-string-expr:
- include: macro-parm
- include: strings
- include: expect-comment
operand: operand:
- include: comment
- include: macro-parm - include: macro-parm
- include: numbers - include: numbers
- include: strings - include: strings
- include: macro-functions - include: macro-functions
# - match: \b(?i:ON|OFF|PUSH|POP)\b
# scope: constant.language
# - match: \b(?i:NO)?(?i:GEN|PAGE|WARN|MCALL|OBJ|DATA|MDIR|HDR|LITS|STAT|SYM)\b
# scope: constant.language
- match: \b(?i:NOT|DIV|MOD|AND|OR|XOR|EOR)\b - match: \b(?i:NOT|DIV|MOD|AND|OR|XOR|EOR)\b
scope: keyword.operator scope: keyword.operator
@ -217,65 +279,52 @@ contexts:
- match: "'" - match: "'"
scope: punctuation.definition.string.begin scope: punctuation.definition.string.begin
push: push:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- match: "'" - match: "'"
scope: punctuation.definition.string.end scope: punctuation.definition.string.end
pop: true pop: true
- match: \n - match: \n
scope: invalid.illegal.newline.asm scope: invalid.illegal.newline.asm
pop: true pop: true
- match: .
scope: string.quoted.single
- match: '"' - match: '"'
scope: punctuation.definition.string.begin scope: punctuation.definition.string.begin
push: push:
- meta_include_prototype: false
- match: '"' - match: '"'
scope: punctuation.definition.string.end scope: punctuation.definition.string.end
pop: true pop: true
- meta_scope: string.quoted.double
pop: true
- match: \n - match: \n
scope: invalid.illegal.newline.asm scope: invalid.illegal.newline.asm
pop: true pop: true
- match: .
scope: string.quoted.double
expect-comment:
- include: comment
- match: \S
scope: invalid.illegal.expect.comment
comment: comment:
- match: ;[^\n]* - match: ;
scope: comment.line.partial push:
- meta_scope: comment.line
- match: \n - match: \n
pop: true pop: true
- include: eol
eol: eol:
- match: \n - match: '$'
pop: true pop: true
mnemonics-6502:
- match: \b(?i: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)\b
scope: keyword.mnemonic.6502
mnemonics-65c02:
- match: \b(?i:BRA|PHX|PHY|PLX|PLY|STP|STZ|TRB|TSB|WAI)\b
scope: keyword.mnemonic.65c02
mnemonics-65816:
- match: \b(?i:BRL|COP|JML|JSL|MVN|MVP|PEA|PEI|PER|PHB|PHD|PHK|PLB|PLD|REP|RTL|SEP|TCD|TCS|TDC|TSC|TXY|TYX|WDM|XBA|XCE)\b
scope: keyword.mnemonic.65816
mnemonics-65816-long:
- match: \b(?i:ADCL|ANDL|CMPL|EORL|LDAL|ORAL|SBCL|STAL)\b
scope: keyword.mnemonic.65816.long
mnemonics-65816-alt: mnemonics-65816-alt:
- match: \b(?i:BLT|BGE|CPA|DEA|INA|SWA|TAS|TSA)\b - match: \b(?i:BLT|BGE|CPA|DEA|INA|SWA|TAS|TSA)\b
scope: keyword.mnemonic.65816.alt scope: keyword.mnemonic.65816.alt
mnemonics-65c02-rockwell:
- match: \b((?i:BBC|BBR|BBS|CLB|RMB|SEB|SMB)[0-7])\b
scope: keyword.mnemonic.rockwell
mnemonics-65c02-m740:
- match: \b(?i:CLT|COM|LDM|RRF|SET|TST)\b
scope: keyword.mnemonic.m740