blob: 9ab98eacf88aa03ebdd1e97d2cf9cee6adeef61a [file] [log] [blame]
Bram Moolenaar4b60a6c2013-11-14 05:48:46 +01001" Vim syntax file
2" Language: MIX (Donald Knuth's assembly language used in TAOCP)
3" Maintainer: Wu Yongwei <wuyongwei@gmail.com>
4" Filenames: *.mixal *.mix
5" Last Change: 2013 Nov 13
6
7" Quit when a syntax file was already loaded
8if exists("b:current_syntax")
9 finish
10endif
11
12let s:cpo_save = &cpo
13set cpo&vim
14
15syn case ignore
16
17" Special processing of ALF directive: implementations vary whether quotation
18" marks are needed
19syn match mixAlfParam #\s\{1,2\}"\?[^"]\{,5\}"\?# contains=mixAlfDirective,mixString nextgroup=mixEndComment contained
20
21" Region for parameters
22syn match mixParam #[-+*/:=0-9a-z,()"]\+# contains=mixIdentifier,mixSpecial,mixNumber,mixString,mixLabel nextgroup=mixEndComment contained
23
24" Comment at the line end
25syn match mixEndComment ".*" contains=mixRegister contained
26
27" Identifier; must go before literals
28syn match mixIdentifier "[a-z0-9_]\+" contained
29
30" Literals
31syn match mixSpecial "[-+*/:=]" contained
32syn match mixNumber "[0-9]\+\>" contained
33syn region mixString start=+"+ skip=+\\"+ end=+"+ contained
34
35" Labels
36syn match mixLabel "^[a-z0-9_]\{,10\}\s\+" nextgroup=mixAlfSpecial,mixOpcode,mixDirective
37syn match mixLabel "[0-9][BF]" contained
38
39" Comments
40syn match mixComment "^\*.*" contains=mixRegister
41
42" Directives
43syn keyword mixDirective ORIG EQU CON END nextgroup=mixParam contained skipwhite
44syn keyword mixDirective ALF nextgroup=mixAlfParam contained
45
46" Opcodes
47syn keyword mixOpcode NOP HLT NUM CHAR FLOT FIX nextgroup=mixEndComment contained
48syn keyword mixOpcode FADD FSUB FMUL FDIV FCMP MOVE ADD SUB MUL DIV IOC IN OUT JRED JBUS JMP JSJ JOV JNOV JL JE JG JLE JNE JGE SLA SRA SLAX SRAX SLC SRC nextgroup=mixParam contained skipwhite
49
50syn match mixOpcode "LD[AX1-6]N\?\>" nextgroup=mixParam contained skipwhite
51syn match mixOpcode "ST[AX1-6JZ]\>" nextgroup=mixParam contained skipwhite
52syn match mixOpcode "EN[TN][AX1-6]\>" nextgroup=mixParam contained skipwhite
53syn match mixOpcode "INC[AX1-6]\>" nextgroup=mixParam contained skipwhite
54syn match mixOpcode "DEC[AX1-6]\>" nextgroup=mixParam contained skipwhite
55syn match mixOpcode "CMP[AX1-6]\>" nextgroup=mixParam contained skipwhite
56syn match mixOpcode "J[AX1-6]N\?[NZP]\>" nextgroup=mixParam contained skipwhite
57
58" Switch back to being case sensitive
59syn case match
60
61" Registers (only to used in comments now)
62syn keyword mixRegister rA rX rI1 rI2 rI3 rI4 rI5 rI6 rJ contained
63
64" The default highlighting
65hi def link mixRegister Special
66hi def link mixLabel Define
67hi def link mixComment Comment
68hi def link mixEndComment Comment
69hi def link mixDirective Keyword
70hi def link mixOpcode Keyword
71
72hi def link mixSpecial Special
73hi def link mixNumber Number
74hi def link mixString String
75hi def link mixAlfParam String
76hi def link mixIdentifier Identifier
77
78let b:current_syntax = "mix"
79
80let &cpo = s:cpo_save
81unlet s:cpo_save
82
83" vim: ts=8