all repos — xyw @ 9f4ba1cb0a2a468ccc1f1af4ed7a54cbb10c87c5

A minimal virtual machine and assembler for terminals.

xyw.vim

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
" Vim syntax file
" Language: xyw Assembly
" Maintainer: Fabio Cevasco
" Latest Revision: 2026-02-04

if exists("b:current_syntax")
  finish
endif

" Comments
syntax match xywComment ";.*$"

" Directives
syntax match xywDirective "\.\(include\|label\|macro\|string\|byte\)\>"

" Label definitions (name after .label)
syntax match xywLabelDef "\(\.label\s\+\)\@<=[a-zA-Z_][a-zA-Z0-9_.\-]*"

" Macro definitions (name after .macro)
syntax match xywMacroDef "\(\.macro\s\+\)\@<=[a-zA-Z_][a-zA-Z0-9_.\-]*"

" Strings
syntax region xywString start=+"+ end=+"+ contains=xywEscape
syntax match xywEscape "\\." contained

" Numbers
syntax match xywHexNumber "\$[0-9a-fA-F]\+"
syntax match xywBinNumber "%[01]\+"

" Regular identifiers
syntax match xywIdentifier "\<[a-zA-Z_][a-zA-Z0-9_.\-]*\>"

" Device identifiers (system.*, terminal.*, file.*, clock.*, beeper.*)
syntax match xywDeviceId "\<\(system\|terminal\|file\|clock\|beeper\)\.[a-zA-Z0-9_.\-]*\>"

" Library subroutines
syntax match xywLibrary "\<\(PUTD\|PUTDw\|PUTS\)\>"

" Library macros
syntax match xywLibrary "\<\(LBYTE\|SP\|NL\|MOD\|arg.end\|arg.sep\)\>"

" Instructions - BRK and RTS have no modifiers
syntax match xywInstruction "\<\(BRK\|RTS\)\>"

" Instructions - OVR and ROT only support w modifier
syntax match xywInstruction "\<\(OVR\|ROT\)w\?\>"

" Instructions - JMP, JCN, JSR support x or y (not both) and w
syntax match xywInstruction "\<\(JMP\|JCN\|JSR\)\([xy]\?w\?\)\>"

" Instructions - All other instructions with optional xyw modifiers
syntax match xywInstruction "\<\(PSH\|POP\|CLR\|LDB\|LDW\|STB\|STW\|INC\|DEC\|SHL\|SHR\|ADD\|SUB\|MUL\|DIV\|EQU\|NEQ\|GTH\|LTH\|AND\|IOR\|XOR\|NOT\|SWP\|DUP\)\([xyw]*\)\>"

" Define highlight groups
highlight default link xywComment Comment
highlight default link xywDirective PreProc
highlight default link xywLabelDef Function
highlight default link xywMacroDef Function
highlight default link xywString String
highlight default link xywEscape SpecialChar
highlight default link xywHexNumber Number
highlight default link xywBinNumber Number
highlight default link xywInstruction Statement
highlight default link xywLibrary Constant
highlight default link xywDeviceId Type
highlight default link xywIdentifier Identifier

let b:current_syntax = "xyw"