1" Vim syntax file
2" Language:	Metafont
3" Maintainer:	Andreas Scherer <andreas.scherer@pobox.com>
4" Last Change:	April 25, 2001
5
6" For version 5.x: Clear all syntax items
7" For version 6.x: Quit when a syntax file was already loaded
8if version < 600
9  syn clear
10elseif exists("b:current_syntax")
11  finish
12endif
13
14" Metafont 'primitives' as defined in chapter 25 of 'The METAFONTbook'
15" Page 210: 'boolean expressions'
16syn keyword mfBoolExp true false known unknown odd charexists not and or
17
18" Page 210: 'numeric expression'
19syn keyword mfNumExp normaldeviate length ASCII oct hex angle turningnumber
20syn keyword mfNumExp totalweight directiontime xpart ypart xxpart xypart
21syn keyword mfNumExp yxpart yypart sqrt sind cosd mlog mexp floor
22syn keyword mfNumExp uniformdeviate
23
24" Page 211: 'internal quantities'
25syn keyword mfInternal tracingtitles tracingequations tracingcapsules
26syn keyword mfInternal tracingchoices tracingspecs tracingpens
27syn keyword mfInternal tracingcommands tracingrestores tracingmacros
28syn keyword mfInternal tracingedges tracingoutput tracingonline tracingstats
29syn keyword mfInternal pausing showstopping fontmaking proofing
30syn keyword mfInternal turningcheck warningcheck smoothing autorounding
31syn keyword mfInternal granularity fillin year month day time
32syn keyword mfInternal charcode charext charwd charht chardp charic
33syn keyword mfInternal chardx chardy designsize hppp vppp xoffset yoffset
34syn keyword mfInternal boundarychar
35
36" Page 212: 'pair expressions'
37syn keyword mfPairExp point of precontrol postcontrol penoffset rotated
38syn keyword mfPairExp scaled shifted slanted transformed xscaled yscaled
39syn keyword mfPairExp zscaled
40
41" Page 213: 'path expressions'
42syn keyword mfPathExp makepath reverse subpath curl tension atleast
43syn keyword mfPathExp controls cycle
44
45" Page 214: 'pen expressions'
46syn keyword mfPenExp nullpen pencircle makepen
47
48" Page 214: 'picutre expressions'
49syn keyword mfPicExp nullpicture
50
51" Page 214: 'string expressions'
52syn keyword mfStringExp jobname readstring str char decimal substring
53
54" Page 217: 'commands and statements'
55syn keyword mfCommand end dump save interim newinternal randomseed let
56syn keyword mfCommand delimiters outer everyjob show showvariable showtoken
57syn keyword mfCommand showdependencies showstats message errmessage errhelp
58syn keyword mfCommand batchmode nonstopmode scrollmode errorstopmode
59syn keyword mfCommand addto also contour doublepath withpen withweight cull
60syn keyword mfCommand keeping dropping display inwindow openwindow at from to
61syn keyword mfCommand shipout special numspecial
62
63" Page 56: 'types'
64syn keyword mfType boolean numeric pair path pen picture string transform
65
66" Page 155: 'grouping'
67syn keyword mfStatement begingroup endgroup
68
69" Page 165: 'definitions'
70syn keyword mfDefinition enddef def expr suffix text primary secondary
71syn keyword mfDefinition tertiary vardef primarydef secondarydef tertiarydef
72
73" Page 169: 'conditions and loops'
74syn keyword mfCondition if fi else elseif endfor for forsuffixes forever
75syn keyword mfCondition step until exitif
76
77" Other primitives listed in the index
78syn keyword mfPrimitive charlist endinput expandafter extensible
79syn keyword mfPrimitive fontdimen headerbyte inner input intersectiontimes
80syn keyword mfPrimitive kern ligtable quote scantokens skipto
81
82" Keywords defined by plain.mf (defined on pp.262-278)
83if !exists("plain_mf_macros")
84  let plain_mf_macros = 1 " Set this to '0' if your source gets too colourful
85			  " metapost.vim does so to turn off Metafont macros
86endif
87if plain_mf_macros
88  syn keyword mfMacro abs addto_currentpicture aspect_ratio base_name
89  syn keyword mfMacro base_version beginchar blacker blankpicture bot bye byte
90  syn keyword mfMacro capsule_def ceiling change_width clear_pen_memory clearit
91  syn keyword mfMacro clearpen clearxy counterclockwise culldraw cullit
92  syn keyword mfMacro currentpen currentpen_path currentpicture
93  syn keyword mfMacro currenttransform currentwindow cutdraw cutoff d decr
94  syn keyword mfMacro define_blacker_pixels define_corrected_pixels
95  syn keyword mfMacro define_good_x_pixels define_good_y_pixels
96  syn keyword mfMacro define_horizontal_corrected_pixels define_pixels
97  syn keyword mfMacro define_whole_blacker_pixels define_whole_pixels
98  syn keyword mfMacro define_whole_vertical_blacker_pixels
99  syn keyword mfMacro define_whole_vertical_pixels dir direction directionpoint
100  syn keyword mfMacro displaying ditto div dotprod down downto draw drawdot
101  syn keyword mfMacro endchar eps epsilon extra_beginchar extra_endchar
102  syn keyword mfMacro extra_setup erase exitunless fill filldraw fix_units flex
103  syn keyword mfMacro font_coding_scheme font_extra_space font_identifier
104  syn keyword mfMacro font_normal_shrink font_normal_space font_normal_stretch
105  syn keyword mfMacro font_quad font_setup font_size font_slant font_x_height
106  syn keyword mfMacro fullcircle generate gfcorners gobble gobbled grayfont h
107  syn keyword mfMacro halfcircle hide hround identity image_rules incr infinity
108  syn keyword mfMacro interact interpath intersectionpoint inverse italcorr
109  syn keyword mfMacro join_radius killtext labelfont labels left lft localfont
110  syn keyword mfMacro loggingall lowres lowres_fix mag magstep makebox makegrid
111  syn keyword mfMacro makelabel maketicks max min mod mode mode_def mode_name
112  syn keyword mfMacro mode_setup nodisplays notransforms number_of_modes numtok
113  syn keyword mfMacro o_correction openit origin pen_bot pen_lft pen_rt pen_top
114  syn keyword mfMacro penlabels penpos penrazor penspeck pensquare penstroke
115  syn keyword mfMacro pickup pixels_per_inch proof proofoffset proofrule
116  syn keyword mfMacro proofrulethickness quartercircle range reflectedabout
117  syn keyword mfMacro relax right rotatedabout rotatedaround round rt rulepen
118  syn keyword mfMacro savepen screenchars screen_rows screen_cols screenrule
119  syn keyword mfMacro screenstrokes shipit showit slantfont smode smoke softjoin
120  syn keyword mfMacro solve stop superellipse takepower tensepath titlefont
121  syn keyword mfMacro tolerance top tracingall tracingnone undraw undrawdot
122  syn keyword mfMacro unfill unfilldraw unitpixel unitsquare unitvector up upto
123  syn keyword mfMacro vround w whatever
124endif
125
126" Some other basic macro names, e.g., from cmbase, logo, etc.
127if !exists("other_mf_macros")
128  let other_mf_macros = 1 " Set this to '0' if your code gets too colourful
129			  " metapost.vim does so to turn off Metafont macros
130endif
131if other_mf_macros
132  syn keyword mfMacro beginlogochar
133endif
134
135" Numeric tokens
136syn match mfNumeric	"[-]\=\d\+"
137syn match mfNumeric	"[-]\=\.\d\+"
138syn match mfNumeric	"[-]\=\d\+\.\d\+"
139
140" Metafont lengths
141syn match mfLength	"\<\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\>"
142syn match mfLength	"\<[-]\=\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\=\>"
143syn match mfLength	"\<[-]\=\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\=\>"
144syn match mfLength	"\<[-]\=\d\+\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\=\>"
145
146" Metafont coordinates and points
147syn match mfCoord	"\<[xy]\d\+\>"
148syn match mfPoint	"\<z\d\+\>"
149
150" String constants
151syn region mfString	start=+"+ end=+"+
152
153" Comments:
154syn match mfComment	"%.*$"
155
156" synchronizing
157syn sync maxlines=50
158
159" Define the default highlighting
160" For version 5.7 and earlier: only when not done already
161" For version 5.8 and later: only when an item doesn't have highlighting yet
162if version >= 508 || !exists("did_mf_syntax_inits")
163  if version < 508
164    let did_mf_syntax_inits = 1
165    command -nargs=+ HiLink hi link <args>
166  else
167    command -nargs=+ HiLink hi def link <args>
168  endif
169
170  HiLink mfBoolExp	Statement
171  HiLink mfNumExp	Statement
172  HiLink mfInternal	Identifier
173  HiLink mfPairExp	Statement
174  HiLink mfPathExp	Statement
175  HiLink mfPenExp	Statement
176  HiLink mfPicExp	Statement
177  HiLink mfStringExp	Statement
178  HiLink mfCommand	Statement
179  HiLink mfType	Type
180  HiLink mfStatement	Statement
181  HiLink mfDefinition	Statement
182  HiLink mfCondition	Conditional
183  HiLink mfPrimitive	Statement
184  HiLink mfMacro	Macro
185  HiLink mfCoord	Identifier
186  HiLink mfPoint	Identifier
187  HiLink mfNumeric	Number
188  HiLink mfLength	Number
189  HiLink mfComment	Comment
190  HiLink mfString	String
191
192  delcommand HiLink
193endif
194
195let b:current_syntax = "mf"
196
197" vim: ts=8
198