5487
|
1 " 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
|
|
8 if exists("b:current_syntax")
|
|
9 finish
|
|
10 endif
|
|
11
|
|
12 let s:cpo_save = &cpo
|
|
13 set cpo&vim
|
|
14
|
|
15 syn case ignore
|
|
16
|
|
17 " Special processing of ALF directive: implementations vary whether quotation
|
|
18 " marks are needed
|
|
19 syn match mixAlfParam #\s\{1,2\}"\?[^"]\{,5\}"\?# contains=mixAlfDirective,mixString nextgroup=mixEndComment contained
|
|
20
|
|
21 " Region for parameters
|
|
22 syn match mixParam #[-+*/:=0-9a-z,()"]\+# contains=mixIdentifier,mixSpecial,mixNumber,mixString,mixLabel nextgroup=mixEndComment contained
|
|
23
|
|
24 " Comment at the line end
|
|
25 syn match mixEndComment ".*" contains=mixRegister contained
|
|
26
|
|
27 " Identifier; must go before literals
|
|
28 syn match mixIdentifier "[a-z0-9_]\+" contained
|
|
29
|
|
30 " Literals
|
|
31 syn match mixSpecial "[-+*/:=]" contained
|
|
32 syn match mixNumber "[0-9]\+\>" contained
|
|
33 syn region mixString start=+"+ skip=+\\"+ end=+"+ contained
|
|
34
|
|
35 " Labels
|
|
36 syn match mixLabel "^[a-z0-9_]\{,10\}\s\+" nextgroup=mixAlfSpecial,mixOpcode,mixDirective
|
|
37 syn match mixLabel "[0-9][BF]" contained
|
|
38
|
|
39 " Comments
|
|
40 syn match mixComment "^\*.*" contains=mixRegister
|
|
41
|
|
42 " Directives
|
|
43 syn keyword mixDirective ORIG EQU CON END nextgroup=mixParam contained skipwhite
|
|
44 syn keyword mixDirective ALF nextgroup=mixAlfParam contained
|
|
45
|
|
46 " Opcodes
|
|
47 syn keyword mixOpcode NOP HLT NUM CHAR FLOT FIX nextgroup=mixEndComment contained
|
|
48 syn 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
|
|
50 syn match mixOpcode "LD[AX1-6]N\?\>" nextgroup=mixParam contained skipwhite
|
|
51 syn match mixOpcode "ST[AX1-6JZ]\>" nextgroup=mixParam contained skipwhite
|
|
52 syn match mixOpcode "EN[TN][AX1-6]\>" nextgroup=mixParam contained skipwhite
|
|
53 syn match mixOpcode "INC[AX1-6]\>" nextgroup=mixParam contained skipwhite
|
|
54 syn match mixOpcode "DEC[AX1-6]\>" nextgroup=mixParam contained skipwhite
|
|
55 syn match mixOpcode "CMP[AX1-6]\>" nextgroup=mixParam contained skipwhite
|
|
56 syn match mixOpcode "J[AX1-6]N\?[NZP]\>" nextgroup=mixParam contained skipwhite
|
|
57
|
|
58 " Switch back to being case sensitive
|
|
59 syn case match
|
|
60
|
|
61 " Registers (only to used in comments now)
|
|
62 syn keyword mixRegister rA rX rI1 rI2 rI3 rI4 rI5 rI6 rJ contained
|
|
63
|
|
64 " The default highlighting
|
|
65 hi def link mixRegister Special
|
|
66 hi def link mixLabel Define
|
|
67 hi def link mixComment Comment
|
|
68 hi def link mixEndComment Comment
|
|
69 hi def link mixDirective Keyword
|
|
70 hi def link mixOpcode Keyword
|
|
71
|
|
72 hi def link mixSpecial Special
|
|
73 hi def link mixNumber Number
|
|
74 hi def link mixString String
|
|
75 hi def link mixAlfParam String
|
|
76 hi def link mixIdentifier Identifier
|
|
77
|
|
78 let b:current_syntax = "mix"
|
|
79
|
|
80 let &cpo = s:cpo_save
|
|
81 unlet s:cpo_save
|
|
82
|
|
83 " vim: ts=8
|