\lstdefinelanguage{MetaPost}{
morecomment=[l]{\%},
morestring=[b]",
%keywords
% Yellow
keywords={
if,%
fi,%
for,%
forsuffixes,%
forever,%
endfor,%
while,%
input,%
addto,%
clip,%
cutdraw,%
draw,%
drawarrow,%
drawdblarrow,%
fill,%
filldraw,%
interim,%
let,%
loggingall,%
newinternal,%
pickup,%
save,%
setbounds,%
shipout,%
show,%
showdependencies,%
showtoken,%
showvariable,%
special,%
tracingall,%
tracingnone,%
undraw,%
unfill,%
unfilldraw,%
boxit,%
boxjoin,%
bpath,%
buildcycle,%
circleit,%
dashpattern,%
decr,%
dotlabel,%
dotlabels,%
drawboxed,%
drawboxes,%
drawoptions,%
drawunboxed,%
fixpos,%
fixsize,%
incr,%
label,%
labels,%
max,%
min,%
thelabel}%
%Name:MetaPost Begin / End
%  Before:0~Alpha
%  After:0~Alpha
%  Enabled:1MetaPost
%  Strict Priority:0
%  Priority:1
%  Color:5122
%  Case Sensitive:1
%
% Yellow
,morekeywords=[1]{
beginfig,%
endfig,%
end}%
%
%Name:MetaPost TeX
%  Before:0~Alpha
%  After:0~Alpha
%  Enabled:1MetaPost
%  Strict Priority:0
%  Priority:1
%  Color:5121
%  Case Sensitive:1
 % Yellow,%
,morekeywords=[2]{
btex,%
etex,%
defaultfont,%
fontsize,%
verbatimtex}%
%
%
%variables
% bluish green
,morekeywords=[3]{
ahangle,%
ahlength,%
bboxmargin,%
charcode,%
circmargin,%
day,%
defaultdx,%
defaultdy,%
defaultpen,%
defaultscale,%
labeloffset,%
linecap,%
linejoin,%
miterlimit,%
month,%
pausing,%
prologues,%
showstopping,%
time,%
tracingcapsules,%
tracingchoices,%
tracingcommands,%
tracingequations,%
tracinglostchars,%
tracingmacros,%
tracingonline,%
tracingoutput,%
tracingrestores,%
tracingspecs,%
tracingstats,%
tracingtitles,%
truecorners,%
warningcheck,%
year,%
background,%
currentpen,%
currentpicture,%
cuttings,%
defaultfont,%
extra_beginfig,%
extra_endfig}%
%
%Name:MetaPost Constants
%  Before:0~Alpha
%  After:0~Alpha
%  Enabled:1MetaPost
%  Strict Priority:0
%  Priority:1
%  Color:1025
%  Case Sensitive:1
%
% red
,morekeywords=[4]{
beveled,%
black,%
blue,%
bp,%
butt,%
cc,%
cm,%
dd,%
ditto,%
down,%
epsilon,%
evenly,%
false,%
fullcircle,%
green,%
halfcircle,%
identity,%
in,%
infinity,%
left,%
mitered,%
mm,%
nullpicture,%
origin,%
pc,%
pencircle,%
pensquare,%
pt,%
quartercircle,%
red,%
right,%
rounded,%
squared,%
true,%
unitsquare,%
up,%
white,%
withdots}%
%
%Name:MetaPost Positions
%  Before:1Point
%  After:0~Alpha
%  Enabled:1MetaPost
%  Strict Priority:0
%  Priority:1
%  Color:1027
%  Case Sensitive:1
%
% purple
,morekeywords=[5]{
bot,%
lft,%
ulft,%
llft,%
rt,%
urt,%
lrt,%
top,%
dx,%
dy,%
nw,%
n,%
ne,%
w,%
e,%
sw,%
s,%
se}%
%
%Name:MetaPost Operators
%  Before:0~Alpha
%  After:0~Alpha
%  Enabled:1MetaPost
%  Strict Priority:0
%  Priority:1
%  Color:1029
%  Case Sensitive:1
 %
% purple
,morekeywords=[6]{
++,%
+-+,%
abs,%
and,%
angle,%
arclength,%
arctime,%
ASCII,%
bbox,%
bluepart,%
boolean,%
ceiling,%
center,%
char,%
color,%
cosd,%
cutafter,%
cutbefore,%
cycle,%
decimal,%
dir,%
direction,%
directionpoint,%
directiontime,%
div,%
dotprod,%
floor,%
fontsize,%
greenpart,%
hex,%
infont,%
intersectionpoint,%
intersectiontimes,%
inverse,%
known,%
length,%
llcorner,%
lrcorner,%
makepath,%
makepen,%
mexp,%
mlog,%
mod,%
normaldeviate,%
not ,%
numeric,%
oct,%
odd,%
or,%
pair,%
path,%
pen,%
penoffset,%
picture,%
point,%
postcontrol,%
precontrol,%
redpart,%
reverse,%
rotated,%
round,%
scaled,%
shifted,%
sind,%
slanted,%
sqrt,%
str,%
string,%
subpath,%
substring,%
transform,%
transformed,%
ulcorner,%
uniformdeviate,%
unitvektor,%
unknown,%
urcorner,%
whatever,%
xpart,%
xscaled,%
xxpart,%
xypart,%
ypart,%
yscaled,%
yxpart,%
yypart,%
zscaled,%
exitif,%
exitunless,%
upto,%
downto,%
step,%
until,%
withcolor,%
dashed,%
lft,%
rt,%
top,%
bot}%
}


\lstset{language=MetaPost,
keywordstyle=\color{orange},
keywordstyle=[1]\color{orange},
keywordstyle=[2]\color{orange},
keywordstyle=[3]\color{bluegreen},
keywordstyle=[4]\color{purple},
keywordstyle=[5]\color{purple},
commentstyle=\color{blue},
stringstyle=\color{red},
basicstyle=\ttfamily
}

%Name:MetaPost Begin / End
% Yellow	1

%Name:MetaPost TeX
 % Yellow,% 2

%variables
% bluish green 3

%Name:MetaPost Constants
% red 4

%Name:MetaPost Positions
% purple 5

%Name:MetaPost Operators
% purple  6
