blob: 01532be75d6d956b2cc88a738d8a19eaad248bf0 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: B (A Formal Method with refinement and mathematical proof)
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00003" Maintainer: Mathieu Clabaut <mathieu.clabaut@gmail.com>
4" Contributor: Csaba Hoch
5" LastChange: 8 Dec 2007
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02008" quit when a syntax file was already loaded
9if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000010 finish
11endif
12
13
14" A bunch of useful B keywords
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000015syn keyword bStatement MACHINE MODEL 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 XLS THEOREMS LOCAL_OPERATIONS
Bram Moolenaar071d4272004-06-13 20:20:40 +000016syn keyword bLabel CASE IN EITHER OR CHOICE DO OF
17syn keyword bConditional IF ELSE SELECT ELSIF THEN WHEN
18syn keyword bRepeat WHILE FOR
19syn 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
20syn keyword bKeywords LET VAR BE IN BEGIN END POW POW1 FIN FIN1 PRE SIGMA STRING UNION IS ANY WHERE
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
22syn keyword bBoolean TRUE FALSE bfalse btrue
23syn keyword bConstant PI MAXINT MININT User_Pass PatchProver PatchProverH0 PatchProverB0 FLAT ARI DED SUB RES
24syn 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
25
26syn keyword bLogic or not
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000027syn match bLogic "\(!\|#\|%\|&\|+->>\|+->\|-->>\|->>\|-->\|->\|/:\|/<:\|/<<:\|/=\|/\\\|/|\\\|::\|:\|;:\|<+\|<->\|<--\|<-\|<:\|<<:\|<<|\|<=>\|<|\|==\|=>\|>+>>\|>->\|>+>\|||\||->\)"
28syn match bNothing /:=/
Bram Moolenaar071d4272004-06-13 20:20:40 +000029
30syn keyword cTodo contained TODO FIXME XXX
31
32" String and Character constants
33" Highlight special characters (those which have a backslash) differently
34syn match bSpecial contained "\\[0-7][0-7][0-7]\=\|\\."
35syn region bString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=bSpecial
36syn match bCharacter "'[^\\]'"
37syn match bSpecialCharacter "'\\.'"
38syn match bSpecialCharacter "'\\[0-7][0-7]'"
39syn match bSpecialCharacter "'\\[0-7][0-7][0-7]'"
40
41"catch errors caused by wrong parenthesis
42syn region bParen transparent start='(' end=')' contains=ALLBUT,bParenError,bIncluded,bSpecial,bTodo,bUserLabel,bBitField
43syn match bParenError ")"
44syn match bInParen contained "[{}]"
45
46"integer number, or floating point number without a dot and with "f".
47syn case ignore
48syn match bNumber "\<[0-9]\+\>"
49"syn match bIdentifier "\<[a-z_][a-z0-9_]*\>"
50syn case match
51
Bram Moolenaar071d4272004-06-13 20:20:40 +000052 syn region bComment start="/\*" end="\*/" contains=bTodo
Bram Moolenaar071d4272004-06-13 20:20:40 +000053 syn match bComment "//.*" contains=bTodo
Bram Moolenaar071d4272004-06-13 20:20:40 +000054syntax match bCommentError "\*/"
55
56syn keyword bType INT INTEGER BOOL NAT NATURAL NAT1 NATURAL1
57
58syn region bPreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=bComment,bString,bCharacter,bNumber,bCommentError
59syn region bIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+
60syn match bIncluded contained "<[^>]*>"
61syn match bInclude "^\s*#\s*include\>\s*["<]" contains=bIncluded
62
63syn region bDefine start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,bPreCondit,bIncluded,bInclude,bDefine,bInParen
64syn region bPreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,bPreCondit,bIncluded,bInclude,bDefine,bInParen
65
Bram Moolenaar071d4272004-06-13 20:20:40 +000066syn sync ccomment bComment minlines=10
67
68" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020069" Only when an item doesn't have highlighting yet
Bram Moolenaar071d4272004-06-13 20:20:40 +000070
Bram Moolenaar071d4272004-06-13 20:20:40 +000071
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020072" The default methods for highlighting. Can be overridden later
Bram Moolenaarf37506f2016-08-31 22:22:10 +020073hi def link bLabel Label
74hi def link bUserLabel Label
75hi def link bConditional Conditional
76hi def link bRepeat Repeat
77hi def link bLogic Special
78hi def link bCharacter Character
79hi def link bSpecialCharacter bSpecial
80hi def link bNumber Number
81hi def link bFloat Float
82hi def link bOctalError bError
83hi def link bParenError bError
84" hi def link bInParen bError
85hi def link bCommentError bError
86hi def link bBoolean Identifier
87hi def link bConstant Identifier
88hi def link bGuard Identifier
89hi def link bOperator Operator
90hi def link bKeywords Operator
91hi def link bOps Identifier
92hi def link bStructure Structure
93hi def link bStorageClass StorageClass
94hi def link bInclude Include
95hi def link bPreProc PreProc
96hi def link bDefine Macro
97hi def link bIncluded bString
98hi def link bError Error
99hi def link bStatement Statement
100hi def link bPreCondit PreCondit
101hi def link bType Type
102hi def link bCommentError bError
103hi def link bCommentString bString
104hi def link bComment2String bString
105hi def link bCommentSkip bComment
106hi def link bString String
107hi def link bComment Comment
108hi def link bSpecial SpecialChar
109hi def link bTodo Todo
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200110"hi link bIdentifier Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +0000111
Bram Moolenaar9964e462007-05-05 17:54:07 +0000112let b:current_syntax = "b"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000113
114" vim: ts=8