mix.vim 2.9 KB

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