From 10e34aca94e422ae30023a1e18dd9f4b754121a5 Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Thu, 7 Jun 2018 16:39:14 +0200 Subject: [PATCH 01/11] New files for Merlin grammar --- grammars/65816-generic.cson | 2 +- grammars/65c02-generic.cson | 2 +- grammars/error-multiscope.cson | 23 ++++ grammars/error-test.cson | 133 +++++++++++++++++++ grammars/merlin_old.cson | 228 +++++++++++++++++++++++++++++++++ 5 files changed, 386 insertions(+), 2 deletions(-) create mode 100644 grammars/error-multiscope.cson create mode 100644 grammars/error-test.cson create mode 100644 grammars/merlin_old.cson diff --git a/grammars/65816-generic.cson b/grammars/65816-generic.cson index 4807f6c..4977383 100644 --- a/grammars/65816-generic.cson +++ b/grammars/65816-generic.cson @@ -5,7 +5,7 @@ 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: 'source.65816l-opcodes' } # extend with 65816L opcodes { include: '#comments' } { include: '#symbols' } ] diff --git a/grammars/65c02-generic.cson b/grammars/65c02-generic.cson index 4b007cc..f1e0e5a 100644 --- a/grammars/65c02-generic.cson +++ b/grammars/65c02-generic.cson @@ -4,7 +4,7 @@ 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.65c02-opcodes' } # include 6502 and 65c02 opcodes { include: 'source.6502x-opcodes' } { include: '#comments' } { include: '#symbols' } diff --git a/grammars/error-multiscope.cson b/grammars/error-multiscope.cson new file mode 100644 index 0000000..e85120d --- /dev/null +++ b/grammars/error-multiscope.cson @@ -0,0 +1,23 @@ +scopeName: 'source.multi1' +patterns: [ + { include: '#binnum' } + { include: '#hexnum' } +] + +repository: + # Binary numbers + binnum: + patterns: [ + { + match: '%[01]+' + name: 'constant.numeric.binary.multi1' + } + ] + + hexnum: + patterns: [ + { + match: '\\$[a-zA-Z0-9]+\\b' + name: 'constant.numeric.binary.multi1' + } + ] diff --git a/grammars/error-test.cson b/grammars/error-test.cson new file mode 100644 index 0000000..7c54391 --- /dev/null +++ b/grammars/error-test.cson @@ -0,0 +1,133 @@ +# Generic 65C02 grammar with semicolon comments + +scopeName: 'source.assembly.6502.6502-test' +fileTypes: [] +name: '6502 TEST' +patterns: [ + # { include: 'source.65c02-opcodes' } # include 6502 and 65c02 opcodes + # { include: 'source.6502x-opcodes' } + # { include: '#comments' } + # { include: '#symbols' } + { include: '#labels' } + { include: 'source.multi1' } + # { include: 'source.multi2' } +] + +# Repository starts here ------------------------------------------------------ +repository: + + # Basic line format + line_processor: + patterns: [ + ] + + # Labels + labels: + patterns: [ + # Variables + { + match: '^][:-~][0-~]+' + name: 'entity.name.variable.6502-test' + } + # Local labels and variables + { + match: '^:[:-~][0-~]+' + # name: 'entity.name.label.function.6502-test' + name: 'entity.name.label.local.6502-test' + # name: 'constant.numeric.hex.6502-test' + } + # Global labels + { + match: '^[:-~][0-~]+' + name: 'entity.name.label.function.6502-test' + } + ] + # Lines that start with an asterisk are comment lines + # commands within strings + # { + # begin: '"' + # end: '"' + # name: 'string.quoted.double' + # patterns: [ + # { include: 'source.65c02-opcodes' } + # ] + # } + # # four line word + # { + # begin: '^(\\w*)\\s+\\b' + # beginCaptures: + # 1: + # name: 'invalid.illegal.6502-test' + # end: ';.*' + # endCaptures: + # 0: + # name: 'comment.line.semicolon.6502-test' + # name: 'constant.numeric.hex.6502-test' + # } + # four word line + # { + # # match: '^(\\w*)\\b\\s+(\\w*)\\b\\s+(\\w*)\\b\\s+(\\w*)\\b' + # match: '^(\\w*)\\s+(\\1)\\s+(\\1)\\b' + # captures: + # 1: + # name: 'invalid.illegal.6502-test' + # 2: + # name: 'keyword.mnemonic.6502-test' + # 3: + # name: 'constant.numeric.hex.6502-test' + # 4: + # name: 'comment.line.semicolon.6502-test' + # name: "meta.line_processor.6502-test" + # } + # ] + + # comments + # comments: + # patterns: [ + # # semicolon comments + # { + # match: ';.*$' + # name: 'comment.line.semicolon.6502-test' + # } + # ] + + # symbols + # symbols: + # patterns: [ + # { + # begin: '"' + # beginCaptures: + # 0: + # name: 'punctuation.definition.string.begin.6502-test' + # end: '"' + # endCaptures: + # 0: + # name: 'punctuation.definition.string.end.6502-test' + # name: 'string.quoted.double.assembly.6502-test' + # } + # # absolut address/number + # { + # match: '\\#(\'.\'|[^\\s\']+)' + # name: 'constant.numeric.hex.6502-test' + # } + # # hex, prefixed with ampersand($) + # { + # match: '-?\\$[A-Fa-f0-9]+' + # name: 'constant.numeric.hex.6502-test' + # } + # # hex, suffixed with h(h) + # { + # match: '-?([0-9]+)h' + # name: 'constant.numeric.hex.6502-test' + # } + # # binary + # { + # match: '%[01]+' + # name: 'constant.numeric.binary.6502-test' + # } + # # decimal + # { + # match: '\\b([0-9]+)\\b' + # name: 'constant.numeric.decimal.6502-test' + # } + # ] diff --git a/grammars/merlin_old.cson b/grammars/merlin_old.cson new file mode 100644 index 0000000..d412eaa --- /dev/null +++ b/grammars/merlin_old.cson @@ -0,0 +1,228 @@ +'fileTypes': [] +'name': 'Merlin OLD' +'patterns': [ + { + 'include': '#M6502' + } + { + 'include': '#M65C02' + } + { + 'include': '#M65816' + } + { + 'include': '#M65816L' + } + { + 'include': '#hex_number' + } + { + 'include': '#decimal_number' + } + { + 'match': '%[01][01_]*' + 'name': 'constant.numeric.binary' + } + { + 'match': '\\b(?i:TAS|TSA|SWA|TAD|TDA|BLT|BGE)\\b' + 'name': 'keyword.mnemonic.65816.alt' + } + { + 'match': '(?<=,)([xXyYsS])\\b' + 'name': 'variable.language.register' + } + { + 'begin': '"' + 'end': '"' + 'name': 'string.quoted.double' + } + { + 'begin': '\'' + 'end': '\'' + 'name': 'string.quoted.single' + } + { + 'match': '^[*].*' + 'name': 'comment.line' + } + { + 'match': ';.*' + 'name': 'comment.line' + } + { + 'match': '^][0-~]*\\b' + 'name': 'entity.name.label.variable' + } + { + 'match': '^:[0-~]*\\b' + 'name': 'entity.name.label.local' + } + { + 'match': '^[:-~][0-~]*\\b' + 'name': 'entity.name.function' + } + { + 'captures': + '1': + 'name': 'keyword.directive' + '2': + 'name': 'string.quoted.other.path' + 'comment': 'eg: KEEP pathname' + 'match': '\\b((?i)DSK|PUT|USE|SAV)\\s+(\\S*)' + 'name': 'meta.path.directive' + } + { + 'captures': + '1': + 'name': 'keyword.directive' + '2': + 'name': 'constant.language' + 'comment': 'eg: KEEP pathname' + 'match': '\\b((?i)CYC)\\s+((?i)ON|OFF|AVE)\\b' + 'name': 'meta.cyc.directive' + } + { + 'captures': + '1': + 'name': 'keyword.directive' + '2': + 'name': 'constant.language' + 'comment': 'eg: KEEP pathname' + 'match': '\\b((?i)EXP)\\s+((?i)ON|OFF|ONLY)\\b' + 'name': 'meta.exp.directive' + } + { + 'captures': + '1': + 'name': 'keyword.directive' + '2': + 'name': 'constant.language' + 'comment': 'eg: KEEP pathname' + 'match': '\\b((?i)LST)\\s+((?i)ON|OFF|RTN)\\b' + 'name': 'meta.lst.directive' + } + { + 'captures': + '1': + 'name': 'keyword.directive' + '2': + 'name': 'constant.language' + 'comment': 'eg: KEEP pathname' + 'match': '\\b((?i)LST)\\s+((?i)OFF)\\b' + 'name': 'meta.lstdo.directive' + } + { + 'captures': + '1': + 'name': 'keyword.directive' + '2': + 'name': 'constant.language' + 'comment': 'eg: KEEP pathname' + 'match': '\\b((?i)TR)\\s+((?i)ON|OFF|ADR)\\b' + 'name': 'meta.tr.directive' + } + { + 'captures': + '1': + 'name': 'keyword.directive.string' + '2': + 'name': 'string.delimited.begin' + '3': + 'name': 'string.delimited' + '4': + 'name': 'string.delimited.end' + '5': + 'name': 'keyword.operator' + '6': + 'name': 'constant.numeric.hexadecimal' + 'comment': 'optional trailing hex data' + 'match': '\\b((?i)ASC|DCI|INV|FLS|STR)\\s+(\\S)(.*?)(\\2|$)(,([0-9A-Fa-f]+))?' + 'name': 'meta.string.delimited' + } + { + 'captures': + '1': + 'name': 'keyword.directive.string' + '2': + 'name': 'string.delimited.begin' + '3': + 'name': 'string.delimited' + '4': + 'name': 'string.delimited.end' + 'match': '\\b((?i)REV)\\s+(\\S)(.*?)(\\2|$)' + 'name': 'meta.string.delimited.rev' + } + { + 'begin': '\\b((?i)HEX)\\b' + 'captures': + '1': + 'name': 'keyword.directive.data' + 'comment': 'HEX has a list of hex bytes w/o the $' + 'end': '$' + 'name': 'meta.hex' + 'patterns': [ + { + 'match': '\\b[0-9A-Fa-f]{1,2}\\b' + 'name': 'constant.numeric.hex' + } + { + 'match': ';.*$' + 'name': 'comment.line' + } + { + 'match': ',' + 'name': 'keyword.operator' + } + { + 'match': '\\S' + 'name': 'invalid.illegal' + } + ] + } + { + 'match': '\\b(?i:DSK|EQU|EXT|ENT|ORG|REL|OBJ|PUT|USE|VAR|SAV|TYP|END|DUM|DEND|AST|CYC|DAT|EXP|LST|LSTDO|PAG|TTL|SKP|TR|CHK|ERR|KBD|LUP|--\\^|MX|PAU|SW|USR|XC)\\b' + 'name': 'keyword.directive' + } + { + 'match': '\\b(?i:DA|DW|DDB|DB|DFB|ADR|ADRL|HEX|DS|ASC|DCI|INV|FLS|REV|STR)\\b' + 'name': 'keyword.directive.data' + } + { + 'match': '\\b(?i:DO|ELSE|IF|FIN)\\b' + 'name': 'keyword.control.conditional' + } + { + 'match': '\\b(?i:MAC)\\b|<<<' + 'name': 'keyword.directive.macro' + } + { + 'match': '[-+/*^><|#\\[\\](),=.!&]' + 'name': 'keyword.operator' + } +] +'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.merlin' From 28079336e1d492e4892867ea009bd6d8a6fb5c67 Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Thu, 7 Jun 2018 17:15:47 +0200 Subject: [PATCH 02/11] Fix hex numbers with suffix 'h' --- grammars/65816-generic.cson | 2 +- grammars/65c02-generic.cson | 2 +- grammars/cc65-directives.cson | 9 +++++---- grammars/wdc-directives.cson | 14 +++++++------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/grammars/65816-generic.cson b/grammars/65816-generic.cson index 4807f6c..9372062 100644 --- a/grammars/65816-generic.cson +++ b/grammars/65816-generic.cson @@ -49,7 +49,7 @@ repository: } # hex, suffixed with h(h) { - match: '-?([0-9]+)h' + match: '-?([a-fA-F0-9]+)h' name: 'constant.numeric.hex.65816-generic' } # binary diff --git a/grammars/65c02-generic.cson b/grammars/65c02-generic.cson index 4b007cc..ec8287b 100644 --- a/grammars/65c02-generic.cson +++ b/grammars/65c02-generic.cson @@ -49,7 +49,7 @@ repository: } # hex, suffixed with h(h) { - match: '-?([0-9]+)h' + match: '-?([a-fA-F0-9]+)h' name: 'constant.numeric.hex.65c02-generic' } # binary diff --git a/grammars/cc65-directives.cson b/grammars/cc65-directives.cson index 88b1e86..8941988 100644 --- a/grammars/cc65-directives.cson +++ b/grammars/cc65-directives.cson @@ -24,6 +24,7 @@ repository: # symbols symbols: patterns: [ + # strings { begin: '"' beginCaptures: @@ -35,19 +36,19 @@ repository: name: 'punctuation.definition.string.end.cc65-directives' name: 'string.quoted.double.assembly.cc65-directives' } - # absolut address/number + # absolut addressing/numbers { match: '\\#(\'.\'|[^\\s\']+)' name: 'constant.numeric.hex.cc65-directives' } - # hex, prefixed with ampersand($) + # hex, prefixed with dollar sign($) { - match: '-?\\$[A-Fa-f0-9]+' + match: '-?\\$[a-fA-F0-9]+' name: 'constant.numeric.hex.cc65-directives' } # hex, suffixed with h(h) { - match: '-?([0-9]+)h' + match: '-?\\b([a-fA-F0-9]+)h' name: 'constant.numeric.hex.cc65-directives' } # binary diff --git a/grammars/wdc-directives.cson b/grammars/wdc-directives.cson index f51e699..7df1014 100644 --- a/grammars/wdc-directives.cson +++ b/grammars/wdc-directives.cson @@ -36,19 +36,19 @@ repository: name: 'punctuation.definition.string.end.wdc-toolchain' name: 'string.quoted.double.assembly.wdc-toolchain' } - # absolut addressing/numbering + # absolut addressing/numbers { match: '\\#(\'.\'|[^\\s\']+)' name: 'constant.numeric.hex.wdc-toolchain' } - # hex, prefixed with ampersand($) + # hex, prefixed with dollar sign($) { - match: '-?\\$[A-Fa-f0-9]+' + match: '-?\\$\\b[a-fA-F0-9]+' name: 'constant.numeric.hex.wdc-toolchain' } # hex, suffixed with h(h) { - match: '-?([0-9]+)h' + match: '-?\\b([a-fA-F0-9]+)h' name: 'constant.numeric.hex.wdc-toolchain' } # binary prefixed with % @@ -63,7 +63,7 @@ repository: } # octal and decimal { - match: '\\b([0-9]+(d|o|q)?)\\b' + match: '\\b([0-9]+[doq]?)\\b' name: 'constant.numeric.decimal.wdc-toolchain' } ] @@ -73,7 +73,7 @@ repository: patterns: [ # File and Symbol control { - match: '\\b(?i:append|include|insert|end(s|mod)?|exit|module|section|org|origin|equ(al)?|gequ|defl|set|var|extern(al|s)?|xref|globals?|public|xdef|message|messg|efunc|incdebug)\\b' + match: '\\b(?i:append|include|insert|end(s|mod)?|exit|module|section|ref_only|org|origin|equ(al)?|gequ|defl|set|var|extern(al|s)?|xref|globals?|public|xdef|message|messg|efunc|incdebug)\\b' name: 'support.function.pseudo.wdc-toolchain' } # Parsing control @@ -108,7 +108,7 @@ repository: } # Operators II { - match: '\\b(?i:and|not|mod|sh[lr]|x?or|eq|u?[gl]t)\\b' + match: '\\.\\b(?i:and|not|mod|sh[lr]|x?or|eq|u?[gl]t)\\b\\.' name: 'keyword.operator.wdc-toolchain' } ] From 42530f66bcc57b61c3182032f4def4b9456fc300 Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Thu, 7 Jun 2018 18:24:53 +0200 Subject: [PATCH 03/11] DASM: Add opcodes and comments --- grammars/6502 Assembly (DASM) OLD.cson | 65 +++++++++++ grammars/6502 Assembly (DASM).cson | 150 +++++++++++++++---------- grammars/65816-generic.cson | 6 +- grammars/65c02-generic.cson | 4 +- grammars/acme.cson | 2 +- grammars/cc65-directives.cson | 4 +- grammars/wdc-directives.cson | 4 +- 7 files changed, 163 insertions(+), 72 deletions(-) create mode 100644 grammars/6502 Assembly (DASM) OLD.cson diff --git a/grammars/6502 Assembly (DASM) OLD.cson b/grammars/6502 Assembly (DASM) OLD.cson new file mode 100644 index 0000000..625bb4e --- /dev/null +++ b/grammars/6502 Assembly (DASM) OLD.cson @@ -0,0 +1,65 @@ +'fileTypes': [] +'foldingStartMarker': '/\\*\\*|\\{\\s*$' +'foldingStopMarker': '\\*\\*/|^\\s*\\}' +'name': '6502 Assembly (DASM) OLD' +'patterns': [ + { + 'match': '\\b(adc|and|asl|bit|clc|cld|cli|clv|cmp|cpx|cpy|dec|dex|dey|eor|inc|inx|iny|lda|ldx|ldy|lsr|nop|ora|pha|php|pla|plp|rol|ror|sbc|sec|sed|sei|sta|stx|sty|tax|txa|tay|tya|tsx|txs)\\b' + 'name': 'keyword' + } + { + 'match': '\\b(bcc|bcs|beq|bmi|bne|bpl|brk|bvc|bvs|jmp|jsr|rti|rts)\\b' + 'name': 'keyword.control' + } + { + 'captures': + '1': + 'name': 'punctuation.definition.comment' + 'match': '(;).*$\\n?' + 'name': 'comment.line.semicolon' + } + { + 'match': '\\b(SET|WORD|BYTE|HEX)\\b' + 'name': 'storage.type' + } + { + 'match': '\\b(ALIGN)\\b' + 'name': 'storage.modifier' + } + { + 'match': '\\b(REPEAT|REPEND|MAC|ENDM|SUBROUTINE)\\b' + 'name': 'support.function' + } + { + 'match': '\\b(processor|org)\\b' + 'name': 'constant.language' + } + { + 'begin': '"' + 'end': '"' + 'name': 'string.quoted.double.untitled' + 'patterns': [ + { + 'match': '\\\\.' + 'name': 'constant.character.escape.untitled' + } + ] + } + { + 'match': '^[A-Za-z_][A-Za-z0-9_]*' + 'name': 'entity.name.label' + } + { + 'match': '^\\.[A-Za-z_][A-Za-z0-9_]*' + 'name': 'entity.name.label.local' + } + { + 'match': '#?\\$[0-9a-fA-F]+' + 'name': 'constant.numeric.hex' + } + { + 'match': '{[0-9]+}' + 'name': 'variable.parameter.macro' + } +] +'scopeName': 'source.assembly.6502.dasm' diff --git a/grammars/6502 Assembly (DASM).cson b/grammars/6502 Assembly (DASM).cson index ffa9cd1..a8bb812 100644 --- a/grammars/6502 Assembly (DASM).cson +++ b/grammars/6502 Assembly (DASM).cson @@ -1,65 +1,91 @@ -'fileTypes': [] -'foldingStartMarker': '/\\*\\*|\\{\\s*$' -'foldingStopMarker': '\\*\\*/|^\\s*\\}' -'name': '6502 Assembly (DASM)' -'patterns': [ - { - 'match': '\\b(adc|and|asl|bit|clc|cld|cli|clv|cmp|cpx|cpy|dec|dex|dey|eor|inc|inx|iny|lda|ldx|ldy|lsr|nop|ora|pha|php|pla|plp|rol|ror|sbc|sec|sed|sei|sta|stx|sty|tax|txa|tay|tya|tsx|txs)\\b' - 'name': 'keyword' - } - { - 'match': '\\b(bcc|bcs|beq|bmi|bne|bpl|brk|bvc|bvs|jmp|jsr|rti|rts)\\b' - 'name': 'keyword.control' - } - { - 'captures': - '1': - 'name': 'punctuation.definition.comment' - 'match': '(;).*$\\n?' - 'name': 'comment.line.semicolon' - } - { - 'match': '\\b(SET|WORD|BYTE|HEX)\\b' - 'name': 'storage.type' - } - { - 'match': '\\b(ALIGN)\\b' - 'name': 'storage.modifier' - } - { - 'match': '\\b(REPEAT|REPEND|MAC|ENDM|SUBROUTINE)\\b' - 'name': 'support.function' - } - { - 'match': '\\b(processor|org)\\b' - 'name': 'constant.language' - } - { - 'begin': '"' - 'end': '"' - 'name': 'string.quoted.double.untitled' - 'patterns': [ +# Syntax highlighting for the DASM macro assembler + +scopeName: 'source.assembly.6502.dasm' +fileTypes: [] +name: '6502 Assembly (DASM)' +patterns: [ + { include: 'source.6502-opcodes' } + { include: '#comments' } + { include: '#symbols' } + # { include: '#directives' } +] + +# Repository starts here ------------------------------------------------------ +repository: + + # comments + comments: + patterns: [ + # semicolon comments { - 'match': '\\\\.' - 'name': 'constant.character.escape.untitled' + match: ';.*$' + name: 'comment.line.semicolon.dasm' } ] - } - { - 'match': '^[A-Za-z_][A-Za-z0-9_]*' - 'name': 'entity.name.label' - } - { - 'match': '^\\.[A-Za-z_][A-Za-z0-9_]*' - 'name': 'entity.name.label.local' - } - { - 'match': '#?\\$[0-9a-fA-F]+' - 'name': 'constant.numeric.hex' - } - { - 'match': '{[0-9]+}' - 'name': 'variable.parameter.macro' - } -] -'scopeName': 'source.assembly.6502.dasm' + + # symbols + symbols: + patterns: [ + # strings + { + begin: '"' + beginCaptures: + 0: + name: 'punctuation.definition.string.begin.dasm' + end: '"' + endCaptures: + 0: + name: 'punctuation.definition.string.end.dasm' + name: 'string.quoted.double.dasm' + } + # absolut addressing/numbers + # { + # match: '\\#(\'.\'|[^\\s\']+)' + # name: 'constant.numeric.hex.dasm' + # } + # hex, prefixed with dollar sign($) + { + match: '-?#?\\$\\b[a-fA-F0-9]+\\b' + name: 'constant.numeric.hex.dasm' + } + # octal, prefixed with zero(0) + { + match: '-?#?\\b0[1-7]+\\b' + name: 'constant.numeric.octal.dasm' + } + # binary + { + match: '#?%[01]+' + name: 'constant.numeric.binary.65816-generic' + } + # decimal + { + match: '#?\\b([0-9]+)\\b' + name: 'constant.numeric.decimal.65816-generic' + } + ] + + # directives + directives: + patterns: [ + # file and symbol control + { + match: '\\b(?i:seg(\\.u)?|include|incbin|incdir|hex|err|r?org|processor|echo|rend|align|subroutine|)\\b' + name: 'support.function.pseudo.dasm' + } + # data control + # { + # match: '\\b(?i:d[csv](.bwl)?|hex|eq[um]|set|list\\s(on|off))\\b' + # name: 'support.function.pseudo.dasm' + # } + # Macro control + # { + # match: '\\b(?i:mac|endm|mexit)\\b' + # name: 'support.function.pseudo.acme' + # } + # Conditional control + # { + # match: '\\b(?i:ifn?const|if|else|e(nd)?if|repeat|repend)\\b' + # name: 'keyword.control.conditional.acme' + # } + ] diff --git a/grammars/65816-generic.cson b/grammars/65816-generic.cson index 9372062..ff7b895 100644 --- a/grammars/65816-generic.cson +++ b/grammars/65816-generic.cson @@ -35,16 +35,16 @@ repository: endCaptures: 0: name: 'punctuation.definition.string.end.65816-generic' - name: 'string.quoted.double.assembly.65816-generic' + name: 'string.quoted.double.65816-generic' } # absolut address/number { match: '\\#(\'.\'|[^\\s\']+)' name: 'constant.numeric.hex.65816-generic' } - # hex, prefixed with ampersand($) + # hex, prefixed with dollar sign($) { - match: '-?\\$[A-Fa-f0-9]+' + match: '-?\\$\\b[a-fA-F0-9]+\\b' name: 'constant.numeric.hex.65816-generic' } # hex, suffixed with h(h) diff --git a/grammars/65c02-generic.cson b/grammars/65c02-generic.cson index ec8287b..698eeb8 100644 --- a/grammars/65c02-generic.cson +++ b/grammars/65c02-generic.cson @@ -35,7 +35,7 @@ repository: endCaptures: 0: name: 'punctuation.definition.string.end.65c02-generic' - name: 'string.quoted.double.assembly.65c02-generic' + name: 'string.quoted.double.65c02-generic' } # absolut address/number { @@ -44,7 +44,7 @@ repository: } # hex, prefixed with ampersand($) { - match: '-?\\$[A-Fa-f0-9]+' + match: '-?\\$\\b[A-Fa-f0-9]+\\b' name: 'constant.numeric.hex.65c02-generic' } # hex, suffixed with h(h) diff --git a/grammars/acme.cson b/grammars/acme.cson index 23566c1..8acf08f 100644 --- a/grammars/acme.cson +++ b/grammars/acme.cson @@ -43,7 +43,7 @@ repository: endCaptures: 0: name: 'punctuation.definition.string.end.acme' - name: 'string.quoted.double.assembly.acme' + name: 'string.quoted.double.acme' } # absolut addressing/numbering { diff --git a/grammars/cc65-directives.cson b/grammars/cc65-directives.cson index 8941988..c067235 100644 --- a/grammars/cc65-directives.cson +++ b/grammars/cc65-directives.cson @@ -34,7 +34,7 @@ repository: endCaptures: 0: name: 'punctuation.definition.string.end.cc65-directives' - name: 'string.quoted.double.assembly.cc65-directives' + name: 'string.quoted.double.cc65-directives' } # absolut addressing/numbers { @@ -43,7 +43,7 @@ repository: } # hex, prefixed with dollar sign($) { - match: '-?\\$[a-fA-F0-9]+' + match: '-?\\$\\b[a-fA-F0-9]+\\b' name: 'constant.numeric.hex.cc65-directives' } # hex, suffixed with h(h) diff --git a/grammars/wdc-directives.cson b/grammars/wdc-directives.cson index 7df1014..b007c57 100644 --- a/grammars/wdc-directives.cson +++ b/grammars/wdc-directives.cson @@ -34,7 +34,7 @@ repository: endCaptures: 0: name: 'punctuation.definition.string.end.wdc-toolchain' - name: 'string.quoted.double.assembly.wdc-toolchain' + name: 'string.quoted.double.wdc-toolchain' } # absolut addressing/numbers { @@ -43,7 +43,7 @@ repository: } # hex, prefixed with dollar sign($) { - match: '-?\\$\\b[a-fA-F0-9]+' + match: '-?\\$\\b[a-fA-F0-9]+\\b' name: 'constant.numeric.hex.wdc-toolchain' } # hex, suffixed with h(h) From 1ce19430cfd754c7f49aa638de13330b064627cb Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Thu, 7 Jun 2018 20:54:11 +0200 Subject: [PATCH 04/11] Fix DASM grammar --- grammars/6502 Assembly (DASM).cson | 65 ++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/grammars/6502 Assembly (DASM).cson b/grammars/6502 Assembly (DASM).cson index a8bb812..4635b02 100644 --- a/grammars/6502 Assembly (DASM).cson +++ b/grammars/6502 Assembly (DASM).cson @@ -7,7 +7,7 @@ patterns: [ { include: 'source.6502-opcodes' } { include: '#comments' } { include: '#symbols' } - # { include: '#directives' } + { include: '#directives' } ] # Repository starts here ------------------------------------------------------ @@ -38,29 +38,45 @@ repository: name: 'punctuation.definition.string.end.dasm' name: 'string.quoted.double.dasm' } + # global labels + { + captures: + 1: + name: 'entity.name.function.label.dasm' + match: '\\b([A-Za-z0-9_]+):' + name: 'meta.function.label.dasm' + } + # local labels + { + captures: + 1: + name: 'entity.name.function.label.dasm' + match: '\\.\\b([A-Za-z0-9_]+):' + name: 'meta.function.label.dasm' + } # absolut addressing/numbers - # { - # match: '\\#(\'.\'|[^\\s\']+)' - # name: 'constant.numeric.hex.dasm' - # } + { + match: '\\#(\'.\'|[^\\s\']+)' + name: 'constant.numeric.hex.dasm' + } # hex, prefixed with dollar sign($) { - match: '-?#?\\$\\b[a-fA-F0-9]+\\b' + match: '-?\\$\\b[a-fA-F0-9]+\\b' name: 'constant.numeric.hex.dasm' } # octal, prefixed with zero(0) { - match: '-?#?\\b0[1-7]+\\b' + match: '-?\\b0[1-7]+\\b' name: 'constant.numeric.octal.dasm' } # binary { - match: '#?%[01]+' + match: '%[01]+' name: 'constant.numeric.binary.65816-generic' } # decimal { - match: '#?\\b([0-9]+)\\b' + match: '\\b([0-9]+)\\b' name: 'constant.numeric.decimal.65816-generic' } ] @@ -70,22 +86,27 @@ repository: patterns: [ # file and symbol control { - match: '\\b(?i:seg(\\.u)?|include|incbin|incdir|hex|err|r?org|processor|echo|rend|align|subroutine|)\\b' + match: '\\b(?i:seg(\\.u)?|include|incbin|incdir|hex|err|r?org|processor|echo|rend|align|subroutine)\\b' name: 'support.function.pseudo.dasm' } # data control - # { - # match: '\\b(?i:d[csv](.bwl)?|hex|eq[um]|set|list\\s(on|off))\\b' - # name: 'support.function.pseudo.dasm' - # } + { + match: '\\b(?i:d[csv](.bwl)?|hex|eq[um]|set|list\\s(on|off))\\b' + name: 'support.function.pseudo.dasm' + } + # data control II + { + match: '\\.\\b(?i:byte|word)\\b' + name: 'support.function.pseudo.dasm' + } # Macro control - # { - # match: '\\b(?i:mac|endm|mexit)\\b' - # name: 'support.function.pseudo.acme' - # } + { + match: '\\b(?i:mac|endm|mexit)\\b' + name: 'support.function.pseudo.acme' + } # Conditional control - # { - # match: '\\b(?i:ifn?const|if|else|e(nd)?if|repeat|repend)\\b' - # name: 'keyword.control.conditional.acme' - # } + { + match: '\\b(?i:ifn?const|if|else|e(nd)?if|repeat|repend)\\b' + name: 'keyword.control.conditional.acme' + } ] From 1687bd1b93d4494b049cd85a29bc2264aa7ab35c Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Fri, 8 Jun 2018 02:57:54 +0200 Subject: [PATCH 05/11] Improve Merlin grammar --- grammars/65816alt-opcodes.cson | 23 ++ grammars/merlin.cson | 435 ++++++++++++++++----------------- grammars/merlin_old.cson | 2 +- 3 files changed, 236 insertions(+), 224 deletions(-) create mode 100644 grammars/65816alt-opcodes.cson diff --git a/grammars/65816alt-opcodes.cson b/grammars/65816alt-opcodes.cson new file mode 100644 index 0000000..9c65693 --- /dev/null +++ b/grammars/65816alt-opcodes.cson @@ -0,0 +1,23 @@ +# Pseudo opcodes for the 65816 used by some assemblers + +scopeName: 'source.65816alt-opcodes' + +patterns: [ + # The 65816 instruction set + { + include: '#mnemonics-65816alt' + } +] + +# Respository starts here ----------------------------------------------------- +repository: + + # 65816 instruction set + 'mnemonics-65816alt': + patterns: [ + # mnemonics + { + match: '\\b(?i:tas|tsa|swa|tad|tda|blt|bge)\\b' + name: 'keyword.mnemonic.65816.65816alt-opcodes' + } + ] diff --git a/grammars/merlin.cson b/grammars/merlin.cson index 9beaad0..df966e8 100644 --- a/grammars/merlin.cson +++ b/grammars/merlin.cson @@ -1,228 +1,217 @@ -'fileTypes': [] -'name': 'Merlin' -'patterns': [ - { - 'include': '#M6502' - } - { - 'include': '#M65C02' - } - { - 'include': '#M65816' - } - { - 'include': '#M65816L' - } - { - 'include': '#hex_number' - } - { - 'include': '#decimal_number' - } - { - 'match': '%[01][01_]*' - 'name': 'constant.numeric.binary' - } - { - 'match': '\\b(?i:TAS|TSA|SWA|TAD|TDA|BLT|BGE)\\b' - 'name': 'keyword.mnemonic.65816.alt' - } - { - 'match': '(?<=,)([xXyYsS])\\b' - 'name': 'variable.language.register' - } - { - 'begin': '"' - 'end': '"' - 'name': 'string.quoted.double' - } - { - 'begin': '\'' - 'end': '\'' - 'name': 'string.quoted.single' - } - { - 'match': '^[*].*' - 'name': 'comment.line' - } - { - 'match': ';.*' - 'name': 'comment.line' - } - { - 'match': '^][0-~]*\\b' - 'name': 'entity.name.label.variable' - } - { - 'match': '^:[0-~]*\\b' - 'name': 'entity.name.label.local' - } - { - 'match': '^[:-~][0-~]*\\b' - 'name': 'entity.name.function' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'string.quoted.other.path' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)DSK|PUT|USE|SAV)\\s+(\\S*)' - 'name': 'meta.path.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)CYC)\\s+((?i)ON|OFF|AVE)\\b' - 'name': 'meta.cyc.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)EXP)\\s+((?i)ON|OFF|ONLY)\\b' - 'name': 'meta.exp.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)LST)\\s+((?i)ON|OFF|RTN)\\b' - 'name': 'meta.lst.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)LST)\\s+((?i)OFF)\\b' - 'name': 'meta.lstdo.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)TR)\\s+((?i)ON|OFF|ADR)\\b' - 'name': 'meta.tr.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive.string' - '2': - 'name': 'string.delimited.begin' - '3': - 'name': 'string.delimited' - '4': - 'name': 'string.delimited.end' - '5': - 'name': 'keyword.operator' - '6': - 'name': 'constant.numeric.hexadecimal' - 'comment': 'optional trailing hex data' - 'match': '\\b((?i)ASC|DCI|INV|FLS|STR)\\s+(\\S)(.*?)(\\2|$)(,([0-9A-Fa-f]+))?' - 'name': 'meta.string.delimited' - } - { - 'captures': - '1': - 'name': 'keyword.directive.string' - '2': - 'name': 'string.delimited.begin' - '3': - 'name': 'string.delimited' - '4': - 'name': 'string.delimited.end' - 'match': '\\b((?i)REV)\\s+(\\S)(.*?)(\\2|$)' - 'name': 'meta.string.delimited.rev' - } - { - 'begin': '\\b((?i)HEX)\\b' - 'captures': - '1': - 'name': 'keyword.directive.data' - 'comment': 'HEX has a list of hex bytes w/o the $' - 'end': '$' - 'name': 'meta.hex' - 'patterns': [ +scopeName: 'source.assembly.65816.merlin' +fileTypes: [] +name: 'Merlin' +patterns: [ + { include: 'source.65c02-opcodes' } + { include: 'source.65816-opcodes' } + { include: 'source.65816l-opcodes' } + { include: 'source.65816alt-opcodes' } + { include: '#comments' } + { include: '#symbols' } + { include: '#directives' } + # registers + # TODO: fix registers + # { + # 'match': '(?<=,)([xXyYsS])\\b' + # 'name': 'variable.language.register' + # } +] + + +repository: + + # comments + comments: + patterns: [ + # asterisk line comment { - 'match': '\\b[0-9A-Fa-f]{1,2}\\b' - 'name': 'constant.numeric.hex' + match: '^[*].*' + name: 'comment.line.asterisk.merlin' } + # semicolon line comment { - 'match': ';.*$' - 'name': 'comment.line' - } - { - 'match': ',' - 'name': 'keyword.operator' - } - { - 'match': '\\S' - 'name': 'invalid.illegal' + match: ';.*$' + name: 'comment.line.semicolon.merlin' + } + ] + + # symbols + symbols: + patterns: [ + # delimited strings + { + begin: '[\'"]' + beginCaptures: + 0: name: 'punctuation.definition.string.begin.merlin' + end: '[\'"]' + endCaptures: + 0: name: 'punctuation.definition.string.end.merlin' + name: 'string.quoted.double.assembly.merlin' + } + # TODO: highlight strings with all valid delimiters + # { + # captures: + # 1: name: 'string.delimited.begin.merlin' + # 2: name: 'string.delimited.merlin' + # 3: name: 'string.delimited.end.merlin' + # match: '\\b(\\S)(.*?)(\\1)\\b' + # } + # TODO: fix label scopes + # Variables + { + match: '^][:-~][0-~]+' + # name: 'variable.named.merlin' + name: 'entity.name.function.label.merlin' + } + # Local labels + { + match: '^:[:-~][0-~]+' + name: 'entity.name.function.label.merlin' + } + # Global labels + { + match: '^[:-~][0-~]+' + name: 'entity.name.function.merlin' + } + # absolut address/number + { + match: '\\#(\'.\'|[^\\s\']+)' + name: 'constant.numeric.hex.merlin' + } + # hex, prefixed with ampersand($) + { + match: '-?\\$[A-Fa-f0-9]+' + name: 'constant.numeric.hex.merlin' + } + # octal, prefixed with @ + { + match: '@([0-7]+)\\b' + name: 'constant.numeric.octal.merlin' + } + # binary + { + match: '%[01]+' + name: 'constant.numeric.binary.merlin' + } + # decimal + { + match: '\\b([0-9]+)\\b' + name: 'constant.numeric.decimal.merlin' + } + ] + + # assembler directives + directives: + patterns: [ + # file control + { + match: '\\b(?i:equ|ext|ent|org|rel|obj|var|typ|end|dum|dend|ast|dat|lstdo|pag|ttl|skp|chk|err|kbd|lup|--\\^|mx|pau|sw|usr|xc)\\b' + name: 'keyword.directive.merlin' + } + # data control + { + match: '\\b(?i:da|dw|ddb|db|dfb|adr|adrl|ds)\\b' + name: 'support.function.pseudo.merlin' + } + # conditional control + { + match: '\\b(?i:do|else|if|fin)\\b' + name: 'keyword.control.conditional.merlin' + } + # macro control + { + match: '\\b(?i:mac)\\b|<<<' + name: 'support.function.pseudo.merlin' + # name: 'keyword.directive.macro.merlin' + } + # operators + { + match: '[-+/*^><|#\\[\\](),=.!&]' + name: 'keyword.operator.merlin' + } + # disk commands + { + captures: + 1: name: 'support.function.pseudo.merlin' + 2: name: 'string.quoted.other.path.merlin' + match: '\\b((?i:dsk|put|use|sav))\\s+(\\S*)' + name: 'meta.disk.directive.merlin' + } + # cycle count + { + captures: + 1: name: 'support.function.pseudo.merlin' + 2: name: 'constant.language.merlin' + match: '\\b((?i:cyc))\\s+((?i:on|off|ave))\\b' + name: 'meta.cyc.directive.merlin' + } + # expand control + { + captures: + 1: name: 'support.function.pseudo.merlin' + 2: name: 'constant.language.merlin' + match: '\\b((?i:exp))\\s+((?i:on|off|only))\\b' + name: 'meta.exp.directive.merlin' + } + # list control + { + captures: + 1: name: 'support.function.pseudo.merlin' + 2: name: 'constant.language.merlin' + match: '\\b((?i:lst))\\s+((?i:off))\\b' + name: 'meta.exp.directive.merlin' + } + # truncation control + { + captures: + 1: name: 'support.function.pseudo.merlin' + 2: name: 'constant.language.merlin' + match: '\\b((?i:tr))\\s+((?i:on|off|adr))\\b' + name: 'meta.tr.directive.merlin' + } + # string command + { + captures: + 1: name: 'support.function.pseudo.merlin' + 2: name: 'string.delimited.begin.merlin' + 3: name: 'string.delimited.merlin' + 4: name: 'string.delimited.end.merlin' + 5: name: 'constant.numeric.hex.merlin' + match: '\\b((?i:asc|dci|inv|fls|str))\\s+(\\S)(.*?)(\\2|\\S),([a-fA-F0-9]+)?' + } + # reverse command + { + captures: + 1: name: 'support.function.pseudo.merlin' + 2: name: 'string.delimited.begin.merlin' + 3: name: 'string.delimited.merlin' + 4: name: 'string.delimited.end.merlin' + match: '\\b((?i:rev))\\s+(\\S)(.*?)(\\2|$)' + } + # hex command + { + begin: '\\b((?i:hex))\\b' + captures: + 1: + name: 'support.function.pseudo.merlin' + end: '$' + name: 'meta.hex.directive.merlin' + patterns: [ + # hex without $ + { + match: '\\b[a-fA-F0-9]{1,2}\\b' + name: 'constant.numeric.hex.merlin' + } + # semicolon comments + { + match: ';.*' + name: 'comment.line.semicolon.merlin' + } + # number check + { + match: '(?!,)\\S' + name: 'invalid.illegal.merlin' + } + ] } ] - } - { - 'match': '\\b(?i:DSK|EQU|EXT|ENT|ORG|REL|OBJ|PUT|USE|VAR|SAV|TYP|END|DUM|DEND|AST|CYC|DAT|EXP|LST|LSTDO|PAG|TTL|SKP|TR|CHK|ERR|KBD|LUP|--\\^|MX|PAU|SW|USR|XC)\\b' - 'name': 'keyword.directive' - } - { - 'match': '\\b(?i:DA|DW|DDB|DB|DFB|ADR|ADRL|HEX|DS|ASC|DCI|INV|FLS|REV|STR)\\b' - 'name': 'keyword.directive.data' - } - { - 'match': '\\b(?i:DO|ELSE|IF|FIN)\\b' - 'name': 'keyword.control.conditional' - } - { - 'match': '\\b(?i:MAC)\\b|<<<' - 'name': 'keyword.directive.macro' - } - { - 'match': '[-+/*^><|#\\[\\](),=.!&]' - 'name': 'keyword.operator' - } -] -'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.merlin' diff --git a/grammars/merlin_old.cson b/grammars/merlin_old.cson index d412eaa..210b21a 100644 --- a/grammars/merlin_old.cson +++ b/grammars/merlin_old.cson @@ -225,4 +225,4 @@ 'octal_number': 'match': '@([0-7]+)\\b' 'name': 'constant.numeric.octal' -'scopeName': 'source.assembly.65816.merlin' +'scopeName': 'source.assembly.65816.merlinold' From eefb3ddffaef46f6e6cd8bef237417408fc1ed33 Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Fri, 8 Jun 2018 03:31:19 +0200 Subject: [PATCH 06/11] Remove duplicate files --- grammars/6502 Assembly (DASM) OLD.cson | 65 ------- grammars/error-multiscope.cson | 23 --- grammars/error-test.cson | 133 --------------- grammars/merlin_old.cson | 228 ------------------------- 4 files changed, 449 deletions(-) delete mode 100644 grammars/6502 Assembly (DASM) OLD.cson delete mode 100644 grammars/error-multiscope.cson delete mode 100644 grammars/error-test.cson delete mode 100644 grammars/merlin_old.cson diff --git a/grammars/6502 Assembly (DASM) OLD.cson b/grammars/6502 Assembly (DASM) OLD.cson deleted file mode 100644 index 625bb4e..0000000 --- a/grammars/6502 Assembly (DASM) OLD.cson +++ /dev/null @@ -1,65 +0,0 @@ -'fileTypes': [] -'foldingStartMarker': '/\\*\\*|\\{\\s*$' -'foldingStopMarker': '\\*\\*/|^\\s*\\}' -'name': '6502 Assembly (DASM) OLD' -'patterns': [ - { - 'match': '\\b(adc|and|asl|bit|clc|cld|cli|clv|cmp|cpx|cpy|dec|dex|dey|eor|inc|inx|iny|lda|ldx|ldy|lsr|nop|ora|pha|php|pla|plp|rol|ror|sbc|sec|sed|sei|sta|stx|sty|tax|txa|tay|tya|tsx|txs)\\b' - 'name': 'keyword' - } - { - 'match': '\\b(bcc|bcs|beq|bmi|bne|bpl|brk|bvc|bvs|jmp|jsr|rti|rts)\\b' - 'name': 'keyword.control' - } - { - 'captures': - '1': - 'name': 'punctuation.definition.comment' - 'match': '(;).*$\\n?' - 'name': 'comment.line.semicolon' - } - { - 'match': '\\b(SET|WORD|BYTE|HEX)\\b' - 'name': 'storage.type' - } - { - 'match': '\\b(ALIGN)\\b' - 'name': 'storage.modifier' - } - { - 'match': '\\b(REPEAT|REPEND|MAC|ENDM|SUBROUTINE)\\b' - 'name': 'support.function' - } - { - 'match': '\\b(processor|org)\\b' - 'name': 'constant.language' - } - { - 'begin': '"' - 'end': '"' - 'name': 'string.quoted.double.untitled' - 'patterns': [ - { - 'match': '\\\\.' - 'name': 'constant.character.escape.untitled' - } - ] - } - { - 'match': '^[A-Za-z_][A-Za-z0-9_]*' - 'name': 'entity.name.label' - } - { - 'match': '^\\.[A-Za-z_][A-Za-z0-9_]*' - 'name': 'entity.name.label.local' - } - { - 'match': '#?\\$[0-9a-fA-F]+' - 'name': 'constant.numeric.hex' - } - { - 'match': '{[0-9]+}' - 'name': 'variable.parameter.macro' - } -] -'scopeName': 'source.assembly.6502.dasm' diff --git a/grammars/error-multiscope.cson b/grammars/error-multiscope.cson deleted file mode 100644 index e85120d..0000000 --- a/grammars/error-multiscope.cson +++ /dev/null @@ -1,23 +0,0 @@ -scopeName: 'source.multi1' -patterns: [ - { include: '#binnum' } - { include: '#hexnum' } -] - -repository: - # Binary numbers - binnum: - patterns: [ - { - match: '%[01]+' - name: 'constant.numeric.binary.multi1' - } - ] - - hexnum: - patterns: [ - { - match: '\\$[a-zA-Z0-9]+\\b' - name: 'constant.numeric.binary.multi1' - } - ] diff --git a/grammars/error-test.cson b/grammars/error-test.cson deleted file mode 100644 index 7c54391..0000000 --- a/grammars/error-test.cson +++ /dev/null @@ -1,133 +0,0 @@ -# Generic 65C02 grammar with semicolon comments - -scopeName: 'source.assembly.6502.6502-test' -fileTypes: [] -name: '6502 TEST' -patterns: [ - # { include: 'source.65c02-opcodes' } # include 6502 and 65c02 opcodes - # { include: 'source.6502x-opcodes' } - # { include: '#comments' } - # { include: '#symbols' } - { include: '#labels' } - { include: 'source.multi1' } - # { include: 'source.multi2' } -] - -# Repository starts here ------------------------------------------------------ -repository: - - # Basic line format - line_processor: - patterns: [ - ] - - # Labels - labels: - patterns: [ - # Variables - { - match: '^][:-~][0-~]+' - name: 'entity.name.variable.6502-test' - } - # Local labels and variables - { - match: '^:[:-~][0-~]+' - # name: 'entity.name.label.function.6502-test' - name: 'entity.name.label.local.6502-test' - # name: 'constant.numeric.hex.6502-test' - } - # Global labels - { - match: '^[:-~][0-~]+' - name: 'entity.name.label.function.6502-test' - } - ] - # Lines that start with an asterisk are comment lines - # commands within strings - # { - # begin: '"' - # end: '"' - # name: 'string.quoted.double' - # patterns: [ - # { include: 'source.65c02-opcodes' } - # ] - # } - # # four line word - # { - # begin: '^(\\w*)\\s+\\b' - # beginCaptures: - # 1: - # name: 'invalid.illegal.6502-test' - # end: ';.*' - # endCaptures: - # 0: - # name: 'comment.line.semicolon.6502-test' - # name: 'constant.numeric.hex.6502-test' - # } - # four word line - # { - # # match: '^(\\w*)\\b\\s+(\\w*)\\b\\s+(\\w*)\\b\\s+(\\w*)\\b' - # match: '^(\\w*)\\s+(\\1)\\s+(\\1)\\b' - # captures: - # 1: - # name: 'invalid.illegal.6502-test' - # 2: - # name: 'keyword.mnemonic.6502-test' - # 3: - # name: 'constant.numeric.hex.6502-test' - # 4: - # name: 'comment.line.semicolon.6502-test' - # name: "meta.line_processor.6502-test" - # } - # ] - - # comments - # comments: - # patterns: [ - # # semicolon comments - # { - # match: ';.*$' - # name: 'comment.line.semicolon.6502-test' - # } - # ] - - # symbols - # symbols: - # patterns: [ - # { - # begin: '"' - # beginCaptures: - # 0: - # name: 'punctuation.definition.string.begin.6502-test' - # end: '"' - # endCaptures: - # 0: - # name: 'punctuation.definition.string.end.6502-test' - # name: 'string.quoted.double.assembly.6502-test' - # } - # # absolut address/number - # { - # match: '\\#(\'.\'|[^\\s\']+)' - # name: 'constant.numeric.hex.6502-test' - # } - # # hex, prefixed with ampersand($) - # { - # match: '-?\\$[A-Fa-f0-9]+' - # name: 'constant.numeric.hex.6502-test' - # } - # # hex, suffixed with h(h) - # { - # match: '-?([0-9]+)h' - # name: 'constant.numeric.hex.6502-test' - # } - # # binary - # { - # match: '%[01]+' - # name: 'constant.numeric.binary.6502-test' - # } - # # decimal - # { - # match: '\\b([0-9]+)\\b' - # name: 'constant.numeric.decimal.6502-test' - # } - # ] diff --git a/grammars/merlin_old.cson b/grammars/merlin_old.cson deleted file mode 100644 index 210b21a..0000000 --- a/grammars/merlin_old.cson +++ /dev/null @@ -1,228 +0,0 @@ -'fileTypes': [] -'name': 'Merlin OLD' -'patterns': [ - { - 'include': '#M6502' - } - { - 'include': '#M65C02' - } - { - 'include': '#M65816' - } - { - 'include': '#M65816L' - } - { - 'include': '#hex_number' - } - { - 'include': '#decimal_number' - } - { - 'match': '%[01][01_]*' - 'name': 'constant.numeric.binary' - } - { - 'match': '\\b(?i:TAS|TSA|SWA|TAD|TDA|BLT|BGE)\\b' - 'name': 'keyword.mnemonic.65816.alt' - } - { - 'match': '(?<=,)([xXyYsS])\\b' - 'name': 'variable.language.register' - } - { - 'begin': '"' - 'end': '"' - 'name': 'string.quoted.double' - } - { - 'begin': '\'' - 'end': '\'' - 'name': 'string.quoted.single' - } - { - 'match': '^[*].*' - 'name': 'comment.line' - } - { - 'match': ';.*' - 'name': 'comment.line' - } - { - 'match': '^][0-~]*\\b' - 'name': 'entity.name.label.variable' - } - { - 'match': '^:[0-~]*\\b' - 'name': 'entity.name.label.local' - } - { - 'match': '^[:-~][0-~]*\\b' - 'name': 'entity.name.function' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'string.quoted.other.path' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)DSK|PUT|USE|SAV)\\s+(\\S*)' - 'name': 'meta.path.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)CYC)\\s+((?i)ON|OFF|AVE)\\b' - 'name': 'meta.cyc.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)EXP)\\s+((?i)ON|OFF|ONLY)\\b' - 'name': 'meta.exp.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)LST)\\s+((?i)ON|OFF|RTN)\\b' - 'name': 'meta.lst.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)LST)\\s+((?i)OFF)\\b' - 'name': 'meta.lstdo.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive' - '2': - 'name': 'constant.language' - 'comment': 'eg: KEEP pathname' - 'match': '\\b((?i)TR)\\s+((?i)ON|OFF|ADR)\\b' - 'name': 'meta.tr.directive' - } - { - 'captures': - '1': - 'name': 'keyword.directive.string' - '2': - 'name': 'string.delimited.begin' - '3': - 'name': 'string.delimited' - '4': - 'name': 'string.delimited.end' - '5': - 'name': 'keyword.operator' - '6': - 'name': 'constant.numeric.hexadecimal' - 'comment': 'optional trailing hex data' - 'match': '\\b((?i)ASC|DCI|INV|FLS|STR)\\s+(\\S)(.*?)(\\2|$)(,([0-9A-Fa-f]+))?' - 'name': 'meta.string.delimited' - } - { - 'captures': - '1': - 'name': 'keyword.directive.string' - '2': - 'name': 'string.delimited.begin' - '3': - 'name': 'string.delimited' - '4': - 'name': 'string.delimited.end' - 'match': '\\b((?i)REV)\\s+(\\S)(.*?)(\\2|$)' - 'name': 'meta.string.delimited.rev' - } - { - 'begin': '\\b((?i)HEX)\\b' - 'captures': - '1': - 'name': 'keyword.directive.data' - 'comment': 'HEX has a list of hex bytes w/o the $' - 'end': '$' - 'name': 'meta.hex' - 'patterns': [ - { - 'match': '\\b[0-9A-Fa-f]{1,2}\\b' - 'name': 'constant.numeric.hex' - } - { - 'match': ';.*$' - 'name': 'comment.line' - } - { - 'match': ',' - 'name': 'keyword.operator' - } - { - 'match': '\\S' - 'name': 'invalid.illegal' - } - ] - } - { - 'match': '\\b(?i:DSK|EQU|EXT|ENT|ORG|REL|OBJ|PUT|USE|VAR|SAV|TYP|END|DUM|DEND|AST|CYC|DAT|EXP|LST|LSTDO|PAG|TTL|SKP|TR|CHK|ERR|KBD|LUP|--\\^|MX|PAU|SW|USR|XC)\\b' - 'name': 'keyword.directive' - } - { - 'match': '\\b(?i:DA|DW|DDB|DB|DFB|ADR|ADRL|HEX|DS|ASC|DCI|INV|FLS|REV|STR)\\b' - 'name': 'keyword.directive.data' - } - { - 'match': '\\b(?i:DO|ELSE|IF|FIN)\\b' - 'name': 'keyword.control.conditional' - } - { - 'match': '\\b(?i:MAC)\\b|<<<' - 'name': 'keyword.directive.macro' - } - { - 'match': '[-+/*^><|#\\[\\](),=.!&]' - 'name': 'keyword.operator' - } -] -'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.merlinold' From b23fafac4ad2a15ef0be893a18e5cd9cf6c0e287 Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Tue, 12 Jun 2018 07:02:05 +0200 Subject: [PATCH 07/11] Improve cc65 support with new grammar for linker config files --- README.md | 2 +- grammars/cc65-directives.cson | 33 +++++----- grammars/cc65-linker-config.cson | 101 +++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 15 deletions(-) create mode 100644 grammars/cc65-linker-config.cson diff --git a/README.md b/README.md index 38bc5aa..9379d37 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Adds syntax highlighting to 65816/65C816/65802/6502/65C02 files in Atom, with extra support for various compilers: - [ACME Crossassembler](https://sourceforge.net/projects/acme-crossass/) - - [cc65 (SNES Syntax: 65816, SPC700, SuperFX)](http://oliverschmidt.github.io/cc65/) + - [cc65 (SNES Syntax: 65816, SPC700, SuperFX)](https://github.com/cc65/cc65) - [DASM](http://dasm-dillon.sourceforge.net/) (6502) - [EDASM](https://archive.org/details/EDASM-ProDOS_Assembler_Tools_Manual) - [Merlin](http://en.wikipedia.org/wiki/Merlin_(assembler)) diff --git a/grammars/cc65-directives.cson b/grammars/cc65-directives.cson index c067235..16de046 100644 --- a/grammars/cc65-directives.cson +++ b/grammars/cc65-directives.cson @@ -48,7 +48,7 @@ repository: } # hex, suffixed with h(h) { - match: '-?\\b([a-fA-F0-9]+)h' + match: '-?\\b([a-fA-F0-9]+)h\\b' name: 'constant.numeric.hex.cc65-directives' } # binary @@ -68,43 +68,48 @@ repository: patterns: [ # ca65 pseudo variables { - match: '(\\.)?\\b(?i:\\*|asize|cpu|isize|paramcount|time|version)\\b' + match: '(\\.)\\b(?i:\\*|asize|cpu|isize|paramcount|time|version)\\b' name: 'support.function.pseudo.cc65-directives' } # ca65 pseudo functions { - match: '(\\.)?\\b(?i:addrsize|bank(byte)?|blank|con(cat|st)|(hi|lo)(byte|word)|ident|left|x?match|max|mi[dn]|ref(erenced)?|right|sizeof|strat|sprintf|str(ing|len)|tcount)\\b' + match: '(\\.)\\b(?i:addrsize|bank(byte)?|blank|con(cat|st)|(hi|lo)(byte|word)|ident|left|x?match|max|mi[dn]|ref(erenced)?|right|sizeof|strat|sprintf|str(ing|len)|tcount)\\b' name: 'support.function.pseudo.cc65-directives' } # ca65 control commands, A through C { - match: '(\\.)?\\b(?i:a(8|16)|addr|align|asciiz|assert|autoimport|(bank|hi)bytes|bss|byte?|case|charmap|code|condes|(con|de)structor)\\b' - name: 'storage.modifier.cc65-directives' + match: '(\\.)\\b(?i:a(8|16)|addr|align|asciiz|assert|autoimport|(bank|hi)bytes|bss|byte?|case|charmap|code|condes|(con|de)structor)\\b' + name: 'support.function.pseudo.cc65-directives' } # ca65 control commands, D and E { - match: '(\\.)?\\b(?i:data|dbyt|debuginfo|define|delmac(ro)?|def(ined(macro)?)?|dword|else(if)?|end(enum)?|end(enum|if|proc|rep(eat)?|scope|struct|union)?|endmac(ro)?|enum|error|exitmac(ro)?|export(zp)?)\\b' - name: 'storage.modifier.cc65-directives' + match: '(\\.)\\b(?i:data|dbyt|debuginfo|define|delmac(ro)?|def(ined(macro)?)?|dword|else(if)?|end(enum)?|end(enum|if|proc|rep(eat)?|scope|struct|union)?|endmac(ro)?|enum|error|exitmac(ro)?|export(zp)?)\\b' + name: 'support.function.pseudo.cc65-directives' } # ca65 control commands, F through I { - match: '(\\.)?\\b(?i:faraddr|fatal|feature|f(ile)?opt|forceimport|global(zp)?|i(8|16)|if((n)?blank|const|(n)?def|(n)?ref|p02|p4510|p816|p(s)?c02)?|import(zp)?|inc(bin|lude)|interruptor|ismnem(onic)?)\\b' - name: 'storage.modifier.cc65-directives' + match: '(\\.)\\b(?i:faraddr|fatal|feature|f(ile)?opt|forceimport|global(zp)?|i(8|16)|if((n)?blank|const|(n)?def|(n)?ref|p02|p4510|p816|p(s)?c02)?|import(zp)?|inc(bin|lude)|interruptor|ismnem(onic)?)\\b' + name: 'support.function.pseudo.cc65-directives' } # ca65 control commands, L through R { - match: '(\\.)?\\b(?i:linecont|list(bytes)?|lobytes|local(char)?|macpack|mac(ro)?|org|out|p02|p4510|p816|pagelen(gth)?|pc02|pop(cpu|seg)|proc|psc02|push(cpu|seg)|reloc|repeat|res|rodata)\\b' - name: 'storage.modifier.cc65-directives' + match: '(\\.)\\b(?i:linecont|list(bytes)?|lobytes|local(char)?|macpack|mac(ro)?|org|out|p02|p4510|p816|pagelen(gth)?|pc02|pop(cpu|seg)|proc|psc02|push(cpu|seg)|reloc|repeat|res|rodata)\\b' + name: 'support.function.pseudo.cc65-directives' } # ca65 control commands, S through Z { - match: '(\\.)?\\b(?i:scope|segment|set(cpu)?|smart|struct|tag|undef(ine)?|union|warning|word|zeropage)\\b' - name: 'storage.modifier.cc65-directives' + match: '(\\.)\\b(?i:scope|segment|set(cpu)?|smart|struct|tag|undef(ine)?|union|warning|word|zeropage)\\b' + name: 'support.function.pseudo.cc65-directives' } # CPU constants { match: '\\b(CPU_6502|CPU_65SC02|CPU_65C02|CPU_65816|CPU_SWEET16|CPU_HUC6280|CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02|CPU_ISET_65816|CPU_ISET_SWEET16|CPU_ISET_HUC6280|__APPLE2__|__APPLE2ENH__|__ATARI__|__ATARIXL__|__ATMOS__|__BBC__|__C128__|__C16__|__C64__|__CBM__|__CBM510__|__CBM610__|__GEOS__|__GEOS_APPLE__|__GEOS_CBM__|__LUNIX__|__LYNX__|__NES__|__PET__|__PLUS4__|__SIM6502__|__SIM65C02__|__SUPERVISION__|__VIC20__)\\b' - name: 'constant.other.cc65-directives' + name: 'constant.language.cc65-directives' + } + # address sizes, macpack packages + { + match: '\\b(?i:direct|zeropage|zp|absolute|abs|near|far|long|dword|atari|cbm|cpu|generic|longbranch)\\b' + name: 'constant.language.cc65-directives' } # Operators { diff --git a/grammars/cc65-linker-config.cson b/grammars/cc65-linker-config.cson new file mode 100644 index 0000000..93b50fc --- /dev/null +++ b/grammars/cc65-linker-config.cson @@ -0,0 +1,101 @@ +# Syntax Highlighting for linker config files used with ld65 of the cc65 toolchain + +scopeName: 'source.assembly.cc65-linker-config' +name: 'Linker Config File (cc65)' # Name shown in Atom Editor grammar selection +# File extensions associated with this grammar +fileTypes: [ + 'cfg' + 'txt' +] +# include all directives and commands the toolchain supports +patterns: [ + { include: '#comments' } + { include: '#symbols' } +] + +# Repository starts here ------------------------------------------------------ +repository: + + # comments + comments: + patterns: [ + # hash comments + { + match: '\\#.*$' + name: 'comment.line.cc65-linker-config' + } + ] + + # symbols + symbols: + patterns: [ + # strings + { + begin: '"' + beginCaptures: + 0: + name: 'punctuation.definition.string.begin.cc65-linker-config' + end: '"' + endCaptures: + 0: + name: 'punctuation.definition.string.end.cc65-linker-config' + name: 'string.quoted.double.cc65-linker-config' + } + # hex, prefixed with dollar sign($) + { + match: '-?\\$\\b[a-fA-F0-9]+\\b' + name: 'constant.numeric.hex.cc65-linker-config' + } + # hex, suffixed with h(h) + { + match: '-?\\b([a-fA-F0-9]+)h\\b' + name: 'constant.numeric.hex.cc65-linker-config' + } + # binary + { + match: '%[01]+' + name: 'constant.numeric.binary.cc65-linker-config' + } + # decimal + { + match: '\\b([0-9]+)\\b' + name: 'constant.numeric.decimal.cc65-linker-config' + } + # areas + { + match: '\\b(?i:memory|segments|files|formats|features|symbols|once|lowcode|startup|zpsave)\\b' + name: 'storage.modifier.cc65-linker-config' + } + # labels + { + captures: + 1: name: 'entity.name.function.label.cc65-linker-config' + match: '\\b([A-Za-z0-9_]+):' + name: 'meta.function.label.cc65-linker-config' + } + # attributes + { + match: '\\b(?i:load|type|define|start|size|fill|file|run|format|os|version|import|export|label|count|segment|order|default|addrsize)\\b' + name: 'storage.modifier.cc65-linker-config' + } + # linker constants + { + match: '\\b(__NAME_LOAD__|__NAME_RUN__|__NAME_SIZE__|__DATA_LOAD__|__DATA_RUN__|__DATA_SIZE__|__STACK_START__|__STACK_SIZE__|__STACK_LAST__|__STACK_FILEOFFS__)\\b' + name: 'constant.language.cc65-directives' + } + # address sizes, functions + { + match: '\\b(?i:direct|zeropage|zp|absolut|abs|near|far|long|dword|atari|cbm|cpu|generic|longbranch|yes|ro|rw|bss)\\b' + name: 'constant.other.cc65-directives' + } + # case sensitive symbols + { + match: '\\b(\\%\\bO|o65)\\b' + name: 'constant.other.cc65-directives' + } + # operators + { + match: '=' + name: 'keyword.operator.cc65-directives' + } + ] From 1e605edeb41f08caef5ca6c12ce8e5f951ae522f Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Tue, 12 Jun 2018 07:55:37 +0200 Subject: [PATCH 08/11] Add missing commands, opcodes, constants --- grammars/cc65-directives.cson | 2 +- grammars/cc65-linker-config.cson | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/grammars/cc65-directives.cson b/grammars/cc65-directives.cson index 16de046..7ab35b0 100644 --- a/grammars/cc65-directives.cson +++ b/grammars/cc65-directives.cson @@ -103,7 +103,7 @@ repository: } # CPU constants { - match: '\\b(CPU_6502|CPU_65SC02|CPU_65C02|CPU_65816|CPU_SWEET16|CPU_HUC6280|CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02|CPU_ISET_65816|CPU_ISET_SWEET16|CPU_ISET_HUC6280|__APPLE2__|__APPLE2ENH__|__ATARI__|__ATARIXL__|__ATMOS__|__BBC__|__C128__|__C16__|__C64__|__CBM__|__CBM510__|__CBM610__|__GEOS__|__GEOS_APPLE__|__GEOS_CBM__|__LUNIX__|__LYNX__|__NES__|__PET__|__PLUS4__|__SIM6502__|__SIM65C02__|__SUPERVISION__|__VIC20__)\\b' + match: '\\b(CPU_6502|CPU_65SC02|CPU_65C02|CPU_65816|CPU_SWEET16|CPU_HUC6280|CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02|CPU_ISET_65816|CPU_ISET_SWEET16|CPU_ISET_HUC6280|__APPLE2__|__APPLE2ENH__|__ATARI__|__ATARIXL__|__ATMOS__|__BBC__|__C128__|__C16__|__C64__|__CBM__|__CBM510__|__CBM610__|__GEOS__|__GEOS_APPLE__|__GEOS_CBM__|__LUNIX__|__LYNX__|__NES__|__PET__|__PLUS4__|__SIM6502__|__SIM65C02__|__SUPERVISION__|__VIC20__|VER_MAJOR|VER_MINOR)\\b' name: 'constant.language.cc65-directives' } # address sizes, macpack packages diff --git a/grammars/cc65-linker-config.cson b/grammars/cc65-linker-config.cson index 93b50fc..115095d 100644 --- a/grammars/cc65-linker-config.cson +++ b/grammars/cc65-linker-config.cson @@ -43,12 +43,12 @@ repository: } # hex, prefixed with dollar sign($) { - match: '-?\\$\\b[a-fA-F0-9]+\\b' + match: '\\$\\b[a-fA-F0-9]+\\b' name: 'constant.numeric.hex.cc65-linker-config' } # hex, suffixed with h(h) { - match: '-?\\b([a-fA-F0-9]+)h\\b' + match: '\\b([a-fA-F0-9]+)h\\b' name: 'constant.numeric.hex.cc65-linker-config' } # binary @@ -81,21 +81,21 @@ repository: # linker constants { match: '\\b(__NAME_LOAD__|__NAME_RUN__|__NAME_SIZE__|__DATA_LOAD__|__DATA_RUN__|__DATA_SIZE__|__STACK_START__|__STACK_SIZE__|__STACK_LAST__|__STACK_FILEOFFS__)\\b' - name: 'constant.language.cc65-directives' + name: 'constant.language.cc65-linker-config' } # address sizes, functions { - match: '\\b(?i:direct|zeropage|zp|absolut|abs|near|far|long|dword|atari|cbm|cpu|generic|longbranch|yes|ro|rw|bss)\\b' - name: 'constant.other.cc65-directives' + match: '\\b(?i:direct|zeropage|zp|absolut|abs|near|far|long|dword|atari|cbm|cpu|generic|longbranch|yes|ro|rw|bss|weak)\\b' + name: 'constant.other.cc65-linker-config' } # case sensitive symbols { - match: '\\b(\\%\\bO|o65)\\b' - name: 'constant.other.cc65-directives' + match: '(%\\bO|\\bo65)\\b' + name: 'constant.other.cc65-linker-config' } # operators { match: '=' - name: 'keyword.operator.cc65-directives' + name: 'keyword.operator.cc65-linker-config' } ] From bc4ce09e84d6f6ef0f0f5fb2aeb30047af3b4591 Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Tue, 12 Jun 2018 09:51:53 +0200 Subject: [PATCH 09/11] Add asar support --- README.md | 1 + grammars/asar.cson | 196 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 grammars/asar.cson diff --git a/README.md b/README.md index 9379d37..f43e29c 100755 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Adds syntax highlighting to 65816/65C816/65802/6502/65C02 files in Atom, with extra support for various compilers: - [ACME Crossassembler](https://sourceforge.net/projects/acme-crossass/) + - [Asar SNES Assembler](https://github.com/RPGHacker/asar) - [cc65 (SNES Syntax: 65816, SPC700, SuperFX)](https://github.com/cc65/cc65) - [DASM](http://dasm-dillon.sourceforge.net/) (6502) - [EDASM](https://archive.org/details/EDASM-ProDOS_Assembler_Tools_Manual) diff --git a/grammars/asar.cson b/grammars/asar.cson new file mode 100644 index 0000000..ab80250 --- /dev/null +++ b/grammars/asar.cson @@ -0,0 +1,196 @@ +# Adds Syntax highlighting for the Asar SNES Assembler + +scopeName: 'source.assembly.65816.asar' +fileTypes: [ + 'asm' +] +name: 'Asar SNES Assembler' +patterns: [ + { include: 'source.65816-opcodes' } + { include: 'source.65816l-opcodes' } + { include: 'source.65816alt-opcodes' } + { include: '#comments' } + { include: '#symbols' } + { include: '#directives' } +] + +# Repository starts here ------------------------------------------------------ +repository: + + # comments + comments: + patterns: [ + # semicolon line comment + { + match: ';.*$' + name: 'comment.line.semicolon.asar' + } + ] + + # symbols + symbols: + patterns: [ + # delimited strings + { + begin: '"' + beginCaptures: + 0: name: 'punctuation.definition.string.begin.asar' + end: '"' + endCaptures: + 0: name: 'punctuation.definition.string.end.asar' + name: 'string.quoted.double.assembly.asar' + } + # labels + { + captures: + 1: name: 'entity.name.function.label.asar' + 2: name: 'entity.name.function.label.asar' + match: '(\\.*)\\b([A-Za-z0-9_]+):' + name: 'meta.label.asar' + } + # defines + { + captures: + 1: name: 'keyword.operator.asar' + 2: name: 'entity.name.function.label.asar' + match: '(!)\\b([A-Za-z0-9_]+)\\b' + name: 'meta.define.asar' + } + # absolut address/number + { + match: '\\#(\'.\'|[^\\s\']+)' + name: 'constant.numeric.hex.asar' + } + # hex, prefixed with ampersand($) + { + match: '-?\\$[A-Fa-f0-9]+' + name: 'constant.numeric.hex.asar' + } + # binary + { + match: '-?%[01]+' + name: 'constant.numeric.binary.asar' + } + # decimal + { + match: '-?\\b([0-9]+)\\b' + name: 'constant.numeric.decimal.asar' + } + ] + + # assembler directives + directives: + patterns: [ + # arch command + { + captures: + 1: name: 'support.function.pseudo.asar' + 2: name: 'constant.language.asar' + match: '\\b(arch)\\s+(65816|spc700(-inline)?|superfx)' + name: 'meta.arch.directive.asar' + } + # warn xkas command + { + captures: + 1: name: 'support.function.pseudo.asar' + 2: name: 'support.function.pseudo.asar' + 3: name: 'constant.language.asar' + match: '\\b(warn)\\s+(xkas)\\s+(on|off)\\b' + name: 'meta.warn.directive.asar' + } + # math command + { + captures: + 1: name: 'support.function.pseudo.asar' + 2: name: 'support.function.pseudo.asar' + 3: name: 'constant.language.asar' + match: '\\b(math)\\s+(pri|round)\\s+(on|off)\\b' + name: 'meta.math.directive.asar' + } + # namespace command + { + begin: '\\b(namespace)\\b' + captures: + 1: + name: 'support.function.pseudo.asar' + end: '$' + name: 'meta.namespace.directive.asar' + patterns: [ + # nested + { + captures: + 1: name: 'support.function.pseudo.asar' + 2: name: 'constant.language.asar' + match: '\\b(nested)\\s+(on|off)\\b' + name: 'meta.namespace.nested.asar' + } + # off + { + match: '\\b(off)\\b' + name: 'constant.language.asar' + } + # identifier + { + match: '\\b[a-zA-Z0-9_]+\\b' + name: 'entity.name.function.label.asar' + } + ] + } + # base command + { + captures: + 1: name: 'support.function.pseudo.asar' + 2: name: 'constant.language.asar' + match: '\\b(base)\\s+(off)*' + name: 'meta.base.directive.asar' + } + # bank command + { + captures: + 1: name: 'support.function.pseudo.asar' + 2: name: 'constant.language.asar' + match: '\\b(bank)\\s+(noassume|auto)*' + name: 'meta.bank.directive.asar' + } + # struct command + { + captures: + 1: name: 'support.function.pseudo.asar' + 2: name: 'entity.name.function.label.asar' + 3: name: 'constant.numeric.hex.asar' + match: '\\b(struct)\\s+([a-zA-Z0-9_]+)\\s+(\\S+)\\b' + name: 'meta.struct.directive.asar' + } + # endstruct command + { + captures: + 1: name: 'support.function.pseudo.asar' + 2: name: 'support.function.pseudo.asar' + 3: name: 'constant.numeric.decimal.asar' + match: '\\b(endstruct)\\s+(align)*\\s+(\\S+)*' + name: 'meta.struct.directive.asar' + } + # data control + { + match: '\\b(inc(bin|src)|(push|pull)(pc|base)|warnpc|skip|asar|org|rep|d[bdlw]|(ex)?(lo|hi)rom|(full)?sa1rom|(no|sfx)rom|function)\\b' + name: 'support.function.pseudo.asar' + } + # conditional control + { + match: '\\b((end)?if)\\b' + name: 'keyword.control.conditional.asar' + } + # macro control + # TODO: fix identifier + { + match: '\\b((end)?macro)\\b' + # name: 'support.function.pseudo.asar' + name: 'keyword.directive.macro.asar' + } + # operators + { + match: '[-+/*^><|#\\[\\](),=.!&]' + name: 'keyword.operator.asar' + } + # TODO: Add built-in functions + ] From 194a96a3cd565ccaf598efb152dcbc1740af382d Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Tue, 12 Jun 2018 17:22:39 +0200 Subject: [PATCH 10/11] Add missing keyword --- grammars/cc65-linker-config.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/cc65-linker-config.cson b/grammars/cc65-linker-config.cson index 115095d..e9cd2ed 100644 --- a/grammars/cc65-linker-config.cson +++ b/grammars/cc65-linker-config.cson @@ -75,7 +75,7 @@ repository: } # attributes { - match: '\\b(?i:load|type|define|start|size|fill|file|run|format|os|version|import|export|label|count|segment|order|default|addrsize)\\b' + match: '\\b(?i:load|type|define|start|size|fill|file|run|format|os|version|import|export|label|count|segment|order|default|addrsize|align)\\b' name: 'storage.modifier.cc65-linker-config' } # linker constants From d7c010e8aa0b448823ec8812e9eca724e75d661b Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Thu, 21 Jun 2018 06:40:54 +0200 Subject: [PATCH 11/11] Add SPC-700 and SuperFX opcodes --- grammars/asar.cson | 4 +++- grammars/spc700-opcodes.cson | 29 +++++++++++++++++++++++++++++ grammars/superfx-opcodes.cson | 29 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 grammars/spc700-opcodes.cson create mode 100644 grammars/superfx-opcodes.cson diff --git a/grammars/asar.cson b/grammars/asar.cson index ab80250..7fb5547 100644 --- a/grammars/asar.cson +++ b/grammars/asar.cson @@ -9,6 +9,8 @@ patterns: [ { include: 'source.65816-opcodes' } { include: 'source.65816l-opcodes' } { include: 'source.65816alt-opcodes' } + { include: 'source.spc700-opcodes' } + { include: 'source.superfx-opcodes' } { include: '#comments' } { include: '#symbols' } { include: '#directives' } @@ -189,7 +191,7 @@ repository: } # operators { - match: '[-+/*^><|#\\[\\](),=.!&]' + match: '[-+/*^><|#\\[\\]()=.!&]' name: 'keyword.operator.asar' } # TODO: Add built-in functions diff --git a/grammars/spc700-opcodes.cson b/grammars/spc700-opcodes.cson new file mode 100644 index 0000000..5ae8b8e --- /dev/null +++ b/grammars/spc700-opcodes.cson @@ -0,0 +1,29 @@ +# Opcodes for the Sony SPC-700 audio processing unit used in the SNES + +scopeName: 'source.spc700-opcodes' + +patterns: [ + # The SPC700 instruction set aliases + { + include: '#mnemonics-spc700' + } +] + +# Respository starts here ----------------------------------------------------- +repository: + + # SPC700 instruction set + 'mnemonics-spc700': + patterns: [ + # mnemonics + { + match: '\\b(?i:ADC|ADDW|AND|AND1|ASL|BBC|BBS|BCC|BCS|BEQ|BMI|BNE|BPL|BVC|BVS|BRA|BRK|CALL|CBNE|CLR1|CLRC|CLRP|CLRV|CMP|CMPW|DAA|DAS|DBNZ|DEC|DECW|DI|DIV|EI|EOR|EOR1|INC|INCW|JMP|LSR|MOV|MOV1|MOVW|MUL|NOP|NOT1|NOTC|OR|OR1|PCALL|POP|PUSH|RET|RETI|ROL|ROR|SBC|SET1|SETC|SETP|SLEEP|STOP|SUBW|TCALL|TCLR1|TSET1|XCN)\\b' + name: 'keyword.mnemonic.spc700.spc700-opcodes' + } + # registers + { + match: '\\b(?i:F[0-9A-F]|SP|PC|PSW)\\b' + name: 'support.function.pseudo.spc700-opcodes' + # name: 'storage.other.register.spc700-opcodes' + } + ] diff --git a/grammars/superfx-opcodes.cson b/grammars/superfx-opcodes.cson new file mode 100644 index 0000000..7ff9b87 --- /dev/null +++ b/grammars/superfx-opcodes.cson @@ -0,0 +1,29 @@ +# Opcodes for the SuperFX DSP used in some SNES cartridges + +scopeName: 'source.superfx-opcodes' + +patterns: [ + # The SPC700 instruction set aliases + { + include: '#mnemonics-superfx' + } +] + +# Respository starts here ----------------------------------------------------- +repository: + + # SuperFX instruction set + 'mnemonics-superfx': + patterns: [ + # mnemonics + { + match: '\\b(?i:ADD|ADC|ALT1|ALT2|ALT3|AND|ASR|BCC|BCS|BEQ|BGE|BIC|BLT|BMI|BNE|BPL|BRA|BVC|BVS|CACHE|CMODE|CMP|COLOR|DEC|DIV2|FMULT|FROM|GETB|GETBH|GETBL|GETBS|GETC|HIB|IBT|INC|IWT|JAL|JMP|LDB|LDW|LEA|LINK|LJMP|LM|LMS|LMULT|LOB|LOOP|LSR|MERGE|MOVE|MOVEB|MOVES|MOVEW|MULT|NOP|NOT|OR|PLOT|POP|PUSH|RAMB|RET|ROL|ROMB|ROR|RPIX|SBC|SBK|SEX|SM|SMS|STB|STOP|STW|SUB|SWAP|TO|UMULT|WITH|XOR)\\b' + name: 'keyword.mnemonic.superfx.superfx-opcodes' + } + # registers + { + match: '\\b(?i:R0|R1|R2|R3|R4|R5|R6|R7|R8|R9|R10|R11|R12|R13|R14|R15|SP|LR|PC|SFR|BRAMR|PBR|ROMBR|CFGR|SCBR|CLSR|SCMR|VCR|RAMBR|CBR)\\b' + name: 'support.function.pseudo.superfx-opcodes' + # name: 'storage.other.register.superfx-opcodes' + } + ]