summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/vdmlisting/vdmlisting.sty
blob: 7bf4a72a73d2636894ae44b5a029552dbb34f00e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
%%
%% This is file `vdmlisting.sty',
%%
%% 
%% Please read the software license in vdmlisting.pdf.
%%
%% (w)(c) 2010--2013 Kenneth Lausdahl and/or any other author listed
%% elsewhere in this file.
%% (c) 2013 Kenneth Lausdahl
%%
%%
\def\filedate{2020/11/10}
\def\fileversion{1.1}
\NeedsTeXFormat{LaTeX2e}
\AtEndOfPackage{\ProvidesPackage{vdmlisting}
             [\filedate\space\fileversion\space(Kenneth Lausdahl)]}
\def\lst@CheckVersion#1{\edef\reserved@a{#1}%
    \ifx\lst@version\reserved@a \expandafter\@gobble
                          \else \expandafter\@firstofone \fi}
\let\lst@version\fileversion

\RequirePackage{listings}

%define load option flags
\newif\ifnotimes
\newif\ifenablecolors

\DeclareOption{notimes}{
 	\notimestrue
}

\DeclareOption{color}{
 	\enablecolorstrue
}

\ProcessOptions\relax

\ifnotimes
%
\else
 	\RequirePackage{times}
\fi

\ifenablecolors
 	\RequirePackage{color}
 	\definecolor{notovered}{rgb}{1,0,0}  %red
% Custom macro used to color uncoverage model parts in listings
	\newcommand{\vdmnotcovered}[1]{\textcolor{notovered}{#1}}
\else
\newcommand{\vdmnotcovered}[1]{#1}
\fi

%
%configure listing style and language
%
\lstdefinelanguage{VDM_SL_10}
  {morekeywords={RESULT, abs, all, always, and, as, be, be st, bool, by, card, cases, char, comp, compose, 
conc, dcl, def, definitions, dinter, div, dlmodule, do, dom, dunion, elems, else, elseif, end,
 error, errs, exists, exists1, exit, exports, ext, false, floor, for, for all, forall, from, 
 functions, hd, if, imports, in, in set, inds, init, inmap, int, inter, inv, inverse, iota, 
 is not yet specified, lambda, len, let, map, measure, merge, mod, module, mu, munion, nat, nat1,
  nil, not, not in set, of, operations, or, others, post, power, pre, psubset, rat, rd, real, rem, 
  renamed, return, reverse, rng, seq, seq1, set, skip, specified, st, state, struct, subset, then,
   tixe, tl, to, token, traces, trap, true, types, undefined, union, uselib, values, while, with, wr,
    yet,mk\_ },
   sensitive,
   morecomment=[l]--,
   morestring=[b]",
   morestring=[b]',
  }[keywords,comments,strings]
  
\lstdefinelanguage{VDM_SL}
  {morekeywords={RESULT,\#else,\#endif,\#ifdef,\#ifndef,abs,all,always,and,as,atomic,be,be st,bool,by,card,cases,char,comp,compose,conc,dcl,def,definitions,dinter,div,dlmodule,do,dom,dunion,
  elems,else,elseif,end,eq,error,errs,exists,exists1,exit,exports,ext,false,floor,for,for all,forall,from,functions,hd,if,imports,in,in set,inds,init,inmap,int,inter,inv,inverse,iota,is,is not yet specified,is\_,lambda,len,let,map,measure,merge,mk\_,mod,module,mu,munion,nat,nat1,nil,not,not in set,of,operations,or,ord,others,post,power,pre,psubset,pure,rat,rd,real,rem,renamed,return,reverse,rng,
  seq,seq1,set,set1,skip,specified,st,state,struct,subset,then,tixe,tl,to,token,traces,trap,true,types,undefined,
  union,uselib,values,while,with,wr,yet
},
   sensitive,
   morecomment=[l]--,
   morestring=[b]",
   morestring=[b]',
  }[keywords,comments,strings]

\lstdefinelanguage{VDM_PP_10}
  {morekeywords={\#act, \#active, \#fin, \#req, \#waiting, 
 RESULT, abs, all, always, and, async, atomic, be, be st, bool, by, card, cases, char, class, 
 comp, compose, conc, dcl, def, dinter, div, do, dom, dunion, elems, else, elseif, end, error, 
 errs, exists, exists1, exit, ext, false, floor, for, for all, forall, from, functions, hd, if, 
 in, in set, inds, inmap, instance, instance variables, int, inter, inv, inverse, iota, is, 
 is not yet specified, is subclass of, is subclass responsibility, isofbaseclass, isofclass, 
 lambda, len, let, map, measure, merge, mod, mu, munion, mutex, nat, nat1, new, nil, not, not in set, 
 of, operations, or, others, per, periodic, post, power, pre, private, protected, psubset, public, rat,
  rd, real, rem, responsibility, return, reverse, rng, samebaseclass, sameclass, self, seq, seq1, set,
   skip, specified, st, start, startlist, static, subclass, subset, sync, then, thread, threadid, tixe,
    tl, to, token, traces, trap, true, types, undefined, union, values, variables, while, with, wr, yet,mk\_ },
   sensitive,
   morecomment=[l]--,
   morestring=[b]",
   morestring=[b]',
  }[keywords,comments,strings]

\lstdefinelanguage{VDM_PP}
  {morekeywords={RESULT,\#act,\#active,\#else,\#endif,\#fin,\#ifdef,\#ifndef,\#req,\#waiting,abs,all,always,and,async,atomic,be,be st,bool,by,card,cases,char,class,comp,compose,conc,dcl,def,dinter,div,do,dom,dunion,elems,else,elseif,end,
  eq,error,errs,exists,exists1,exit,ext,false,floor,for,for all,forall,from,functions,hd,if,in,in set,inds,init,inmap,instance,instance variables,int,inter,inv,inverse,iota,is,is not yet specified,is subclass of,is subclass responsibility,is\_,isofbaseclass,isofclass,lambda,len,let,map,measure,merge,mk\_,mod,mu,munion,mutex,narrow\_,
  nat,nat1,new,nil,not,not in set,obj\_,of,operations,or,ord,others,per,periodic,post,power,pre,private,protected,psubset,public,pure,rat,rd,real,rem,
  responsibility,return,reverse,rng,samebaseclass,sameclass,self,seq,seq1,set,set1,skip,specified,sporadic,st,start,
  startlist,static,stop,stoplist,subclass,subset,sync,then,thread,threadid,tixe,tl,to,token,traces,trap,true,types,undefined,
  union,values,variables,while,with,wr,yet
 },
   sensitive,
   morecomment=[l]--,
   morestring=[b]",
   morestring=[b]',
  }[keywords,comments,strings]
  

\lstdefinelanguage{VDM_RT_10}
  {morekeywords={\#act, \#active, \#fin, \#req, \#waiting, 
RESULT, abs, all, always, and, async, atomic, be, be st, bool, by, card, cases, 
char, class, comp, compose, conc, cycles, dcl, def, dinter, div, do, dom, dunion, 
duration, elems, else, elseif, end, error, errs, exists, exists1, exit, ext, false, 
floor, for, for all, forall, from, functions, hd, if, in, in set, inds, inmap, instance,
 instance variables, int, inter, inv, inverse, iota, is, is not yet specified, is subclass of, 
 is subclass responsibility, isofbaseclass, isofclass, lambda, len, let, map, measure, merge, mod,
  mu, munion, mutex, nat, nat1, new, nil, not, not in set, of, operations, or, others, per, periodic,
   post, power, pre, private, protected, psubset, public, rat, rd, real, rem, responsibility, return,
    reverse, rng, samebaseclass, sameclass, self, seq, seq1, set, skip, specified, st, start, startlist,
     static, subclass, subset, sync, system, then, thread, threadid, time, tixe, tl, to, token, traces,
      trap, true, types, undefined, union, values, variables, while, with, wr, yet,mk\_ },
   sensitive,
   morecomment=[l]--,
   morestring=[b]",
   morestring=[b]',
  }[keywords,comments,strings]

\lstdefinelanguage{VDM_RT}
  {morekeywords={RESULT,\#act,\#active,\#else,\#endif,\#fin,\#ifdef,\#ifndef,\#req,\#waiting,abs,all,always,and,async,atomic,be,be st,bool,by,card,cases,char,class,comp,compose,conc,cycles,dcl,def,dinter,div,do,dom,dunion,duration,elems,
  else,elseif,end,eq,error,errs,exists,exists1,exit,ext,false,floor,for,for all,forall,from,functions,hd,if,in,in set,inds,init,inmap,instance,instance variables,int,inter,inv,inverse,iota,is,is not yet specified,is subclass of,is subclass responsibility,is\_,isofbaseclass,isofclass,lambda,len,let,map,measure,merge,mk\_,mod,mu,munion,mutex,narrow\_,
  nat,nat1,new,nil,not,not in set,obj\_,of,operations,or,ord,others,per,periodic,post,power,pre,private,protected,psubset,public,pure,rat,rd,real,
  rem,responsibility,return,reverse,rng,samebaseclass,sameclass,self,seq,seq1,set,set1,skip,specified,sporadic,
  st,start,startlist,static,stop,stoplist,subclass,subset,sync,system,then,thread,threadid,time,tixe,tl,to,token,traces,
  trap,true,types,undefined,union,values,variables,while,with,wr,yet
 },
   sensitive,
   morecomment=[l]--,
   morestring=[b]",
   morestring=[b]',
  }[keywords,comments,strings]


%
% Define  listing for the VDM language
%
\lstdefinestyle{overtureLanguageStyle}{basicstyle=\footnotesize\ttfamily,
			frame=trBL, 
			tabsize=2, 
			linewidth=\textwidth,
			showstringspaces=false, 
			captionpos=b,
			frameround=fttt, 
			aboveskip=5mm,
			belowskip=5mm,
			framexleftmargin=0mm, 
			framexrightmargin=0mm,
			escapeinside={(*@}{@*)},
			language=VDM_SL}


% define listing environments



% Environment definition for VDM blocks
%  The listing environment vdm_al is reset to the default overture style and default dialect each time one of the overture listing environments are used.
% All listing environments are defined to take an optional parameter of the type \lstset which is applied as the last on in the environment allowing the user to change the defaults if desired:
%\begin{vdm_al}[\lstset{numbers=left}]

%Default VDM  Listing: language is set by the project from which it has been generated from. 
\lstnewenvironment{vdm_al}[1][]{\lstset{style=overtureLanguageStyle}\lstset{language=VDM_RT}\lstset{#1}}
{}

\lstnewenvironment{vdmsl}[1][]{\lstset{style=overtureLanguageStyle}\lstset{language=VDM_SL}\lstset{#1}}
{}

\lstnewenvironment{vdmsl_10}[1][]{\lstset{style=overtureLanguageStyle}\lstset{language=VDM_SL_10}\lstset{#1}}
{}

\lstnewenvironment{vdmpp}[1][]{\lstset{style=overtureLanguageStyle}\lstset{language=VDM_PP}\lstset{#1}}
{}

\lstnewenvironment{vdmpp_10}[1][]{\lstset{style=overtureLanguageStyle}\lstset{language=VDM_PP_10}\lstset{#1}}
{}

\lstnewenvironment{vdmrt}[1][]{\lstset{style=overtureLanguageStyle}\lstset{language=VDM_RT}\lstset{#1}}
{}

\lstnewenvironment{vdmrt_10}[1][]{\lstset{style=overtureLanguageStyle}\lstset{language=VDM_RT_10}\lstset{#1}}
{}

% Environment definition for test coverage use by VDM Tools
\lstnewenvironment{vdmrealtimeinfo}{}
{}

















\endinput