[27dde72] | 1 | \usepackage[usenames,dvipsnames]{xcolor}
|
---|
[0f9bef3] | 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 | keywordstyle=\bfseries\color{blue},
|
---|
| 101 | keywordstyle=[2]\bfseries\color{Plum},
|
---|
| 102 | commentstyle=\itshape\color{OliveGreen}, % green and italic comments
|
---|
| 103 | identifierstyle=\color{identifierCol},
|
---|
| 104 | stringstyle=\sf\color{Mahogany}, % use sanserif font
|
---|
| 105 | mathescape=true,
|
---|
| 106 | columns=fixed,
|
---|
| 107 | aboveskip=4pt, % spacing above/below code block
|
---|
| 108 | belowskip=3pt,
|
---|
| 109 | keepspaces=true,
|
---|
| 110 | % frame=lines,
|
---|
| 111 | literate=,
|
---|
| 112 | showlines=true, % show blank lines at end of code
|
---|
| 113 | showspaces=false,
|
---|
| 114 | showstringspaces=false,
|
---|
| 115 | escapechar=\$,
|
---|
| 116 | xleftmargin=\parindentlnth, % indent code to paragraph indentation
|
---|
| 117 | moredelim=[is][\color{red}\bfseries]{**R**}{**R**}, % red highlighting
|
---|
| 118 | % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
|
---|
| 119 | % moredelim=** allows cumulative application
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | \lstdefinestyle{defaultStyle}{
|
---|
| 123 | escapeinside={@@},
|
---|
| 124 | basicstyle=\linespread{0.9}\tt\footnotesize, % reduce line spacing and use typewriter font
|
---|
| 125 | keywordstyle=\bfseries\color{blue},
|
---|
| 126 | keywordstyle=[2]\bfseries\color{Plum},
|
---|
| 127 | commentstyle=\itshape\color{OliveGreen}, % green and italic comments
|
---|
| 128 | identifierstyle=\color{identifierCol},
|
---|
| 129 | stringstyle=\sf\color{Mahogany}, % use sanserif font
|
---|
| 130 | mathescape=true,
|
---|
| 131 | columns=fixed,
|
---|
| 132 | aboveskip=4pt, % spacing above/below code block
|
---|
| 133 | belowskip=3pt,
|
---|
| 134 | keepspaces=true,
|
---|
| 135 | % frame=lines,
|
---|
| 136 | literate=,
|
---|
| 137 | showlines=true, % show blank lines at end of code
|
---|
| 138 | showspaces=false,
|
---|
| 139 | showstringspaces=false,
|
---|
| 140 | escapechar=\$,
|
---|
| 141 | xleftmargin=\parindentlnth, % indent code to paragraph indentation
|
---|
| 142 | moredelim=[is][\color{red}\bfseries]{**R**}{**R**}, % red highlighting
|
---|
| 143 | % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
|
---|
| 144 | % moredelim=** allows cumulative application
|
---|
| 145 | }
|
---|
[27dde72] | 146 |
|
---|
[a029714] | 147 | \lstdefinestyle{cfaStyle}{
|
---|
| 148 | escapeinside={@@},
|
---|
| 149 | basicstyle=\linespread{0.9}\tt\footnotesize, % reduce line spacing and use typewriter font
|
---|
| 150 | keywordstyle=\bfseries\color{blue},
|
---|
| 151 | keywordstyle=[2]\bfseries\color{Plum},
|
---|
| 152 | commentstyle=\itshape\color{OliveGreen}, % green and italic comments
|
---|
| 153 | identifierstyle=\color{identifierCol},
|
---|
| 154 | stringstyle=\sf\color{Mahogany}, % use sanserif font
|
---|
| 155 | mathescape=true,
|
---|
| 156 | columns=fixed,
|
---|
| 157 | aboveskip=4pt, % spacing above/below code block
|
---|
| 158 | belowskip=3pt,
|
---|
| 159 | keepspaces=true,
|
---|
| 160 | % frame=lines,
|
---|
| 161 | literate=,
|
---|
| 162 | showlines=true, % show blank lines at end of code
|
---|
| 163 | showspaces=false,
|
---|
| 164 | showstringspaces=false,
|
---|
| 165 | escapechar=\$,
|
---|
| 166 | xleftmargin=\parindentlnth, % indent code to paragraph indentation
|
---|
| 167 | moredelim=[is][\color{red}\bfseries]{**R**}{**R**}, % red highlighting
|
---|
| 168 | morekeywords=[2]{accept, signal, signal_block, wait},
|
---|
| 169 | }
|
---|
| 170 |
|
---|
[0f9bef3] | 171 | \lstMakeShortInline[basewidth=0.5em,breaklines=true,basicstyle=\normalsize\ttfamily\color{basicCol}]@ % single-character for \lstinline
|
---|
| 172 |
|
---|
[27dde72] | 173 | \lstnewenvironment{ccode}[1][]{
|
---|
| 174 | \lstset{
|
---|
| 175 | language = C,
|
---|
| 176 | style=defaultStyle,
|
---|
| 177 | #1
|
---|
| 178 | }
|
---|
| 179 | }{}
|
---|
| 180 |
|
---|
| 181 | \lstnewenvironment{cfacode}[1][]{
|
---|
| 182 | \lstset{
|
---|
| 183 | language = CFA,
|
---|
[a029714] | 184 | style=cfaStyle,
|
---|
[27dde72] | 185 | #1
|
---|
| 186 | }
|
---|
[0f9bef3] | 187 | }{}
|
---|
| 188 |
|
---|
| 189 | \lstnewenvironment{pseudo}[1][]{
|
---|
| 190 | \lstset{
|
---|
| 191 | language = pseudo,
|
---|
| 192 | style=pseudoStyle,
|
---|
| 193 | #1
|
---|
| 194 | }
|
---|
| 195 | }{}
|
---|
| 196 |
|
---|
| 197 | \lstnewenvironment{cppcode}[1][]{
|
---|
| 198 | \lstset{
|
---|
| 199 | language = c++,
|
---|
| 200 | style=defaultStyle,
|
---|
| 201 | #1
|
---|
| 202 | }
|
---|
| 203 | }{}
|
---|
| 204 |
|
---|
[27dde72] | 205 | \lstnewenvironment{ucppcode}[1][]{
|
---|
| 206 | \lstset{
|
---|
| 207 | language = c++,
|
---|
| 208 | style=defaultStyle,
|
---|
| 209 | #1
|
---|
| 210 | }
|
---|
| 211 | }{}
|
---|
| 212 |
|
---|
[0f9bef3] | 213 | \lstnewenvironment{javacode}[1][]{
|
---|
| 214 | \lstset{
|
---|
| 215 | language = java,
|
---|
| 216 | style=defaultStyle,
|
---|
| 217 | #1
|
---|
| 218 | }
|
---|
| 219 | }{}
|
---|
| 220 |
|
---|
| 221 | \lstnewenvironment{scalacode}[1][]{
|
---|
| 222 | \lstset{
|
---|
| 223 | language = scala,
|
---|
| 224 | style=defaultStyle,
|
---|
| 225 | #1
|
---|
| 226 | }
|
---|
| 227 | }{}
|
---|
| 228 |
|
---|
| 229 | \lstnewenvironment{smlcode}[1][]{
|
---|
| 230 | \lstset{
|
---|
| 231 | language = sml,
|
---|
| 232 | style=defaultStyle,
|
---|
| 233 | #1
|
---|
| 234 | }
|
---|
| 235 | }{}
|
---|
| 236 |
|
---|
| 237 | \lstnewenvironment{dcode}[1][]{
|
---|
| 238 | \lstset{
|
---|
| 239 | language = D,
|
---|
| 240 | style=defaultStyle,
|
---|
| 241 | #1
|
---|
| 242 | }
|
---|
| 243 | }{}
|
---|
| 244 |
|
---|
| 245 | \lstnewenvironment{rustcode}[1][]{
|
---|
| 246 | \lstset{
|
---|
| 247 | language = rust,
|
---|
| 248 | style=defaultStyle,
|
---|
| 249 | #1
|
---|
| 250 | }
|
---|
| 251 | }{}
|
---|
| 252 |
|
---|
| 253 | \newcommand{\zero}{\lstinline{zero_t}\xspace}
|
---|
| 254 | \newcommand{\one}{\lstinline{one_t}\xspace}
|
---|
[27dde72] | 255 | \newcommand{\ateq}{\lstinline{\@=}\xspace}
|
---|
[a029714] | 256 | \newcommand{\code}[1]{\lstinline[language=CFA,style=cfaStyle]{#1}}
|
---|
[27dde72] | 257 | \newcommand{\pscode}[1]{\lstinline[language=pseudo,style=pseudoStyle]{#1}}
|
---|