| 1 | \usepackage{xcolor} | 
|---|
| 2 | \usepackage{listings} | 
|---|
| 3 | % \usepackage{booktabs} | 
|---|
| 4 | % \usepackage{array} | 
|---|
| 5 | % \newcolumntype{?}{!{\vrule width 1pt}} % thick vertical line | 
|---|
| 6 |  | 
|---|
| 7 |  | 
|---|
| 8 | % like Mac Classic or iPlastic | 
|---|
| 9 | % \definecolor{basicCol}{HTML}{000000} | 
|---|
| 10 | % \definecolor{commentCol}{HTML}{0066FF} | 
|---|
| 11 | % \definecolor{stringCol}{HTML}{036A07} | 
|---|
| 12 | % \definecolor{keywordCol}{HTML}{0000FF} | 
|---|
| 13 | % \definecolor{identifierCol}{HTML}{318495} | 
|---|
| 14 |  | 
|---|
| 15 | % like Visual Studio 2010 | 
|---|
| 16 | % \definecolor{basicCol}{HTML}{000000} | 
|---|
| 17 | % \definecolor{commentCol}{HTML}{006400} | 
|---|
| 18 | % \definecolor{stringCol}{HTML}{A31515} | 
|---|
| 19 | % \definecolor{keywordCol}{HTML}{0000FF} | 
|---|
| 20 | % \definecolor{identifierCol}{HTML}{000000} | 
|---|
| 21 |  | 
|---|
| 22 | \definecolor{basicCol}{HTML}{000000} | 
|---|
| 23 | \definecolor{commentCol}{HTML}{000000} | 
|---|
| 24 | \definecolor{stringCol}{HTML}{000000} | 
|---|
| 25 | \definecolor{keywordCol}{HTML}{000000} | 
|---|
| 26 | \definecolor{identifierCol}{HTML}{000000} | 
|---|
| 27 |  | 
|---|
| 28 | % from https://gist.github.com/nikolajquorning/92bbbeef32e1dd80105c9bf2daceb89a | 
|---|
| 29 | \lstdefinelanguage{sml} { | 
|---|
| 30 | morekeywords= { | 
|---|
| 31 | 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 | 
|---|
| 32 | }, | 
|---|
| 33 | morestring=[b]", | 
|---|
| 34 | morecomment=[s]{(*}{*)}, | 
|---|
| 35 | } | 
|---|
| 36 |  | 
|---|
| 37 | \lstdefinelanguage{D}{ | 
|---|
| 38 | % Keywords | 
|---|
| 39 | morekeywords=[1]{ | 
|---|
| 40 | abstract, alias, align, auto, body, break, cast, catch, class, const, | 
|---|
| 41 | continue, debug, delegate, delete, deprecated, do, else, enum, export, | 
|---|
| 42 | false, final, finally, for, foreach, foreach_reverse, function, goto, if, | 
|---|
| 43 | immutable, import, in, inout, interface, invariant, is, lazy, macro, mixin, | 
|---|
| 44 | module, new, nothrow, null, out, override, package, pragma, private, | 
|---|
| 45 | protected, public, pure, ref, return, shared, static, struct, super, | 
|---|
| 46 | switch, synchronized, template, this, throw, true, try, typedef, typeid, | 
|---|
| 47 | typeof, union, unittest, volatile, while, with | 
|---|
| 48 | }, | 
|---|
| 49 | % Special identifiers, common functions | 
|---|
| 50 | morekeywords=[2]{enforce}, | 
|---|
| 51 | % Ugly identifiers | 
|---|
| 52 | morekeywords=[3]{ | 
|---|
| 53 | __DATE__, __EOF__, __FILE__, __LINE__, __TIMESTAMP__, __TIME__, __VENDOR__, | 
|---|
| 54 | __VERSION__, __ctfe, __gshared, __monitor, __thread, __vptr, _argptr, | 
|---|
| 55 | _arguments, _ctor, _dtor | 
|---|
| 56 | }, | 
|---|
| 57 | % Basic types | 
|---|
| 58 | morekeywords=[4]{ | 
|---|
| 59 | byte, ubyte, short, ushort, int, uint, long, ulong, cent, ucent, void, | 
|---|
| 60 | bool, bit, float, double, real, ushort, int, uint, long, ulong, float, | 
|---|
| 61 | char, wchar, dchar, string, wstring, dstring, ireal, ifloat, idouble, | 
|---|
| 62 | creal, cfloat, cdouble, size_t, ptrdiff_t, sizediff_t, equals_t, hash_t | 
|---|
| 63 | }, | 
|---|
| 64 | % Strings | 
|---|
| 65 | morestring=[b]{"}, | 
|---|
| 66 | morestring=[b]{'}, | 
|---|
| 67 | morestring=[b]{`}, | 
|---|
| 68 | % Comments | 
|---|
| 69 | comment=[l]{//}, | 
|---|
| 70 | morecomment=[s]{/*}{*/}, | 
|---|
| 71 | morecomment=[s][\color{blue}]{/**}{*/}, | 
|---|
| 72 | morecomment=[n]{/+}{+/}, | 
|---|
| 73 | morecomment=[n][\color{blue}]{/++}{+/}, | 
|---|
| 74 | % Options | 
|---|
| 75 | sensitive=true | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | \lstdefinelanguage{rust}{ | 
|---|
| 79 | % Keywords | 
|---|
| 80 | morekeywords=[1]{ | 
|---|
| 81 | abstract, alignof, as, become, box, | 
|---|
| 82 | break, const, continue, crate, do, | 
|---|
| 83 | else, enum, extern, false, final, | 
|---|
| 84 | fn, for, if, impl, in, | 
|---|
| 85 | let, loop, macro, match, mod, | 
|---|
| 86 | move, mut, offsetof, override, priv, | 
|---|
| 87 | proc, pub, pure, ref, return, | 
|---|
| 88 | Self, self, sizeof, static, struct, | 
|---|
| 89 | super, trait, true,  type, typeof, | 
|---|
| 90 | unsafe, unsized, use, virtual, where, | 
|---|
| 91 | while, yield | 
|---|
| 92 | }, | 
|---|
| 93 | % Strings | 
|---|
| 94 | morestring=[b]{"}, | 
|---|
| 95 | % Comments | 
|---|
| 96 | comment=[l]{//}, | 
|---|
| 97 | morecomment=[s]{/*}{*/}, | 
|---|
| 98 | % Options | 
|---|
| 99 | sensitive=true | 
|---|
| 100 | } | 
|---|
| 101 |  | 
|---|
| 102 | \newcommand{\KWC}{K-W C\xspace} | 
|---|
| 103 |  | 
|---|
| 104 | \renewcommand{\ttdefault}{pcr} | 
|---|
| 105 |  | 
|---|
| 106 | \lstdefinestyle{defaultStyle}{ | 
|---|
| 107 | escapeinside={@@}, | 
|---|
| 108 | basicstyle=\footnotesize\ttfamily\color{basicCol}, | 
|---|
| 109 | keywordstyle=\bfseries\color{keywordCol}, | 
|---|
| 110 | commentstyle=\itshape\color{commentCol}, | 
|---|
| 111 | identifierstyle=\color{identifierCol}, | 
|---|
| 112 | stringstyle=\color{stringCol}, | 
|---|
| 113 | mathescape=true, | 
|---|
| 114 | columns=fixed, | 
|---|
| 115 | aboveskip=4pt,                                  % spacing above/below code block | 
|---|
| 116 | belowskip=3pt, | 
|---|
| 117 | keepspaces=true, | 
|---|
| 118 | frame=lines, | 
|---|
| 119 | literate=, | 
|---|
| 120 | showlines=true,                                 % show blank lines at end of code | 
|---|
| 121 | showspaces=false, | 
|---|
| 122 | showstringspaces=false, | 
|---|
| 123 | escapechar=\$, | 
|---|
| 124 | xleftmargin=\parindentlnth,                     % indent code to paragraph indentation | 
|---|
| 125 | moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting | 
|---|
| 126 | % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting | 
|---|
| 127 | % moredelim=** allows cumulative application | 
|---|
| 128 | } | 
|---|
| 129 | \lstset{ | 
|---|
| 130 | language = CFA, | 
|---|
| 131 | style=defaultStyle | 
|---|
| 132 | } | 
|---|
| 133 | \lstMakeShortInline[basewidth=0.5em,breaklines=true,basicstyle=\normalsize\ttfamily\color{basicCol}]@  % single-character for \lstinline | 
|---|
| 134 |  | 
|---|
| 135 | \lstnewenvironment{cfacode}[1][]{ | 
|---|
| 136 | \lstset{ | 
|---|
| 137 | language = CFA, | 
|---|
| 138 | style=defaultStyle, | 
|---|
| 139 | #1 | 
|---|
| 140 | % belowcaptionskip=1\baselineskip, | 
|---|
| 141 | % breaklines=true, | 
|---|
| 142 | % frame=L, | 
|---|
| 143 | } | 
|---|
| 144 | }{} | 
|---|
| 145 |  | 
|---|
| 146 | \lstnewenvironment{cppcode}[1][]{ | 
|---|
| 147 | \lstset{ | 
|---|
| 148 | language = c++, | 
|---|
| 149 | style=defaultStyle, | 
|---|
| 150 | #1 | 
|---|
| 151 | } | 
|---|
| 152 | }{} | 
|---|
| 153 |  | 
|---|
| 154 | \lstnewenvironment{javacode}[1][]{ | 
|---|
| 155 | \lstset{ | 
|---|
| 156 | language = java, | 
|---|
| 157 | style=defaultStyle, | 
|---|
| 158 | #1 | 
|---|
| 159 | } | 
|---|
| 160 | }{} | 
|---|
| 161 |  | 
|---|
| 162 | \lstnewenvironment{scalacode}[1][]{ | 
|---|
| 163 | \lstset{ | 
|---|
| 164 | language = scala, | 
|---|
| 165 | style=defaultStyle, | 
|---|
| 166 | #1 | 
|---|
| 167 | } | 
|---|
| 168 | }{} | 
|---|
| 169 |  | 
|---|
| 170 | \lstnewenvironment{smlcode}[1][]{ | 
|---|
| 171 | \lstset{ | 
|---|
| 172 | language = sml, | 
|---|
| 173 | style=defaultStyle, | 
|---|
| 174 | #1 | 
|---|
| 175 | } | 
|---|
| 176 | }{} | 
|---|
| 177 |  | 
|---|
| 178 | \lstnewenvironment{dcode}[1][]{ | 
|---|
| 179 | \lstset{ | 
|---|
| 180 | language = D, | 
|---|
| 181 | style=defaultStyle, | 
|---|
| 182 | #1 | 
|---|
| 183 | } | 
|---|
| 184 | }{} | 
|---|
| 185 |  | 
|---|
| 186 | \lstnewenvironment{rustcode}[1][]{ | 
|---|
| 187 | \lstset{ | 
|---|
| 188 | language = rust, | 
|---|
| 189 | style=defaultStyle, | 
|---|
| 190 | #1 | 
|---|
| 191 | } | 
|---|
| 192 | }{} | 
|---|
| 193 |  | 
|---|
| 194 | \newcommand{\zero}{\lstinline{zero_t}\xspace} | 
|---|
| 195 | \newcommand{\one}{\lstinline{one_t}\xspace} | 
|---|
| 196 | \newcommand{\ateq}{\lstinline{\@=}\xspace} | 
|---|
| 197 |  | 
|---|
| 198 | % \lstset{ % | 
|---|
| 199 | %   backgroundcolor=\color{white}, | 
|---|
| 200 | %   basicstyle=\footnotesize, | 
|---|
| 201 | %   breakatwhitespace=false, | 
|---|
| 202 | %   breaklines=true, | 
|---|
| 203 | %   captionpos=b, | 
|---|
| 204 | %   commentstyle=\color{mygreen}, | 
|---|
| 205 | %   escapeinside={\%*}{*)}, | 
|---|
| 206 | %   extendedchars=true, | 
|---|
| 207 | %   frame=single, | 
|---|
| 208 | %   keywordstyle=\color{blue}, | 
|---|
| 209 | %   language=Prolog, | 
|---|
| 210 | %   numbers=left, | 
|---|
| 211 | %   numbersep=5pt, | 
|---|
| 212 | %   numberstyle=\tiny\color{mygray}, | 
|---|
| 213 | %   rulecolor=\color{black}, | 
|---|
| 214 | %   showspaces=false, | 
|---|
| 215 | %   showstringspaces=false, | 
|---|
| 216 | %   showtabs=false, | 
|---|
| 217 | %   stepnumber=2, | 
|---|
| 218 | %   stringstyle=\color{mymauve}, | 
|---|
| 219 | %   tabsize=2, | 
|---|
| 220 | %   title=\lstname, | 
|---|
| 221 | %   morekeywords={not,\},\{,preconditions,effects }, | 
|---|
| 222 | %   deletekeywords={time} | 
|---|
| 223 | % } | 
|---|