65816.tmbundle/Syntaxes/MPW Asm IIgs.sublime-syntax
2020-07-14 22:27:34 -04:00

336 lines
7.9 KiB
YAML

%YAML 1.2
---
name: MPW Asm IIgs
file_extensions: [aii]
scope: source.asm.65816.mpw
variables:
ws: '[ \t]+'
ident: '[A-Za-z@_~][A-Za-z0-9@_~%$#]*'
contexts:
prototype:
- include: eol
- include: comment
main:
- meta_include_prototype: false
- match: '{{ws}}'
push: opcode
- match: '^({{ident}}){{ws}}((?i)PROC|PROCNAME|FUNC|INIT)\b'
captures:
1: entity.name.function
2: meta.opcode keyword.directive
push: operand-proc
- match: '^({{ident}}){{ws}}((?i)STACKDP)\b'
captures:
1: entity.name.function
2: meta.operand keyword.directive
push: operand-stackdp
- match: '^({{ident}}){{ws}}((?i)RECORD)\b'
captures:
1: entity.name.record
2: meta.operand keyword.directive
push: operand-record
- match: '^{{ident}}'
scope: entity.name.label
- match: '^&{{ident}}'
scope: variable.other
- match: ^[;*]
push:
- meta_scope: comment.line
- match: \n
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
- include: scope:source.asm.65816#mnemonics-65816-long
- 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)([.](.))?
scope: meta.dc.directive
captures:
1: keyword.directive.data
2: storage.type
- match: \b((?i)CODECHK|DATACHK|LONGA|LONGI|MSB)\b
scope: keyword.directive
set: operand-on-off
- match: \b((?i)STRING)\b
scope: keyword.directive.data
set: operand-string
- match: \b(?i:ENTRY)\b
scope: keyword.directive
set: operand-entry
- match: \b(?i:EXPORT|IMPORT)\b
scope: keyword.directive
set: operand-export
- match: \b(?i:MACHINE)\b
scope: keyword.directive
set: operand-machine
- match: \b(?i:BLANKS)\b
scope: keyword.directive
set: operand-blanks
- match: \b(?i:CASE)\b
scope: keyword.directive
set: operand-case
- match: \b(?i:PRINT)\b
scope: keyword.directive
set: operand-print
- 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
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
scope: keyword.directive
- match: \b(?i:IF|ELSEIF)\b
scope: keyword.control.conditional
set: operand-if
- match: \b(?i:CYCLE|LEAVE|ELSE|ENDIF|ENDWHILE|THEN|WHILE)\b
scope: keyword.control.conditional
- match: \b(?i:ACTR|AERROR|ANOP|CYCLE|ELSE|ELSEIF|ENDIF|ENDM|ENDMACRO|ENDWHILE|EXITM|GOTO|IF|LEAVE|MACRO|MEND|MEXIT|THEN|WHILE|WRITE|WRITELN|SET|SETA|SETC)\b
scope: support.function.macro
- include: macro-functions
# - match: '{{ident}}' # macro?
# scope: keyword.macro
macro-parm:
- match: '&{{ident}}\b'
scope: variable.other
operand-on-off:
- include: macro-parm
- match: \b(?i:ON|OFF)\b
scope: constant.language
set: expect-comment
- include: expect-comment
operand-string:
- include: macro-parm
- match: \b(?i:ASIS|PASCAL|C|GS/OS)\b
scope: constant.language
set: expect-comment
- include: expect-comment
operand-proc:
- 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
- match: \b(?i:M65816|M6502|M65C02|M65CX02|M740)\b
scope: constant.language
set: expect-comment
- include: expect-comment
operand-case:
- include: macro-parm
- match: \b(?i:ON|OFF|YES|NO|Y|N|OBJECT|OBJ)\b
scope: constant.language
set: expect-comment
- include: expect-comment
operand-blanks:
- include: macro-parm
- match: \b(?i:ON|OFF|YES|NO|Y|N)\b
scope: constant.language
set: expect-comment
- include: expect-comment
operand-print:
- include: macro-parm
- match: ','
- 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
- include: expect-comment
operand-entry:
- match: \b(?i:CODE|DATA)\b
scope: constant.language
- match: '\b{{ident}}\b'
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:
- match: \b(?i:THEN)\b
scope: keyword.control.conditional
- include: operand
operand-string-expr:
- include: macro-parm
- include: strings
- include: expect-comment
operand:
- meta_content_scope: meta.operand
- include: macro-parm
- include: numbers
- include: strings
- include: macro-functions
- match: \b(?i:NOT|DIV|MOD|AND|OR|XOR|EOR)\b
scope: keyword.operator
macro-functions:
- match: \&(?i:ABS|CHR|CONCAT|DEFAULT|DELSYMTBL|ENTERSYM|EVAL|FINDSYM|GETENV|INTTOSTR|I2S|ISINT|LEN|LEX|LIST|LOWCASE|LC|MAX|MIN|NBR|NEWSYMTBL|ORD|POS|SCANEQ|SCANNE|STRTOINT|S2I|SETTING|SUBSTR|SYSDATE|SYSINDEX|SYSLIST|SYSLST|SYSLOCAL|SYSGLOBAL|SYSMOD|SYSSEG|SYSTIME|SYSTOKEN|SYSTOKSTR|SYSVALUE|SYSFLAGS|TRIM|TYPE|UPCASE|UC)\b
scope: support.function.macro
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.octal
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
- match: '"'
scope: punctuation.definition.string.end
pop: true
- meta_scope: string.quoted.double
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
- match: \n
pop: true
- include: eol
eol:
- match: '$'
pop: true
mnemonics-65816-alt:
- match: \b(?i:BLT|BGE|CPA|DEA|INA|SWA|TAS|TSA)\b
scope: keyword.mnemonic.65816.alt