65816.tmbundle/Syntaxes/Macross.sublime-syntax
2017-09-17 00:26:24 -04:00

174 lines
4.4 KiB
YAML

%YAML 1.2
---
name: MACROSS Assembler
file_extensions: []
scope: source.asm.6502.macross
variables:
ws: '[ \t]'
ident: '[A-Za-z_][A-Za-z_0-9]*'
contexts:
prototype:
- include: comments
main:
- match: '\b(?i:include)\b'
scope: keyword.control.import
- match: '\b(macro){{ws}}+({{ident}})\b'
captures:
1: keyword.control.import
2: entitity.name.macro
push:
- match: '{'
set: block
- match: '\b{{ident}}\b'
scope: variable.parameter
- match: '\b(function){{ws}}+({{ident}})\b'
captures:
1: keyword.control.import
2: entitity.name.function
push:
- match: '{'
set: block
- match: '\b{{ident}}\b'
scope: variable.parameter
- match: \bstruct(?=\s*{)
scope: keyword
set: [name_after_struct, block]
- include: block
- include: block-content
name_after_struct:
# - match: \n
# scope: invalid.illegal
# pop: true
- match: '{{ident}}'
scope: entitity.name.struct
pop: true
- match: '[^ \t]+'
scope: invalid.illegal
pop: true
while_after_mdo:
# - match: \n
# scope: invalid.illegal
# pop: true
- match: '\b(?i:while|until)\b'
scope: keyword.control.import
pop: true
- match: '[^ \t]+'
scope: invalid.illegal
pop: true
block:
- match: \{
scope: invalid.illegal
meta_content_scope: meta.block
push: block
- match: \}
pop: true
- include: block-content
block-content:
- include: string
- include: scope:source.asm.65816#mnemonics-6502
- include: scope:source.asm.65816#mnemonics-65c02
- include: numbers
- match: '({{ident}}):'
captures:
1: entitity.name.label
- match: '\b[AaXxYy]\b'
scope: constant.language.register
- match: '\b(?i:TRUE|FALSE|NULL|here)\b'
scope: constant.language
# data statement
- match: \b(?i:block|align|word|long|dbyte|byte|string|struct)\b
scope: storage.type
# macro statements
# c++ #if uses keyword.control.import
- match: \b(?i:mdefine|mif|melse|melseif|mwhile|freturn|mfor|mswitch|mcase|mdefault|define|variable|undefine|function|macro)\b
scope: keyword.control.import
# mdo { block } while | until
- match: \b(?i:mdo)
scope: keyword.control.import
set: [while_after_mdo, block]
- match: '\b(?i:assert|constrain|define|do|else|elseif|extern|freturn|function|if|include|macro|mcase|mdefault|mdefine|mdo|melse|melseif|mfor|mif|mswitch|muntil|mvariable|mwhile|org|rel|start|target|undefine|until|variable|while|word)\b'
scope: keyword
- match: '\b(?i:always|carry|equal|geq|greater|gt|leq|less|lt|minus|negative|neq|never|not_carry|not_equal|not_overflow|not_zero|overflow|plus|positive|sgeq|sgt|sleq|slt|sneq|zero)\b'
scope: keyword.condition
- match: '\b(?i:addressMode|apply|arrayLength|atascii|atasciiColor|debugModeOff|debugModeOn|emitModeOff|emitModeOn|isAbsoluteValue|isARegister|isBlock|isBuiltInFunction|isConditionCode|isDefined|isDirectMode|isExternal|isField|isFunction|isImmediateMode|isIndexedMode|isIndirectMode|isPostIndexedMode|isPreIndexedMode|isRelocatableValue|isString|isStruct|isSymbol|isXIndexedMode|isXRegister|isYIndexedMode|isYRegister|listingOff|listingOn|makeArray|nthChar|printf|strcat|strcmp|strcmplc|strlen|substr|symbolDefine|symbolLookup|symbolName|symbolUsage|valueType)\b'
scope: keyword
string:
- match: '"'
scope: string
push:
- meta_include_prototype: false
- meta_scope: string
- match: '\n'
pop: true
scope: invalid.illegal.newline
- match: '[^"\n]|\\.'
- match: '"'
pop: true
comments:
- match: ';'
push:
- meta_scope: comment.line
- match: '$'
pop: true
- match: '/\*'
push:
- meta_scope: comment.line
- match: '\*/'
pop: true
numbers:
- match: 0[0-7]+
scope: constant.numeric.octal
- match: 0[xX][0-9A-Fa-f]+
scope: constant.numeric.hexadecimal
- match: 0[qQ][0-3]+
scope: constant.numeric.quarters
- match: 0[bB][01]+
scope: constant.numeric
- match: \d+
scope: constant.numeric
- match: \'([^'\n]|\\.)\'
scope: constant.character
- match: \'.*$
scope: invalid.illegal.constant.character