1" Language:     ampl (A Mathematical Programming Language)
2" Maintainer:   Krief David <david.krief@etu.enseeiht.fr> or <david_krief@hotmail.com>
3" Last Change:  2003 May 11
4
5
6if version < 600
7 syntax clear
8elseif exists("b:current_syntax")
9 finish
10endif
11
12
13
14
15"--
16syn match   amplEntityKeyword     "\(subject to\)\|\(subj to\)\|\(s\.t\.\)"
17syn keyword amplEntityKeyword	  minimize   maximize  objective
18
19syn keyword amplEntityKeyword	  coeff      coef      cover	    obj       default
20syn keyword amplEntityKeyword	  from	     to        to_come	    net_in    net_out
21syn keyword amplEntityKeyword	  dimen      dimension
22
23
24
25"--
26syn keyword amplType		  integer    binary    set	    param     var
27syn keyword amplType		  node	     ordered   circular     reversed  symbolic
28syn keyword amplType		  arc
29
30
31
32"--
33syn keyword amplStatement	  check      close     \display     drop      include
34syn keyword amplStatement	  print      printf    quit	    reset     restore
35syn keyword amplStatement	  solve      update    write	    shell     model
36syn keyword amplStatement	  data	     option    let	    solution  fix
37syn keyword amplStatement	  unfix      end       function     pipe      format
38
39
40
41"--
42syn keyword amplConditional	  if	     then      else	    and       or
43syn keyword amplConditional	  exists     forall    in	    not       within
44
45
46
47"--
48syn keyword amplRepeat		  while      repeat    for
49
50
51
52"--
53syn keyword amplOperators	  union      diff      difference   symdiff   sum
54syn keyword amplOperators	  inter      intersect intersection cross     setof
55syn keyword amplOperators	  by	     less      mod	    div       product
56"syn keyword amplOperators	   min	      max
57"conflict between functions max, min and operators max, min
58
59syn match   amplBasicOperators    "||\|<=\|==\|\^\|<\|=\|!\|-\|\.\.\|:="
60syn match   amplBasicOperators    "&&\|>=\|!=\|\*\|>\|:\|/\|+\|\*\*"
61
62
63
64
65"--
66syn match   amplComment		"\#.*"
67syn region  amplComment		start=+\/\*+		  end=+\*\/+
68
69syn region  amplStrings		start=+\'+    skip=+\\'+  end=+\'+
70syn region  amplStrings		start=+\"+    skip=+\\"+  end=+\"+
71
72syn match   amplNumerics	"[+-]\=\<\d\+\(\.\d\+\)\=\([dDeE][-+]\=\d\+\)\=\>"
73syn match   amplNumerics	"[+-]\=Infinity"
74
75
76"--
77syn keyword amplSetFunction	  card	     next     nextw	  prev	    prevw
78syn keyword amplSetFunction	  first      last     member	  ord	    ord0
79
80syn keyword amplBuiltInFunction   abs	     acos     acosh	  alias     asin
81syn keyword amplBuiltInFunction   asinh      atan     atan2	  atanh     ceil
82syn keyword amplBuiltInFunction   cos	     exp      floor	  log	    log10
83syn keyword amplBuiltInFunction   max	     min      precision   round     sin
84syn keyword amplBuiltInFunction   sinh	     sqrt     tan	  tanh	    trunc
85
86syn keyword amplRandomGenerator   Beta	     Cauchy   Exponential Gamma     Irand224
87syn keyword amplRandomGenerator   Normal     Poisson  Uniform	  Uniform01
88
89
90
91"-- to highlight the 'dot-suffixes'
92syn match   amplDotSuffix	"\h\w*\.\(lb\|ub\)"hs=e-2
93syn match   amplDotSuffix	"\h\w*\.\(lb0\|lb1\|lb2\|lrc\|ub0\)"hs=e-3
94syn match   amplDotSuffix	"\h\w*\.\(ub1\|ub2\|urc\|val\|lbs\|ubs\)"hs=e-3
95syn match   amplDotSuffix	"\h\w*\.\(init\|body\|dinit\|dual\)"hs=e-4
96syn match   amplDotSuffix	"\h\w*\.\(init0\|ldual\|slack\|udual\)"hs=e-5
97syn match   amplDotSuffix	"\h\w*\.\(lslack\|uslack\|dinit0\)"hs=e-6
98
99
100
101"--
102syn match   amplPiecewise	"<<\|>>"
103
104
105
106"-- Todo.
107syn keyword amplTodo contained	 TODO FIXME XXX
108
109
110
111
112
113
114
115
116
117
118if version >= 508 || !exists("did_ampl_syntax_inits")
119  if version < 508
120    let did_ampl_syntax_inits = 1
121    command -nargs=+ HiLink hi link <args>
122  else
123    command -nargs=+ HiLink hi def link <args>
124  endif
125
126  " The default methods for highlighting. Can be overridden later.
127  HiLink amplEntityKeyword	Keyword
128  HiLink amplType		Type
129  HiLink amplStatement		Statement
130  HiLink amplOperators		Operator
131  HiLink amplBasicOperators	Operator
132  HiLink amplConditional	Conditional
133  HiLink amplRepeat		Repeat
134  HiLink amplStrings		String
135  HiLink amplNumerics		Number
136  HiLink amplSetFunction	Function
137  HiLink amplBuiltInFunction	Function
138  HiLink amplRandomGenerator	Function
139  HiLink amplComment		Comment
140  HiLink amplDotSuffix		Special
141  HiLink amplPiecewise		Special
142
143  delcommand HiLink
144endif
145
146let b:current_syntax = "ampl"
147
148" vim: ts=8
149
150
151