KIF syntax highlighting

From CS227B Wiki

Jump to: navigation, search

You're encouraged to develop syntax files for your favorite editor.

Vim

You'll need to place two files into subdirectories of your VIMFILES directory. If you're on Linux, you'll put them in ~/.vim; if you're on Windows, you'll probably put them in c:\program files\vim\vimfiles.

These sources were last updated on April 16, 2009.

VIMFILES/ftdetect/kif.vim

" KIF syntax highlighting

au BufRead,BufNewFile *.kif set filetype=kif

VIMFILES/syntax/kif.vim

" Vim syntax file
" Language   : Knowledge Interchange Format (KIF)
" (http://games.stanford.edu)
" Maintainers: Justin Lebar (starwiz@gmail.com)
" Last Change: 2009 April 16

if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

syn case match
syn sync minlines=50

" Variables and identifiers are overriden by keywords and operators, so we
" define them first.

" Variables are things which start with '?'  I assume variables don't contain
" symbols.
syn match kifVariable "?\<\w\+\>"

" Identifiers are things which don't start with '?'.  I can't use \< and \> to
" separate words here because tokens with symbols are valid identifiers (e.g.
" '++').  So we have to special case the end-of-line case and whatnot.
"
" Right now, this allows identifiers which start with numbers, such as
" '123abc'.  I'm not sure if this is valid kif.
syn match kifIdentifier "[^?() \t]\+\([ \t()]\|$\)"he=e-1,me=e-1

syn keyword kifKeyword role proposition action init true next legal does goal terminal

syn keyword kifOperator not or <=

syn match kifNumber "\<\d\+\>"
syn match kifComment "^\s*;.*"

syn sync fromstart

hi link kifKeyword Keyword
hi link kifNumber Normal
hi link kifComment Comment
hi link kifOperator Keyword
hi link kifVariable Normal
hi link kifIdentifier Identifier
Personal tools