sic

The sic programming language, compiler and tools (WIP)
Log | Files | Refs

sic.vim (1402B)



" Clear any existing syntax
if exists("b:current_syntax")
  finish
endif

" Keywords
syntax keyword sicKeyword    if else while opt lazy match def for each some none ok err in is cast

" Types
syntax keyword sicType       int dec str bool void

syntax match   sicUserType   /\<[A-Z][A-Za-z0-9_]*\>/

" Constants
syntax keyword sicConstant   true false

" Strings: "..."
syntax region  sicString     start=/"/ end=/"/ skip=/\\"/

" Char def
syntax match   sicChar       /'[^\']'/
syntax match   sicCharError  /'[^\']\{2,}'/

" Numbers
syntax match   sicNumber     "\v(\d+(\.\d+)?)"

" Operators
syntax match   sicOperator /[?;!~#*+\-:=<>&^%|]/
syntax match   sicOperator /\/\%(\/\)\@!/ "special rules for / to have another / after it
" Types override
" syntax match   sicType2      /\<[i|u|f]\(8\|16\|32\|64\)\>/

" Functions
syntax match sicUserFunc  /\<[A-Za-z_][A-Za-z0-9_]*\ze(/

" Comments: // EOL
syntax match   sicComment    "//.*$" contains=NONE

" Highlight groups
hi def link    sicComment    Comment
hi def link    sicOperator   Operator
hi def link    sicKeyword    Keyword
hi def link    sicType       Type
hi def link    sicUserType	 Tag
hi def link    sicUserFunc	 Function
hi def link    sicConstant   Constant
hi def link    sicString     String
hi def link    sicChar       Character
hi def link    sicCharError  Error
hi def link    sicNumber     Number

let b:current_syntax = "sic"