From 90366d7d064ed728067056b356eb96c00c6a77c0 Mon Sep 17 00:00:00 2001 From: Georg Ziegler Date: Thu, 22 Mar 2018 22:03:41 +0100 Subject: [PATCH] Add WDCTools support --- grammars/6502-opcodes.cson | 10 --- grammars/65c02-opcodes.cson | 5 ++ grammars/cc65-directives.cson | 9 --- grammars/wdc-directives.cson | 122 +++++++++++++++++++++++++++++++++ grammars/wdc-toolchain.cson | 14 ++++ grammars/wdc816-toolchain.cson | 14 ++++ settings/language-65asm.cson | 36 +++++----- 7 files changed, 173 insertions(+), 37 deletions(-) create mode 100644 grammars/wdc-directives.cson create mode 100644 grammars/wdc-toolchain.cson create mode 100644 grammars/wdc816-toolchain.cson diff --git a/grammars/6502-opcodes.cson b/grammars/6502-opcodes.cson index 9461e41..f0a9a1a 100644 --- a/grammars/6502-opcodes.cson +++ b/grammars/6502-opcodes.cson @@ -23,13 +23,3 @@ repository: name: 'keyword.mnemonic.6502.6502-opcodes' } ] -# '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' -# 'M65816_alias': -# 'match': '\\b(?i:BGE|BLT|CPA|DEA|INA|SWA|TAD|TAS|TDA|TSA)\\b' -# 'name': 'keyword.mnemonic.65816_alias' -# 'M65C02': -# 'match': '\\b(?i:BRA|PHX|PHY|PLX|PLY|STP|STZ|TRB|TSB|WAI)\\b' -# 'name': 'keyword.mnemonic.65c02' -# 'scopeName': 'source.assembly.6502' diff --git a/grammars/65c02-opcodes.cson b/grammars/65c02-opcodes.cson index e0ecbfe..35b5980 100644 --- a/grammars/65c02-opcodes.cson +++ b/grammars/65c02-opcodes.cson @@ -25,4 +25,9 @@ repository: match: '\\b(?i:BRA|PHX|PHY|PLX|PLY|STP|STZ|TRB|TSB|WAI)\\b' name: 'keyword.mnemonic.65c02.65c02-opcodes' } + # additional opcodes for WDC chips + { + match: '\\b(?i:(BBR|BBS|RMB|SMB)[0-7])\\b' + name: 'keyword.mnemonic.65c02.65c02-opcodes' + } ] diff --git a/grammars/cc65-directives.cson b/grammars/cc65-directives.cson index 290544a..81c33ca 100644 --- a/grammars/cc65-directives.cson +++ b/grammars/cc65-directives.cson @@ -3,15 +3,6 @@ scopeName: 'source.cc65-directives' patterns: [ - # # The 65c02 instruction set - # { - # include: 'source.65c02-opcodes' - # } - # # Include the 6502ex op codes - # { - # include: 'source.6502x-opcodes' - # } - # The cc65 toolchain considers everything after a semicolon(;) as comment { include: '#comments' } diff --git a/grammars/wdc-directives.cson b/grammars/wdc-directives.cson new file mode 100644 index 0000000..9833f96 --- /dev/null +++ b/grammars/wdc-directives.cson @@ -0,0 +1,122 @@ +# Syntax Highlighting for the Western Design Center toolchain directives + +scopeName: 'source.wdc-directives' + +patterns: [ + { + include: '#comments' + } + # symbols, constants, numbers + { + include: '#symbols' + } + # directives + { + include: '#directives' + } +] + +# Repository starts here ------------------------------------------------------ +repository: + + # comments + comments: + patterns: [ + # semicolon comments + { + match: ';.*$' + name: 'comment.line.semicolon.wdc-toolchain' + } + ] + + # symbols + symbols: + patterns: [ + # strings + { + begin: '"' + beginCaptures: + 0: + name: 'punctuation.definition.string.begin.wdc-toolchain' + end: '"' + endCaptures: + 0: + name: 'punctuation.definition.string.end.wdc-toolchain' + name: 'string.quoted.double.assembly.wdc-toolchain' + } + # absolut addressing/numbering + { + match: '\\#(\'.\'|[^\\s\']+)' + name: 'constant.numeric.hex.wdc-toolchain' + } + # hex, prefixed with ampersand($) + { + match: '-?\\$[A-Fa-f0-9]+' + name: 'constant.numeric.hex.wdc-toolchain' + } + # hex, suffixed with h(h) + { + match: '-?([0-9]+)h' + name: 'constant.numeric.hex.wdc-toolchain' + } + # binary prefixed with % + { + match: '%[01]+' + name: 'constant.numeric.binary.wdc-toolchain' + } + # binary suffixed with B + { + match: '[01]+(?i:b)' + name: 'constant.numeric.binary.wdc-toolchain' + } + # octal and decimal + { + match: '\\b([0-9]+(d|o|q)?)\\b' + name: 'constant.numeric.decimal.wdc-toolchain' + } + ] + + # assembler directives + directives: + 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' + name: 'support.function.pseudo.wdc-toolchain' + } + # Parsing control + { + match: '\\b(?i:case|chip|chkimmed|comment|dbreg|dpage|long[ai]|radix|spaces|llchar|bit7|mask|squote|twochar|asc(ii)?|fcc|date|da|d?byte|d(ef)?b|fcb|string|dc|d(ef)?w|fdb|l?word|dl|longw?|blk[blw]|defs|ds(a|b|l|w)?|rmb|apwdc|float|double)\\b' + name: 'support.function.pseudo.wdc-toolchain' + } + # Macro control + { + match: '\\b(?i:macro|endm|macend|argchk|macfirst|macdelim|macexit|ifma|ifnma|rept|endr)\\b' + name: 'support.function.pseudo.wdc-toolchain' + } + # Conditional control + { + match: '\\b(?i:end(c|if)?|cond|ifn?(false|true|z|abs|rel|def|diff|same|ext|page0)?|if(long|short)[ai]|ifmatch|else)\\b' + name: 'keyword.control.conditional.wdc-toolchain' + } + # Listing control + { + match: '\\b(?i:pl|pw|top|heading|nam|title|s?ttl|subtitle|subttl|eject|page?|(no?)?list|(inc|asc|cond|m(ac)?|mn)list|pass1)\\b' + name: 'support.function.pseudo.wdc-toolchain' + } + # Pre-defined sections + { + match: '\\b(?i:page0|code|(k|u)?data)\\b' + name: 'constant.other.wdc-toolchain' + } + # Operators + { + match: '!|\\+|\\-|\\/|\\*|<<|>>|&|\\||\\^|=|<|>|\\:|\\|\\|' + name: 'keyword.operator.wdc-toolchain' + } + # Operators II + { + match: '\\b(?i:and|not|mod|sh[lr]|x?or|eq|u?[gl]t)\\b' + name: 'keyword.operator.wdc-toolchain' + } + ] diff --git a/grammars/wdc-toolchain.cson b/grammars/wdc-toolchain.cson new file mode 100644 index 0000000..ec03df5 --- /dev/null +++ b/grammars/wdc-toolchain.cson @@ -0,0 +1,14 @@ +# Syntax Highlighting for the Western Design Center toolchain and 6502 support +# TODO: extra addressing modes, chip point prefix, * comments + +scopeName: 'source.wdc-toolchain' +name: '6502 Assembly (WDCTools)' # 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.65c02-opcodes' } # the 65c02 opcodes, includes the basic 6502 instruction set + { include: 'source.wdc-directives' } # include the directives of the WDCxAS assemblers +] diff --git a/grammars/wdc816-toolchain.cson b/grammars/wdc816-toolchain.cson new file mode 100644 index 0000000..c997c13 --- /dev/null +++ b/grammars/wdc816-toolchain.cson @@ -0,0 +1,14 @@ +# Syntax Highlighting for the Western Design Center toolchain and 65816 support + +scopeName: 'source.wdc816-toolchain' +name: '65816 Assembly (WDCTools)' # 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' } # 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/settings/language-65asm.cson b/settings/language-65asm.cson index 137d861..9908f2e 100644 --- a/settings/language-65asm.cson +++ b/settings/language-65asm.cson @@ -1,18 +1,18 @@ -# '.source.assembly': -# 'editor': -# 'commentStart': ';' -# '.source.assembly.6502.edasm': -# 'editor': -# 'foldEndPattern': '\\b(?i:DEND|FIN)\\b' -# '.source.assembly.65816.mpw': -# 'editor': -# 'foldEndPattern': '\\b(?i:ENDF|ENDFUNC|ENDI|ENDP|ENDPROC|ENDR|ENDSTACK|ENDWITH|ENDM|ENDMACRO|MEND)\\b' -# '.source.assembly.65816.merlin': -# 'editor': -# 'foldEndPattern': '\\b(?i:DEND|FIN)\\b|<<<|--\\^' -# '.source.assembly.65816.ninjaforce': -# 'editor': -# 'foldEndPattern': '(\\^\\^\\^|\\<\\<\\<)' -# '.source.assembly.65816.orcam': -# 'editor': -# 'foldEndPattern': '\\b(?i:END)\\b' +'.source.assembly': + 'editor': + 'commentStart': ';' +'.source.assembly.6502.edasm': + 'editor': + 'foldEndPattern': '\\b(?i:DEND|FIN)\\b' +'.source.assembly.65816.mpw': + 'editor': + 'foldEndPattern': '\\b(?i:ENDF|ENDFUNC|ENDI|ENDP|ENDPROC|ENDR|ENDSTACK|ENDWITH|ENDM|ENDMACRO|MEND)\\b' +'.source.assembly.65816.merlin': + 'editor': + 'foldEndPattern': '\\b(?i:DEND|FIN)\\b|<<<|--\\^' +'.source.assembly.65816.ninjaforce': + 'editor': + 'foldEndPattern': '(\\^\\^\\^|\\<\\<\\<)' +'.source.assembly.65816.orcam': + 'editor': + 'foldEndPattern': '\\b(?i:END)\\b'