1" Vim syntax file 2" Language: B (A Formal Method with refinement and mathematical proof) 3" Maintainer: Mathieu Clabaut <[email protected]> 4" LastChange: 25 Apr 2001 5 6 7" For version 5.x: Clear all syntax items 8" For version 6.x: Quit when a syntax file was already loaded 9if version < 600 10 syntax clear 11elseif exists("b:current_syntax") 12 finish 13endif 14 15 16" A bunch of useful B keywords 17syn keyword bStatement MACHINE SEES OPERATIONS INCLUDES DEFINITIONS CONSTRAINTS CONSTANTS VARIABLES CONCRETE_CONSTANTS CONCRETE_VARIABLES ABSTRACT_CONSTANTS ABSTRACT_VARIABLES HIDDEN_CONSTANTS HIDDEN_VARIABLES ASSERT ASSERTIONS EXTENDS IMPLEMENTATION REFINEMENT IMPORTS USES INITIALISATION INVARIANT PROMOTES PROPERTIES REFINES SETS VALUES VARIANT VISIBLE_CONSTANTS VISIBLE_VARIABLES THEORY 18syn keyword bLabel CASE IN EITHER OR CHOICE DO OF 19syn keyword bConditional IF ELSE SELECT ELSIF THEN WHEN 20syn keyword bRepeat WHILE FOR 21syn keyword bOps bool card conc closure closure1 dom first fnc front not or id inter iseq iseq1 iterate last max min mod perm pred prj1 prj2 ran rel rev seq seq1 size skip succ tail union 22syn keyword bKeywords LET VAR BE IN BEGIN END POW POW1 FIN FIN1 PRE SIGMA STRING UNION IS ANY WHERE 23syn match bKeywords "||" 24 25syn keyword bBoolean TRUE FALSE bfalse btrue 26syn keyword bConstant PI MAXINT MININT User_Pass PatchProver PatchProverH0 PatchProverB0 FLAT ARI DED SUB RES 27syn keyword bGuard binhyp band bnot bguard bsearch bflat bfresh bguardi bget bgethyp barith bgetresult bresult bgoal bmatch bmodr bnewv bnum btest bpattern bprintf bwritef bsubfrm bvrb blvar bcall bappend bclose 28 29syn keyword bLogic or not 30syn match bLogic "\&\|=>\|<=>" 31 32syn keyword cTodo contained TODO FIXME XXX 33 34" String and Character constants 35" Highlight special characters (those which have a backslash) differently 36syn match bSpecial contained "\\[0-7][0-7][0-7]\=\|\\." 37syn region bString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=bSpecial 38syn match bCharacter "'[^\\]'" 39syn match bSpecialCharacter "'\\.'" 40syn match bSpecialCharacter "'\\[0-7][0-7]'" 41syn match bSpecialCharacter "'\\[0-7][0-7][0-7]'" 42 43"catch errors caused by wrong parenthesis 44syn region bParen transparent start='(' end=')' contains=ALLBUT,bParenError,bIncluded,bSpecial,bTodo,bUserLabel,bBitField 45syn match bParenError ")" 46syn match bInParen contained "[{}]" 47 48"integer number, or floating point number without a dot and with "f". 49syn case ignore 50syn match bNumber "\<[0-9]\+\>" 51"syn match bIdentifier "\<[a-z_][a-z0-9_]*\>" 52syn case match 53 54if exists("b_comment_strings") 55 " A comment can contain bString, bCharacter and bNumber. 56 " But a "*/" inside a bString in a bComment DOES end the comment! So we 57 " need to use a special type of bString: bCommentString, which also ends on 58 " "*/", and sees a "*" at the start of the line as comment again. 59 " Unfortunately this doesn't very well work for // type of comments :-( 60 syntax match bCommentSkip contained "^\s*\*\($\|\s\+\)" 61 syntax region bCommentString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=bSpecial,bCommentSkip 62 syntax region bComment2String contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=bSpecial 63 syntax region bComment start="/\*" end="\*/" contains=bTodo,bCommentString,bCharacter,bNumber,bFloat 64 syntax region bComment start="/\?\*" end="\*\?/" contains=bTodo,bCommentString,bCharacter,bNumber,bFloat 65 syntax match bComment "//.*" contains=bTodo,bComment2String,bCharacter,bNumber 66else 67 syn region bComment start="/\*" end="\*/" contains=bTodo 68 syn region bComment start="/\?\*" end="\*\?/" contains=bTodo 69 syn match bComment "//.*" contains=bTodo 70endif 71syntax match bCommentError "\*/" 72 73syn keyword bType INT INTEGER BOOL NAT NATURAL NAT1 NATURAL1 74 75syn region bPreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=bComment,bString,bCharacter,bNumber,bCommentError 76syn region bIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+ 77syn match bIncluded contained "<[^>]*>" 78syn match bInclude "^\s*#\s*include\>\s*["<]" contains=bIncluded 79 80syn region bDefine start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,bPreCondit,bIncluded,bInclude,bDefine,bInParen 81syn region bPreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,bPreCondit,bIncluded,bInclude,bDefine,bInParen 82 83 84syn sync ccomment bComment minlines=10 85 86" Define the default highlighting. 87" For version 5.7 and earlier: only when not done already 88" For version 5.8 and later: only when an item doesn't have highlighting yet 89 90if version >= 508 || !exists("did_b_syntax_inits") 91 if version < 508 92 let did_b_syntax_inits = 1 93 command -nargs=+ HiLink hi link <args> 94 else 95 command -nargs=+ HiLink hi def link <args> 96 endif 97 98 " The default methods for highlighting. Can be overridden later 99 HiLink bLabel Label 100 HiLink bUserLabel Label 101 HiLink bConditional Conditional 102 HiLink bRepeat Repeat 103 HiLink bLogic Special 104 HiLink bCharacter Character 105 HiLink bSpecialCharacter bSpecial 106 HiLink bNumber Number 107 HiLink bFloat Float 108 HiLink bOctalError bError 109 HiLink bParenError bError 110" HiLink bInParen bError 111 HiLink bCommentError bError 112 HiLink bBoolean Identifier 113 HiLink bConstant Identifier 114 HiLink bGuard Identifier 115 HiLink bOperator Operator 116 HiLink bKeywords Operator 117 HiLink bOps Identifier 118 HiLink bStructure Structure 119 HiLink bStorageClass StorageClass 120 HiLink bInclude Include 121 HiLink bPreProc PreProc 122 HiLink bDefine Macro 123 HiLink bIncluded bString 124 HiLink bError Error 125 HiLink bStatement Statement 126 HiLink bPreCondit PreCondit 127 HiLink bType Type 128 HiLink bCommentError bError 129 HiLink bCommentString bString 130 HiLink bComment2String bString 131 HiLink bCommentSkip bComment 132 HiLink bString String 133 HiLink bComment Comment 134 HiLink bSpecial SpecialChar 135 HiLink bTodo Todo 136 "hi link bIdentifier Identifier 137 delcommand HiLink 138endif 139 140let b:current_syntax = "b" 141 142" vim: ts=8 143