From 356800f90e7ab2ecaabf16bf2272eef634cbec9e Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Sun, 3 Jun 2018 04:12:44 +0200 Subject: [PATCH] Add generic 65816 and 6502 grammars --- grammars/65816 Assembly.cson | 42 ------------ grammars/65816-generic.cson | 65 +++++++++++++++++++ grammars/65816l-opcodes.cson | 23 +++++++ grammars/65c02-generic.cson | 65 +++++++++++++++++++ grammars/cc65-816-toolchain.cson | 9 +-- grammars/cc65-directives.cson | 14 +--- grammars/cc65-toolchain.cson | 8 +-- ...-toolchain.cson => wdc-816-toolchain.cson} | 8 +-- grammars/wdc-directives.cson | 14 +--- grammars/wdc-toolchain.cson | 4 +- 10 files changed, 174 insertions(+), 78 deletions(-) delete mode 100644 grammars/65816 Assembly.cson create mode 100644 grammars/65816-generic.cson create mode 100644 grammars/65816l-opcodes.cson create mode 100644 grammars/65c02-generic.cson rename grammars/{wdc816-toolchain.cson => wdc-816-toolchain.cson} (50%) diff --git a/grammars/65816 Assembly.cson b/grammars/65816 Assembly.cson deleted file mode 100644 index a9412db..0000000 --- a/grammars/65816 Assembly.cson +++ /dev/null @@ -1,42 +0,0 @@ -'fileTypes': [] -'name': '65816 Assembly' -'patterns': [ - { - 'include': '#M6502' - } - { - 'include': '#M65C02' - } - { - 'include': '#M65816L' - } - { - 'include': '#M65816' - } -] -'repository': - 'M6502': - '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' - 'name': 'keyword.mnemonic.6502' - 'M65816': - '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' - 'name': 'keyword.mnemonic.65816' - 'M65816L': - 'match': '\\b(?i:ADCL|ANDL|CMPL|EORL|LDAL|ORAL|SBCL|STAL)\\b' - 'name': 'keyword.mnemonic.65816.long' - 'M65C02': - 'match': '\\b(?i:BRA|PHX|PHY|PLX|PLY|STP|STZ|TRB|TSB|WAI)\\b' - 'name': 'keyword.mnemonic.65c02' - 'binary_number': - 'match': '%[01]+' - 'name': 'constant.numeric.binary' - 'decimal_number': - 'match': '\\b([0-9]+)\\b' - 'name': 'constant.numeric.decimal' - 'hex_number': - 'match': '\\$[A-Fa-f0-9]+' - 'name': 'constant.numeric.hex' - 'octal_number': - 'match': '@([0-7]+)\\b' - 'name': 'constant.numeric.octal' -'scopeName': 'source.assembly.65816' diff --git a/grammars/65816-generic.cson b/grammars/65816-generic.cson new file mode 100644 index 0000000..4807f6c --- /dev/null +++ b/grammars/65816-generic.cson @@ -0,0 +1,65 @@ +# Generic 65816 grammar with semicolon comments + +scopeName: 'source.assembly.65816.65816-generic' +fileTypes: [] +name: '65816 Assembly' +patterns: [ + { include: 'source.65816-opcodes' } # add basic 65816 instruction set, includes 6502 and 65c02 opcodes + { include: 'source.65816l-opcodes' } # extend with 6502X opcodes + { include: '#comments' } + { include: '#symbols' } +] + +# Repository starts here ------------------------------------------------------ +repository: + + # comments + comments: + patterns: [ + # semicolon comments + { + match: ';.*$' + name: 'comment.line.semicolon.65816-generic' + } + ] + + # symbols + symbols: + patterns: [ + { + begin: '"' + beginCaptures: + 0: + name: 'punctuation.definition.string.begin.65816-generic' + end: '"' + endCaptures: + 0: + name: 'punctuation.definition.string.end.65816-generic' + name: 'string.quoted.double.assembly.65816-generic' + } + # absolut address/number + { + match: '\\#(\'.\'|[^\\s\']+)' + name: 'constant.numeric.hex.65816-generic' + } + # hex, prefixed with ampersand($) + { + match: '-?\\$[A-Fa-f0-9]+' + name: 'constant.numeric.hex.65816-generic' + } + # hex, suffixed with h(h) + { + match: '-?([0-9]+)h' + name: 'constant.numeric.hex.65816-generic' + } + # binary + { + match: '%[01]+' + name: 'constant.numeric.binary.65816-generic' + } + # decimal + { + match: '\\b([0-9]+)\\b' + name: 'constant.numeric.decimal.65816-generic' + } + ] diff --git a/grammars/65816l-opcodes.cson b/grammars/65816l-opcodes.cson new file mode 100644 index 0000000..b528963 --- /dev/null +++ b/grammars/65816l-opcodes.cson @@ -0,0 +1,23 @@ +# Pseudo opcodes for the 65816 used by some assemblers + +scopeName: 'source.65816l-opcodes' + +patterns: [ + # The 65816 instruction set + { + include: '#mnemonics-65816l' + } +] + +# Respository starts here ----------------------------------------------------- +repository: + + # 65816 instruction set + 'mnemonics-65816l': + patterns: [ + # mnemonics + { + match: '\\b(?i:ADCL|ANDL|CMPL|EORL|LDAL|ORAL|SBCL|STAL)\\b' + name: 'keyword.mnemonic.65816.65816l-opcodes' + } + ] diff --git a/grammars/65c02-generic.cson b/grammars/65c02-generic.cson new file mode 100644 index 0000000..4b007cc --- /dev/null +++ b/grammars/65c02-generic.cson @@ -0,0 +1,65 @@ +# Generic 65C02 grammar with semicolon comments + +scopeName: 'source.assembly.6502.65c02-generic' +fileTypes: [] +name: '6502 Assembly' +patterns: [ + { include: 'source.65c02-opcodes' } # add basic 65816 instruction set, includes 6502 and 65c02 opcodes + { include: 'source.6502x-opcodes' } + { include: '#comments' } + { include: '#symbols' } +] + +# Repository starts here ------------------------------------------------------ +repository: + + # comments + comments: + patterns: [ + # semicolon comments + { + match: ';.*$' + name: 'comment.line.semicolon.65c02-generic' + } + ] + + # symbols + symbols: + patterns: [ + { + begin: '"' + beginCaptures: + 0: + name: 'punctuation.definition.string.begin.65c02-generic' + end: '"' + endCaptures: + 0: + name: 'punctuation.definition.string.end.65c02-generic' + name: 'string.quoted.double.assembly.65c02-generic' + } + # absolut address/number + { + match: '\\#(\'.\'|[^\\s\']+)' + name: 'constant.numeric.hex.65c02-generic' + } + # hex, prefixed with ampersand($) + { + match: '-?\\$[A-Fa-f0-9]+' + name: 'constant.numeric.hex.65c02-generic' + } + # hex, suffixed with h(h) + { + match: '-?([0-9]+)h' + name: 'constant.numeric.hex.65c02-generic' + } + # binary + { + match: '%[01]+' + name: 'constant.numeric.binary.65c02-generic' + } + # decimal + { + match: '\\b([0-9]+)\\b' + name: 'constant.numeric.decimal.65c02-generic' + } + ] diff --git a/grammars/cc65-816-toolchain.cson b/grammars/cc65-816-toolchain.cson index 69fed09..37c32aa 100644 --- a/grammars/cc65-816-toolchain.cson +++ b/grammars/cc65-816-toolchain.cson @@ -1,13 +1,14 @@ # Syntax Highlighting for the cc65 toolchain and 65816 support -scopeName: 'source.cc65-816-toolchain' +scopeName: 'source.assembly.cc65-816-toolchain' name: '65816 Assembly (cc65)' # Name shown in Atom Editor grammar selection # File extensions associated with this grammar fileTypes: [ 's' ] +# include all opcodes and directives the toolchain supports patterns: [ - { include: 'source.65816-opcodes' } # add basic 65816 instruction set, includes 6502 and 65c02 opcodes - { include: 'source.6502x-opcodes' } # extend with 6502X opcodes - { include: 'source.cc65-directives' } # include the directives for the cc65 toolchain + { include: 'source.65816-opcodes' } # add basic 65816 instruction set, includes 6502 and 65c02 opcodes + { include: 'source.6502x-opcodes' } # extend with 6502X opcodes + { include: 'source.cc65-directives' } # include the directives for the cc65 toolchain ] diff --git a/grammars/cc65-directives.cson b/grammars/cc65-directives.cson index 25e79c6..88b1e86 100644 --- a/grammars/cc65-directives.cson +++ b/grammars/cc65-directives.cson @@ -3,17 +3,9 @@ scopeName: 'source.cc65-directives' patterns: [ - { - include: '#comments' - } - # symbols, constants, numbers - { - include: '#symbols' - } - # directives - { - include: '#directives' - } + { include: '#comments' } # comments + { include: '#symbols' } # symbols, constants, numbers + { include: '#directives' } # cc65 assembler directives ] # Repository starts here ------------------------------------------------------ diff --git a/grammars/cc65-toolchain.cson b/grammars/cc65-toolchain.cson index 4b4f2ff..589d5d4 100644 --- a/grammars/cc65-toolchain.cson +++ b/grammars/cc65-toolchain.cson @@ -1,6 +1,6 @@ # Syntax Highlighting for the cc65 toolchain ans 6502 support -scopeName: 'source.cc65-toolchain' +scopeName: 'source.assembly.cc65-toolchain' name: '6502 Assembly (cc65)' # Name shown in Atom Editor grammar selection # File extensions associated with this grammar fileTypes: [ @@ -8,7 +8,7 @@ fileTypes: [ ] # include all opcodes and directives the toolchain supports patterns: [ - { include: 'source.65c02-opcodes' } # the 65c02 opcodes, includes the basic 6502 instruction set - { include: 'source.6502x-opcodes' } # extend with 6502X opcodes - { include: 'source.cc65-directives' } # include the directives for the cc65 toolchain + { include: 'source.65c02-opcodes' } # the 65c02 opcodes, includes the basic 6502 instruction set + { include: 'source.6502x-opcodes' } # extend with 6502X opcodes + { include: 'source.cc65-directives' } # include the directives for the cc65 toolchain ] diff --git a/grammars/wdc816-toolchain.cson b/grammars/wdc-816-toolchain.cson similarity index 50% rename from grammars/wdc816-toolchain.cson rename to grammars/wdc-816-toolchain.cson index c997c13..78cf4e5 100644 --- a/grammars/wdc816-toolchain.cson +++ b/grammars/wdc-816-toolchain.cson @@ -1,6 +1,6 @@ # Syntax Highlighting for the Western Design Center toolchain and 65816 support -scopeName: 'source.wdc816-toolchain' +scopeName: 'source.wdc-816-toolchain' name: '65816 Assembly (WDCTools)' # Name shown in Atom Editor grammar selection # File extensions associated with this grammar fileTypes: [ @@ -8,7 +8,7 @@ fileTypes: [ ] # include all opcodes and directives the toolchain supports patterns: [ - { include: 'source.65816-opcodes' } # the 65c02 opcodes, includes the basic 65c02 instruction set - { include: 'source.65816-aliases' } # Opcode aliases for the 65816 - { include: 'source.wdc-directives' } # include the directives of the WDCxAS assemblers + { include: 'source.65816-opcodes' } # the 65c02 opcodes, includes the basic 65c02 instruction set + { include: 'source.65816-aliases' } # Opcode aliases for the 65816 + { include: 'source.wdc-directives' } # include the directives of the WDCxAS assemblers ] diff --git a/grammars/wdc-directives.cson b/grammars/wdc-directives.cson index 9833f96..f51e699 100644 --- a/grammars/wdc-directives.cson +++ b/grammars/wdc-directives.cson @@ -3,17 +3,9 @@ scopeName: 'source.wdc-directives' patterns: [ - { - include: '#comments' - } - # symbols, constants, numbers - { - include: '#symbols' - } - # directives - { - include: '#directives' - } + { include: '#comments' } + { include: '#symbols' } # symbols, constants, numbers + { include: '#directives' } ] # Repository starts here ------------------------------------------------------ diff --git a/grammars/wdc-toolchain.cson b/grammars/wdc-toolchain.cson index ec03df5..4290b7a 100644 --- a/grammars/wdc-toolchain.cson +++ b/grammars/wdc-toolchain.cson @@ -9,6 +9,6 @@ fileTypes: [ ] # include all opcodes and directives the toolchain supports patterns: [ - { include: 'source.65c02-opcodes' } # the 65c02 opcodes, includes the basic 6502 instruction set - { include: 'source.wdc-directives' } # include the directives of the WDCxAS assemblers + { include: 'source.65c02-opcodes' } # the 65c02 opcodes, includes the basic 6502 instruction set + { include: 'source.wdc-directives' } # include the directives of the WDCxAS assemblers ]