65816.tmbundle/Syntaxes/ORCA-M.sublime-syntax
Kelvin Sherlock e2270615b2 ORCA/M syntax
2017-08-21 15:37:14 -04:00

272 lines
6.2 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
main:
- meta_include_prototype: false
- include: label
label:
- 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
- match: '^{{ident}}'
scope: entity.name.label
# - match: '^&{{ident}}'
# scope: variable.other
- match: ^[*;!.]
push:
- meta_scope: comment.line
- match: \n
pop: true
opcode:
- include: mnemonics-6502
- include: mnemonics-65c02
- include: mnemonics-65816
- include: mnemonics-65816-alt
- match: \b(?i:DC)\b
scope: keyword.directive
set: operand-dc
- match: \b(?i:APPEND|COPY|KEEP|MCOPY)\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: '{{ws}}'
set: operand
operand:
- include: numbers
- include: strings
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: "''" # escaping quote
- 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
eol-pop:
- match: ''
pop: true
expect-comment:
# - include: comment
- match: \S
scope: invalid.illegal.expect.comment
comment:
- match: ;[^\n]*
scope: comment.line.partial
- match: \n
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: (['])([^'\n]*)(')
- match: (['"])([^\\1\n]*?)(\1)
captures:
1: string.quoted.single punctuation.definition.string.begin
2: string.quoted.single
3: string.quoted.single punctuation.definition.string.end
- match: (['"])([^\\1\n]*?)(\n)
captures:
1: string.quoted.single punctuation.definition.string.begin
2: string.quoted.single
3: invalid.illegal.newline.asm
pop: true
# - match: "'"
# scope: punctuation.definition.string.begin
# push: [string-end, string-contents]
# # 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
# # set: eol-pop
# - match: '"'
# scope: punctuation.definition.string.begin
# push:
# - meta_include_prototype: false
# - meta_scope: string.quoted.double
# - match: '"'
# scope: punctuation.definition.string.end
# pop: true
# - match: \n
# scope: invalid.illegal.newline.asm
# 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-alt:
- match: \b(?i:BLT|BGE|CPA)\b
scope: keyword.mnemonic.65816.alt