source: doc/theses/colby_parsons_MMAth/style/cfa-format.tex@ 678c540

ADT ast-experimental stuck-waitfor-destruct
Last change on this file since 678c540 was 678c540, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

small commits before changing latex macros

  • Property mode set to 100644
File size: 8.4 KB
Line 
1\usepackage[usenames,dvipsnames]{xcolor}
2\usepackage{listings}
3\usepackage{inconsolata}
4
5\definecolor{basicCol}{HTML}{000000}
6\definecolor{commentCol}{HTML}{000000}
7\definecolor{stringCol}{HTML}{000000}
8\definecolor{keywordCol}{HTML}{000000}
9\definecolor{identifierCol}{HTML}{000000}
10
11% from https://gist.github.com/nikolajquorning/92bbbeef32e1dd80105c9bf2daceb89a
12\lstdefinelanguage{sml} {
13 morekeywords= {
14 EQUAL, GREATER, LESS, NONE, SOME, abstraction, abstype, and, andalso, array, as, before, bool, case, char, datatype, do, else, end, eqtype, exception, exn, false, fn, fun, functor, handle, if, in, include, infix, infixr, int, let, list, local, nil, nonfix, not, o, of, op, open, option, orelse, overload, print, raise, real, rec, ref, sharing, sig, signature, string, struct, structure, substring, then, true, type, unit, val, vector, where, while, with, withtype, word
15 },
16 morestring=[b]",
17 morecomment=[s]{(*}{*)},
18}
19
20\lstdefinelanguage{D}{
21 % Keywords
22 morekeywords=[1]{
23 abstract, alias, align, auto, body, break, cast, catch, class, const,
24 continue, debug, delegate, delete, deprecated, do, else, enum, export,
25 false, final, finally, for, foreach, foreach_reverse, function, goto, if,
26 immutable, import, in, inout, interface, invariant, is, lazy, macro, mixin,
27 module, new, nothrow, null, out, override, package, pragma, private,
28 protected, public, pure, ref, return, shared, static, struct, super,
29 switch, synchronized, template, this, throw, true, try, typedef, typeid,
30 typeof, union, unittest, volatile, while, with
31 },
32 % Special identifiers, common functions
33 morekeywords=[2]{enforce},
34 % Ugly identifiers
35 morekeywords=[3]{
36 __DATE__, __EOF__, __FILE__, __LINE__, __TIMESTAMP__, __TIME__, __VENDOR__,
37 __VERSION__, __ctfe, __gshared, __monitor, __thread, __vptr, _argptr,
38 _arguments, _ctor, _dtor
39 },
40 % Basic types
41 morekeywords=[4]{
42 byte, ubyte, short, ushort, int, uint, long, ulong, cent, ucent, void,
43 bool, bit, float, double, real, ushort, int, uint, long, ulong, float,
44 char, wchar, dchar, string, wstring, dstring, ireal, ifloat, idouble,
45 creal, cfloat, cdouble, size_t, ptrdiff_t, sizediff_t, equals_t, hash_t
46 },
47 % Strings
48 morestring=[b]{"},
49 morestring=[b]{'},
50 morestring=[b]{`},
51 % Comments
52 comment=[l]{//},
53 morecomment=[s]{/*}{*/},
54 morecomment=[s][\color{blue}]{/**}{*/},
55 morecomment=[n]{/+}{+/},
56 morecomment=[n][\color{blue}]{/++}{+/},
57 % Options
58 sensitive=true
59}
60
61\lstdefinelanguage{rust}{
62 % Keywords
63 morekeywords=[1]{
64 abstract, alignof, as, become, box,
65 break, const, continue, crate, do,
66 else, enum, extern, false, final,
67 fn, for, if, impl, in,
68 let, loop, macro, match, mod,
69 move, mut, offsetof, override, priv,
70 proc, pub, pure, ref, return,
71 Self, self, sizeof, static, struct,
72 super, trait, true, type, typeof,
73 unsafe, unsized, use, virtual, where,
74 while, yield
75 },
76 % Strings
77 morestring=[b]{"},
78 % Comments
79 comment=[l]{//},
80 morecomment=[s]{/*}{*/},
81 % Options
82 sensitive=true
83}
84
85\lstdefinelanguage{pseudo}{
86 morekeywords={string,uint,int,bool,float},%
87 sensitive=true,%
88 morecomment=[l]{//},%
89 morecomment=[s]{/*}{*/},%
90 morestring=[b]',%
91 morestring=[b]",%
92 morestring=[s]{`}{`},%
93}%
94
95\newcommand{\KWC}{K-W C\xspace}
96
97\lstdefinestyle{pseudoStyle}{
98 escapeinside={@@},
99% basicstyle=\linespread{0.9}\sf\footnotesize, % reduce line spacing and use typewriter font
100 basicstyle=\linespread{0.9}\sf, % reduce line spacing and use typewriter font
101% keywordstyle=\bfseries\color{blue},
102% keywordstyle=[2]\bfseries\color{Plum},
103% commentstyle=\itshape\color{OliveGreen}, % green and italic comments
104% identifierstyle=\color{identifierCol},
105% stringstyle=\sf\color{Mahogany}, % use sanserif font
106 mathescape=true,
107 columns=fixed,
108 aboveskip=4pt, % spacing above/below code block
109 belowskip=3pt,
110 keepspaces=true,
111 tabsize=4,
112 % frame=lines,
113 literate=,
114 showlines=true, % show blank lines at end of code
115 showspaces=false,
116 showstringspaces=false,
117 escapechar=\$,
118 xleftmargin=\parindentlnth, % indent code to paragraph indentation
119 moredelim=[is][\color{red}\bfseries]{**R**}{**R**}, % red highlighting
120 % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
121 % moredelim=** allows cumulative application
122}
123
124\lstdefinestyle{defaultStyle}{
125 escapeinside={@@},
126 basicstyle=\linespread{0.9}\tt\footnotesize, % reduce line spacing and use typewriter font
127 keywordstyle=\bfseries\color{blue},
128 keywordstyle=[2]\bfseries\color{Plum},
129 commentstyle=\itshape\color{OliveGreen}, % green and italic comments
130 identifierstyle=\color{identifierCol},
131 stringstyle=\sf\color{Mahogany}, % use sanserif font
132 mathescape=true,
133 columns=fixed,
134 aboveskip=4pt, % spacing above/below code block
135 belowskip=3pt,
136 keepspaces=true,
137 tabsize=4,
138 % frame=lines,
139 literate=,
140 showlines=true, % show blank lines at end of code
141 showspaces=false,
142 showstringspaces=false,
143 escapechar=\$,
144 xleftmargin=\parindentlnth, % indent code to paragraph indentation
145 moredelim=[is][\color{red}\bfseries]{**R**}{**R**}, % red highlighting
146 % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
147 % moredelim=** allows cumulative application
148}
149
150\lstdefinestyle{cfaStyle}{
151 escapeinside={@@},
152% basicstyle=\linespread{0.9}\tt\footnotesize, % reduce line spacing and use typewriter font
153 basicstyle=\linespread{0.9}\sf, % reduce line spacing and use typewriter font
154% keywordstyle=\bfseries\color{blue},
155% keywordstyle=[2]\bfseries\color{Plum},
156% commentstyle=\sf\itshape\color{OliveGreen}, % green and italic comments
157% identifierstyle=\color{identifierCol},
158% stringstyle=\sf\color{Mahogany}, % use sanserif font
159 stringstyle=\tt, % use sanserif font
160 mathescape=true,
161% columns=fixed,
162 columns=fullflexible,
163% aboveskip=4pt, % spacing above/below code block
164% belowskip=3pt,
165 keepspaces=true,
166 tabsize=4,
167 % frame=lines,
168 literate=,
169 showlines=true, % show blank lines at end of code
170 showspaces=false,
171 showstringspaces=false,
172 showlines=true, % show blank lines at end of code
173 escapechar=\$,
174 xleftmargin=\parindentlnth, % indent code to paragraph indentation
175 moredelim=[is][\color{red}\bfseries]{**R**}{**R**}, % red highlighting
176 morekeywords=[2]{accept, signal, signal_block, wait, waitfor},
177 abovecaptionskip=5pt,
178}
179
180% \lstMakeShortInline[basewidth=0.5em,breaklines=true,basicstyle=\normalsize\ttfamily\color{basicCol}]@ % single-character for \lstinline
181% \lstMakeShortInline@
182
183\lstnewenvironment{ccode}[1][]{
184 \lstset{
185 language = C,
186 style=defaultStyle,
187 captionpos=b,
188 #1
189 }
190}{}
191
192\lstnewenvironment{cfacode}[1][]{
193 \lstset{
194 language = CFA,
195 style=cfaStyle,
196 captionpos=b,
197 #1
198 }
199}{}
200
201\lstnewenvironment{pseudo}[1][]{
202 \lstset{
203 language = pseudo,
204 style=pseudoStyle,
205 captionpos=b,
206 #1
207 }
208}{}
209
210\lstnewenvironment{cppcode}[1][]{
211 \lstset{
212 language = c++,
213 style=defaultStyle,
214 captionpos=b,
215 #1
216 }
217}{}
218
219\lstnewenvironment{ucppcode}[1][]{
220 \lstset{
221 language = c++,
222 style=defaultStyle,
223 captionpos=b,
224 #1
225 }
226}{}
227
228\lstnewenvironment{javacode}[1][]{
229 \lstset{
230 language = java,
231 style=defaultStyle,
232 captionpos=b,
233 #1
234 }
235}{}
236
237\lstnewenvironment{scalacode}[1][]{
238 \lstset{
239 language = scala,
240 style=defaultStyle,
241 captionpos=b,
242 #1
243 }
244}{}
245
246\lstnewenvironment{smlcode}[1][]{
247 \lstset{
248 language = sml,
249 style=defaultStyle,
250 captionpos=b,
251 #1
252 }
253}{}
254
255\lstnewenvironment{dcode}[1][]{
256 \lstset{
257 language = D,
258 style=defaultStyle,
259 captionpos=b,
260 #1
261 }
262}{}
263
264\lstnewenvironment{rustcode}[1][]{
265 \lstset{
266 language = rust,
267 style=defaultStyle,
268 captionpos=b,
269 #1
270 }
271}{}
272
273\lstnewenvironment{gocode}[1][]{
274 \lstset{
275 language = Golang,
276 style=defaultStyle,
277 captionpos=b,
278 #1
279 }
280}{}
281
282\newcommand{\zero}{\lstinline{zero_t}\xspace}
283\newcommand{\one}{\lstinline{one_t}\xspace}
284\newcommand{\ateq}{\lstinline{\@=}\xspace}
285\newcommand{\code}[1]{\lstinline[language=CFA,style=cfaStyle]{#1}}
286\newcommand{\pscode}[1]{\lstinline[language=pseudo,style=pseudoStyle]{#1}}
Note: See TracBrowser for help on using the repository browser.