Improve cc65 support with new grammar for linker config files

This commit is contained in:
Georg Ziegler 2018-06-12 07:02:05 +02:00
parent eefb3ddffa
commit b23fafac4a
3 changed files with 121 additions and 15 deletions

View File

@ -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))

View File

@ -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
{

View File

@ -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'
}
]