65816.tmbundle/Syntaxes/ORCA-M.sublime-syntax
2017-11-25 10:01:02 -05:00

344 lines
7.5 KiB
YAML

%YAML 1.2
---
name: ORCA/M Assembler
file_extensions: [src, s]
scope: source.asm.65816.orcam
variables:
ws: '[ \t]+'
ident: '[_~A-Za-z][_~A-Za-z0-9]*'
contexts:
prototype:
- include: comment
- include: eol
main:
- meta_include_prototype: false
- match: '{{ws}}'
push: opcode
- match: '^({{ident}}){{ws}}((?i)START|PRIVATE|DATA|PRIVDATA)\b'
captures:
1: entity.name.function
2: keyword.directive
push: operand-segname
- match: '^({{ident}}){{ws}}((?i)GEQU)\b'
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:
- include: scope:source.asm.65816#mnemonics-6502
- include: scope:source.asm.65816#mnemonics-65c02
- include: scope:source.asm.65816#mnemonics-65816
- 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.smart-macro.toolbox
- match: \b(?i:DC)\b
scope: keyword.directive
set: operand-dc
- match: \b(?i:APPEND|COPY|KEEP|MCOPY|MLOAD|MDROP)\b
scope: keyword.control.import
set: operand-path
- match: \b(?i:ABSADDR|CASE|CODECHK|DATACHECK|DYNCHK|ERR|EXPAND|IEEE|INSTIME|LIST|LONGA|LONGI|MSB|NUMSEX|OBJCASE|PRINTER|SYMBOL|65C02|65816)\b
scope: keyword.directive
set: operand-on-off
- match: \b(?i:DIRECT)\b
scope: keyword.directive
set: operand-or-off
- match: \b(?i:ALIGN|DS|EQU|GEQU|KIND|MERR|ORG|RENAME|SETCOM)\b
scope: keyword.directive
set: operand
# using label
- match: \b(?i:USING)\b
scope: keyword.directive
set: operand-label
- match: \b(?i:ANOP|EJECT|END|ENTRY|OBJEND)\b
scope: keyword.directive
set: expect-comment
- match: \b(?i:START|PRIVATE|DATA|PRIVDATA)\b
scope: keyword.directive
set: operand-segname
- match: \b(?i:TITLE)\b
scope: keyword.directive
set: operand-title
- match: \b(?i:MEM)\b
scope: invalid.deprecated
set: operand
- match: '{{ws}}'
set: operand
operand:
- include: numbers
- include: strings
operand-label:
- match: '\b{{ident}}\b'
set: expect-comment
- include: need-operand
need-operand:
- match: '\n'
scope: invalid.illegal.operand
set: main
- match: '\S'
scope: invalid.illegal.operand
operand-or-off:
- match: \b(?i:OFF)\b
scope: constant.language
set: expect-comment
- include: operand
# optional label.
operand-segname:
- match: '\b{{ident}}\b'
set: expect-comment
- include: expect-comment
operand-title:
- match: "'"
scope: punctuation.definition.string.begin
set:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- match: "'"
scope: punctuation.definition.string.end
set: expect-comment
- match: \n
scope: invalid.illegal.newline.asm
set: main
- match: '([^ \t\n;]+)'
scope: string.unquoted
set: expect-comment
operand-on-off:
- match: \b(?i:ON|OFF)\b
scope: constant.language
set: expect-comment
- match: \S
scope: invalid.illegal.operand
operand-path:
- match: '([^ \t\n;]+)'
scope: string.unquoted
set: expect-comment
operand-dc:
# dc nB
# dc nH
# dc nX
- match: \d+
scope: constant.numeric
set: operand-dc-format
- include: operand-dc-format
operand-dc-format:
- match: ([bB])
scope: storage.type
set: operand-dc-b
- match: ([cC])
scope: storage.type
set: operand-dc-c
- match: ([hH])
scope: storage.type
set: operand-dc-h
- match: ((?i)[ABCDEFHIRS])(\d+)?
captures:
1: storage.type
2: constant.numeric
set: operand-dc-other
- match: '[^ \t,]'
scope: invalid.illegal.operand
set: operand-dc-other
operand-dc-b:
# '[01]+'
- match: "'"
scope: punctuation.definition.string.begin
set:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- match: "'"
scope: punctuation.definition.string.end
set: operand-dc
- match: \n
scope: invalid.illegal.newline
pop: true
- match: '[^01]'
scope: invalid.illegal
operand-dc-h:
# '[A-Fa-f0-9]+'
- match: "'"
scope: punctuation.definition.string.begin
set:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- match: "'"
scope: punctuation.definition.string.end
set: operand-dc
- match: \n
scope: invalid.illegal.newline
pop: true
- match: '[^A-Fa-f0-9\t ]'
scope: invalid.illegal
operand-dc-c:
- match: "'"
scope: punctuation.definition.string.begin
set:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- match: \''|[^'\n] # '' to escape
- match: "'"
scope: punctuation.definition.string.end
set: operand-dc
- match: \n
scope: invalid.illegal.newline
pop: true
operand-dc-other:
- match: "'"
scope: punctuation.definition.string.begin
set:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- include: numbers
- match: "'"
scope: punctuation.definition.string.end
set: operand-dc
- 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
numbers:
- match: \d+
scope: constant.numeric
- match: \$[0-9a-fA-F]+
scope: constant.numeric.hex
- match: \%[01]+
scope: constant.numeric.binary
- match: \@[0-7]+
scope: constant.numeric.octal
strings:
- match: "'"
scope: punctuation.definition.string.begin
push:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- match: \''|[^'\n] # '' to escape
- 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
- meta_scope: string.quoted.double
- match: \""|[^"\n] # '' to escape
- match: '"'
scope: punctuation.definition.string.end
pop: true
- match: \n
scope: invalid.illegal.newline.asm
pop: true
string:
- match: "'"
scope: punctuation.definition.string.begin
push:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- match: \''|[^'\n] # '' to escape
- match: "'"
scope: punctuation.definition.string.end
pop: true
- match: \n
scope: invalid.illegal.newline.asm
pop: true
mnemonics-65816-alt:
- match: \b(?i:BLT|BGE|CPA)\b
scope: keyword.mnemonic.65816.alt