" Vim syntax file
" Language   : BogusForth
" Maintainer : Antonio Maschio <tbin@libero.it>
" Last change: 

" Thanks to...
" Christian V. J. Brüssow <cvjb@epost.de> for the forth.vim

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
	syntax clear
elseif exists("b:current_syntax")
	finish
endif

" Synchronization method
syn sync ccomment maxlines=200

" Characters allowed in keywords
if version >= 600
	setlocal iskeyword=!,@,33-64,A-Z,91-96,a-z,123-126,128-255
else
	set iskeyword=!,@,33-64,A-Z,91-96,a-z,123-126,128-255
endif

" Matchin case
syn case match

" Keywords

" math, logical and bitwise operators
syn match bfOpa 		/a/
syn match bfOpo 		/o/
syn match bfOpn 		/n/
syn match bfOpx 		/x/
syn match bfOpplus  	/+/
syn match bfOptimes 	/*/
syn match bfOpminus 	/-/
syn match bfOpdiv   	/\\/
syn match bfOpneg   	/\//
syn match bfOppow   	/\^/
syn match bfOproot  	/!/
syn match bfOpequal 	/=/
syn match bfOpgt    	/>/
syn match bfOpand   	/&/
syn match bfOpor    	/|/
syn match bfOpxor	   /l/
syn match bfOpnot   	/\~/
syn match bfOpmod   	/m/
syn match bfOpran	  	/g/
														 
" stack manipulation
syn match bfStdup  	/%/
syn match bfStdrop 	/;/
syn match bfStswap 	/\$/
syn match bfStrot  	/_/
syn match bfStroll 	/r/
syn match bfStpick 	/p/
syn match bfStstck 	/:/
syn match bfStempt 	/)/
syn match bfStdpth 	/}/

" if-then-else and tear away
syn match bfIfif 		/?/
syn match bfIftr 		/t/

" while cycle
syn match bfRepeat 	/#/

" function command
syn match bfFunctionC /@/

" functions
syn region bfFunction start=/\[/ end=/\]/ end=/$/ contains=ALLBUT,bfSyBr
"syn match bfFuncStart /\[/ skipwhite
"syn match bfFuncEnd   /\]/ contained

" input/output
syn match bfIOi /i/
syn match bfIOj /j/
syn match bfIOk /k/
syn match bfIOl /</
syn match bfIOp /(/

" system commands
syn match bfSyh /h/
syn match bfSyd /d/
syn match bfSyc /c/
syn match bfSyv /v/
syn match bfSyq /q/
syn match bfSybr /]/
syn match bfSyy /y/
syn match bfSyb /b/
syn match bfSyf /f/
syn match bfSys /s/
syn match bfSyw /w/

" string/char 
syn match bfStr1 /'/
syn match bfStr2 /`/
syn match bfStr3 /,/
syn match bfStr4 /\./
syn match bfStre /e/
syn match bfStru /u/

" Strings
syn region bfString start=/"/ skip=/\\"/ end=/"/ end=/$/

" Comments
syn region bfComment start=/{/ end=/}/ end=/$/
syn match  bfCapComm /\<\u\+\>/

" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_bf_syn_inits")
	if version < 508
		let did_bf_syn_inits = 1
		command -nargs=+ HiLink hi link <args>
	else
		command -nargs=+ HiLink hi def link <args>
	endif

	" The default methods for highlighting. Can be overriden later.

" math, logical and bitwise operators
	HiLink bfOpa 	  Special
	HiLink bfOpo 	  Special
	HiLink bfOpn 	  Special
	HiLink bfOpx 	  Special
	HiLink bfOpplus  Special
	HiLink bfOptimes Special
	HiLink bfOpminus Special
	HiLink bfOpdiv   Special
	HiLink bfOpneg   Special
	HiLink bfOpmod   Special
	HiLink bfOppow   Special
	HiLink bfOproot  Special
	HiLink bfOpequal Special
	HiLink bfOpgt    Special
	HiLink bfOpand   Special
	HiLink bfOpor    Special  
	HiLink bfOpxor   Special
	HiLink bfOpnot   Special
	HiLink bfOpran   Special
														 
" stack manipulation
	HiLink bfStdup  PreProc
	HiLink bfStdrop PreProc
	HiLink bfStswap PreProc
	HiLink bfStrot  PreProc
	HiLink bfStroll PreProc
	HiLink bfStpick PreProc
	HiLink bfStstck PreProc
	HiLink bfStempt PreProc
	HiLink bfStdpth PreProc

" if-then-else and tear away
	HiLink bfIfif Conditional
	HiLink bfIftr Conditional

" while cycle
	HiLink bfRepeat Repeat

" functions
	HiLink bfFunctionC Function 

" input/output
	HiLink bfIOi Define
	HiLink bfIOj Define
	HiLink bfIOk Define
	HiLink bfIOl Define
	HiLink bfIOp Define

" system commands
	HiLink bfSyh Type
	HiLink bfSyd Type
	HiLink bfSyc Type
	HiLink bfSyv Type
	HiLink bfSyq Type
	HiLink bfSybr Type
	HiLink bfSyy Type
	HiLink bfSyb Type
	HiLink bfSyf Type
	HiLink bfSys Type
	HiLink bfSyw Type

" string/char 
	HiLink bfStr1 Identifier
	HiLink bfStr2 Identifier
	HiLink bfStr3 Identifier
	HiLink bfStr4 Identifier
	HiLink bfStre Identifier
	HiLink bfStru Identifier
	HiLink bfComment Comment
	HiLink bfCapComm Comment
	HiLink bfString String
	HiLink bfFunction Function
"	HiLink bfFuncStart Function
"	HiLink bfFuncEnd Function

	delcommand HiLink
endif

let b:current_syntax = "bf"

" vim:ts=3:sw=3
