65816.tmbundle/Syntaxes/Merlin.sublime-syntax

308 lines
6.5 KiB
Plaintext
Raw Normal View History

2017-08-13 23:42:53 +00:00
%YAML 1.2
---
name: Merlin Assembler
file_extensions: [S]
scope: source.asm.65816.merlin
variables:
ws: '[ \t]+'
ident: '[:-~][0-~]*'
contexts:
2017-09-17 02:36:09 +00:00
prototype:
- include: comment
- include: eol
2017-08-13 23:42:53 +00:00
main:
2017-09-17 02:36:09 +00:00
- meta_include_prototype: false
- match: ^[;*]
push:
- meta_scope: comment.line
- match: \n
pop: true
2017-08-13 23:42:53 +00:00
- 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
opcode:
- match: '{{ws}}'
set: operand
- include: comment
2017-09-17 02:36:09 +00:00
- include: scope:source.asm.65816#mnemonics-6502
- include: scope:source.asm.65816#mnemonics-65c02
- include: scope:source.asm.65816#mnemonics-65816
- include: scope:source.asm.65816#mnemonics-65816-long
2017-08-13 23:42:53 +00:00
- include: mnemonics-65816-alt
2017-08-15 14:18:46 +00:00
# toolbox macros
- match: \b_[A-Za-z0-9]+\b
scope: support.function.macro.toolbox
- match: \~[A-Za-z0-9]+\b
scope: support.function.smart-macro.toolbox
2017-08-15 14:18:46 +00:00
2017-08-13 23:42:53 +00:00
2019-12-05 01:28:12 +00:00
- match: \b(?i:DFB|DB|DDB|DA|DW|ADR|ADRL|DL|DS)\b
2017-08-13 23:42:53 +00:00
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
2019-12-08 17:26:52 +00:00
- 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
2017-08-13 23:42:53 +00:00
scope: keyword.directive
2018-09-10 03:56:48 +00:00
# IF MX..
# IF char=]\d
- match: \b(?i:IF)\b
scope: keyword.control.conditional
set: if-operand
2017-08-13 23:42:53 +00:00
- 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
2019-12-05 01:28:31 +00:00
- match: \b(?i:MX)\b
scope: keyword.directive
2017-08-13 23:42:53 +00:00
- 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: numbers
2017-08-15 14:18:46 +00:00
- include: strings
2018-09-10 03:56:48 +00:00
- match: ']\d+'
scope: variable.other
2017-08-21 19:39:06 +00:00
#- include: macro-parm
2017-08-13 23:42:53 +00:00
2018-09-10 03:56:48 +00:00
if-operand:
- match: \b(?i:MX)\b
scope: constant.language
- match: '(.)[,=](]\d+)'
captures:
1: string.unquoted
2: variable.other
- include: numbers
2017-08-13 23:42:53 +00:00
operand-hex:
- match: '[0-9A-Fa-f]{2}'
scope: constant.numeric.hex
2017-09-17 19:32:25 +00:00
- match: ','
- include: expect-comment
2017-08-13 23:42:53 +00:00
operand-path:
2017-09-17 02:36:09 +00:00
- match: \S+
2017-08-13 23:42:53 +00:00
scope: string.unquoted
2017-09-17 02:36:09 +00:00
set: expect-comment
- include: expect-comment
2017-08-13 23:42:53 +00:00
operand-string:
- include: strings
- match: '[0-9A-Fa-f]{2}'
scope: constant.numeric.hex
2017-09-17 19:32:25 +00:00
- match: ','
2018-09-10 03:56:48 +00:00
- match: ']\d+'
scope: variable.other
2017-09-17 19:32:25 +00:00
- include: expect-comment
2017-08-13 23:42:53 +00:00
operand-off:
- match: \b(?i:OFF)\b
scope: constant.language
2017-09-17 02:36:09 +00:00
set: expect-comment
- include: expect-comment
2017-08-13 23:42:53 +00:00
operand-cas:
# cas se / cas in
- match: \b(?i:SE|IN)\b
scope: constant.language
2017-09-17 02:36:09 +00:00
set: expect-comment
- include: expect-comment
2017-08-13 23:42:53 +00:00
operand-cyc:
# cyc off | ave | flags
- match: \b(?i:OFF|AVE|FLAGS)\b
scope: constant.language
2017-09-17 02:36:09 +00:00
set: expect-comment
- include: expect-comment
2017-08-13 23:42:53 +00:00
operand-exp:
# exp on | off | only
- match: \b(?i:ON|OFF|ONLY)\b
scope: constant.language
2017-09-17 02:36:09 +00:00
set: expect-comment
- include: expect-comment
2017-08-13 23:42:53 +00:00
operand-lst:
# lst | lst ON | OFF | RTN | FILE,path...
- match: \b(?i:ON|OFF|RTN)\b
scope: constant.language
2017-09-17 02:36:09 +00:00
set: expect-comment
2017-08-13 23:42:53 +00:00
- match: \b(?i:FILE){{ws}}*,
scope: constant.language
set: operand-path
2017-09-17 02:36:09 +00:00
- include: expect-comment
2017-08-13 23:42:53 +00:00
operand-tr:
# tr on | off | adr
- match: \b(?i:ON|OFF|ADR)\b
scope: constant.language
2017-09-17 02:36:09 +00:00
set: expect-comment
- include: expect-comment
expect-comment:
- include: comment
2017-08-13 23:42:53 +00:00
- match: \S
2017-09-17 02:36:09 +00:00
scope: invalid.illegal.expect.comment
2017-08-13 23:42:53 +00:00
comment:
2018-09-10 03:56:48 +00:00
- match: (?<=[\t ]);
2017-09-17 02:36:09 +00:00
push:
- meta_scope: comment.line
- match: \n
pop: true
- include: eol
2017-08-13 23:42:53 +00:00
mnemonics-65816-alt:
- match: \b(?i:TAS|TSA|SWA|TAD|TDA|BLT|BGE)\b
scope: keyword.mnemonic.65816.alt
numbers:
2018-09-08 20:11:17 +00:00
- match: \b\d+\b
2017-08-13 23:42:53 +00:00
scope: constant.numeric
2018-09-08 20:11:17 +00:00
- match: \$[0-9a-fA-F]+\b
2017-08-13 23:42:53 +00:00
scope: constant.numeric.hex
2018-09-08 20:11:17 +00:00
- match: \%[01_]+\b
2017-08-13 23:42:53 +00:00
scope: constant.numeric.binary
strings:
2018-09-08 20:11:17 +00:00
# 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
2017-08-13 23:42:53 +00:00
- match: "'"
scope: punctuation.definition.string.begin
push:
2017-09-17 02:36:09 +00:00
- meta_include_prototype: false
- meta_scope: string.quoted.single
2017-08-13 23:42:53 +00:00
- match: "'"
scope: punctuation.definition.string.end
pop: true
- match: \n
scope: invalid.illegal.newline.asm
pop: true
- match: '"'
scope: punctuation.definition.string.begin
push:
2017-09-17 02:36:09 +00:00
- meta_include_prototype: false
- meta_scope: string.quoted.double
2017-08-13 23:42:53 +00:00
- match: '"'
scope: punctuation.definition.string.end
pop: true
- match: \n
scope: invalid.illegal.newline.asm
pop: true
2017-09-17 02:36:09 +00:00
eol:
- match: '$'
pop: true
2017-08-13 23:42:53 +00:00