65816.tmbundle/Syntaxes/Merlin.sublime-syntax
Kelvin Sherlock 93ff3a31b6 updates.
2017-08-21 15:39:06 -04:00

277 lines
6.2 KiB
YAML

%YAML 1.2
---
name: Merlin Assembler
file_extensions: [S]
scope: source.asm.65816.merlin
variables:
ws: '[ \t]+'
ident: '[:-~][0-~]*'
contexts:
main:
- include: label
label:
- match: '{{ws}}'
push: opcode
- match: '^({{ident}}){{ws}}((?i)MAC)\b'
captures:
1: entity.name.macro
2: keyword.directive
push: operand
- match: '^({{ident}}){{ws}}((?i)ENT)\b'
captures:
1: entity.name.function
2: keyword.directive
push: operand
- match: '^({{ident}}){{ws}}((?i)EQU)\b'
captures:
1: entity.name.constant
2: keyword.directive
push: operand
- match: '^({{ident}}){{ws}}(=)'
captures:
1: entity.name.constant
2: keyword.directive
push: operand
- match: '^{{ident}}'
scope: entity.name.label
- match: ^[*]|;
push:
- meta_scope: comment.line
- match: \n
pop: true
opcode:
- match: '{{ws}}'
set: operand
- include: comment
- include: mnemonics-6502
- include: mnemonics-65c02
- include: mnemonics-65816
- include: mnemonics-65816-long
- include: mnemonics-65816-alt
# toolbox macros
- match: \b_[A-Za-z0-9]+\b
scope: support.function.macro.toolbox
- match: ~[A-Za-z0-9]+\b
scope: support.function.macro.toolbox
- match: \b(?i:DFB|DB|DDB|DA|DW|ADR|ADRL|DS)\b
scope: keyword.directive.data
- match: \b(?i:HEX)\b
scope: keyword.directive.data
set: operand-hex
- match: \b(?i:ASC|DCI|INV|FLS|REV|STR|STRL|FLO)\b
scope: keyword.directive.data
set: operand-string
- match: \b(?i:LUP)\b
scope: keyword.control.conditional
- 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
scope: keyword.directive
- match: \b(?i:DO|ELSE|IF|FIN)\b
scope: keyword.control.conditional
- match: \b(?i:USE|PUT|PUTBIN)\b
scope: keyword.control.import
set: operand-path
- match: \b(?i:DSK|SAV|LNK)\b
scope: keyword.control.export
set: operand-path
- match: \b(?i:XC)\b
scope: keyword.directive
set: operand-off
- match: \b(?i:CAS)\b
scope: keyword.directive
set: operand-cas
- match: \b(?i:CYC)\b
scope: keyword.directive
set: operand-cyc
- match: \b(?i:EXP)\b
scope: keyword.directive
set: operand-exp
- match: \b(?i:LST)\b
scope: keyword.directive
set: operand-lst
- match: \b(?i:LSTDO)\b
scope: keyword.directive
set: operand-off
- match: \b(?i:TTL)\b
scope: keyword.directive
set: operand-string
- match: \b(?i:TR)\b
scope: keyword.directive
set: operand-tr
operand:
- include: comment
- include: numbers
- include: strings
#- include: macro-parm
operand-hex:
- include: comment
- match: '[0-9A-Fa-f]{2}'
scope: constant.numeric.hex
- match: '[^ \t,]'
scope: invalid.illegal.operand
operand-path:
- include: comment
- match: \S
scope: string.unquoted
operand-string:
- include: comment
- include: strings
- match: '[0-9A-Fa-f]{2}'
scope: constant.numeric.hex
- match: '[^ \t,]'
scope: invalid.illegal.operand
operand-off:
- include: comment
- match: \b(?i:OFF)\b
scope: constant.language
- match: \S
scope: invalid.illegal.operand
operand-cas:
# cas se / cas in
- include: comment
- match: \b(?i:SE|IN)\b
scope: constant.language
- match: \S
scope: invalid.illegal.operand
operand-cyc:
# cyc off | ave | flags
- include: comment
- match: \b(?i:OFF|AVE|FLAGS)\b
scope: constant.language
- match: \S
scope: invalid.illegal.operand
operand-exp:
# exp on | off | only
- include: comment
- match: \b(?i:ON|OFF|ONLY)\b
scope: constant.language
- match: \S
scope: invalid.illegal.operand
operand-lst:
# lst | lst ON | OFF | RTN | FILE,path...
- include: comment
- match: \b(?i:ON|OFF|RTN)\b
scope: constant.language
- match: \b(?i:FILE){{ws}}*,
scope: constant.language
set: operand-path
- match: \S
scope: invalid.illegal.operand
operand-tr:
# tr on | off | adr
- include: comment
- match: \b(?i:ON|OFF|ADR)\b
scope: constant.language
- match: \S
scope: invalid.illegal.operand
comment:
- match: ;[^\n]*
scope: comment.line.partial
- match: \n
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:
- match: \b(?i:TAS|TSA|SWA|TAD|TDA|BLT|BGE)\b
scope: keyword.mnemonic.65816.alt
numbers:
- match: \d+
scope: constant.numeric
- match: \$[0-9a-fA-F]+
scope: constant.numeric.hex
- match: \%[01_]+
scope: constant.numeric.binary
strings:
- match: "'"
scope: punctuation.definition.string.begin
push:
- match: "'"
scope: punctuation.definition.string.end
pop: true
- match: \n
scope: invalid.illegal.newline.asm
pop: true
- match: .
scope: string.quoted.single
- match: '"'
scope: punctuation.definition.string.begin
push:
- match: '"'
scope: punctuation.definition.string.end
pop: true
- match: \n
scope: invalid.illegal.newline.asm
pop: true
- match: .
scope: string.quoted.double