blob: 3018900e800358c5886d940cb10e5db892fe91ab [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Modula 2
3" Maintainer: pf@artcom0.north.de (Peter Funk)
4" based on original work of Bram Moolenaar <Bram@vim.org>
5" Last Change: 2001 May 09
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" Don't ignore case (Modula-2 is case significant). This is the default in vim
16
17" Especially emphasize headers of procedures and modules:
18syn region modula2Header matchgroup=modula2Header start="PROCEDURE " end="(" contains=modula2Ident oneline
19syn region modula2Header matchgroup=modula2Header start="MODULE " end=";" contains=modula2Ident oneline
20syn region modula2Header matchgroup=modula2Header start="BEGIN (\*" end="\*)" contains=modula2Ident oneline
21syn region modula2Header matchgroup=modula2Header start="END " end=";" contains=modula2Ident oneline
22syn region modula2Keyword start="END" end=";" contains=ALLBUT,modula2Ident oneline
23
24" Some very important keywords which should be emphasized more than others:
25syn keyword modula2AttKeyword CONST EXIT HALT RETURN TYPE VAR
26" All other keywords in alphabetical order:
27syn keyword modula2Keyword AND ARRAY BY CASE DEFINITION DIV DO ELSE
28syn keyword modula2Keyword ELSIF EXPORT FOR FROM IF IMPLEMENTATION IMPORT
29syn keyword modula2Keyword IN LOOP MOD NOT OF OR POINTER QUALIFIED RECORD
30syn keyword modula2Keyword SET THEN TO UNTIL WHILE WITH
31
32syn keyword modula2Type ADDRESS BITSET BOOLEAN CARDINAL CHAR INTEGER REAL WORD
33syn keyword modula2StdFunc ABS CAP CHR DEC EXCL INC INCL ORD SIZE TSIZE VAL
34syn keyword modula2StdConst FALSE NIL TRUE
35" The following may be discussed, since NEW and DISPOSE are some kind of
36" special builtin macro functions:
37syn keyword modula2StdFunc NEW DISPOSE
38" The following types are added later on and may be missing from older
39" Modula-2 Compilers (they are at least missing from the original report
40" by N.Wirth from March 1980 ;-) Highlighting should apply nevertheless:
41syn keyword modula2Type BYTE LONGCARD LONGINT LONGREAL PROC SHORTCARD SHORTINT
42" same note applies to min and max, which were also added later to m2:
43syn keyword modula2StdFunc MAX MIN
44" The underscore was originally disallowed in m2 ids, it was also added later:
45syn match modula2Ident " [A-Z,a-z][A-Z,a-z,0-9,_]*" contained
46
47" Comments may be nested in Modula-2:
48syn region modula2Comment start="(\*" end="\*)" contains=modula2Comment,modula2Todo
49syn keyword modula2Todo contained TODO FIXME XXX
50
51" Strings
52syn region modula2String start=+"+ end=+"+
53syn region modula2String start="'" end="'"
54syn region modula2Set start="{" end="}"
55
56" Define the default highlighting.
57" For version 5.7 and earlier: only when not done already
58" For version 5.8 and later: only when an item doesn't have highlighting yet
59if version >= 508 || !exists("did_modula2_syntax_inits")
60 if version < 508
61 let did_modula2_syntax_inits = 1
62 command -nargs=+ HiLink hi link <args>
63 else
64 command -nargs=+ HiLink hi def link <args>
65 endif
66
67 HiLink modula2Ident Identifier
68 HiLink modula2StdConst Boolean
69 HiLink modula2Type Identifier
70 HiLink modula2StdFunc Identifier
71 HiLink modula2Header Type
72 HiLink modula2Keyword Statement
73 HiLink modula2AttKeyword PreProc
74 HiLink modula2Comment Comment
75 " The following is just a matter of taste (you want to try this instead):
76 " hi modula2Comment term=bold ctermfg=DarkBlue guifg=Blue gui=bold
77 HiLink modula2Todo Todo
78 HiLink modula2String String
79 HiLink modula2Set String
80
81 delcommand HiLink
82endif
83
84let b:current_syntax = "modula2"
85
86" vim: ts=8