| 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 | \newcommand{\KWC}{K-W C\xspace}
 | 
|---|
| 79 | 
 | 
|---|
| 80 | \renewcommand{\ttdefault}{pcr}
 | 
|---|
| 81 | 
 | 
|---|
| 82 | \lstdefinestyle{defaultStyle}{
 | 
|---|
| 83 |   escapeinside={@@},
 | 
|---|
| 84 |   basicstyle=\footnotesize\ttfamily\color{basicCol},
 | 
|---|
| 85 |   keywordstyle=\bfseries\color{keywordCol},
 | 
|---|
| 86 |   commentstyle=\itshape\color{commentCol},
 | 
|---|
| 87 |   identifierstyle=\color{identifierCol},
 | 
|---|
| 88 |   stringstyle=\color{stringCol},
 | 
|---|
| 89 |   mathescape=true,
 | 
|---|
| 90 |   columns=fixed,
 | 
|---|
| 91 |   aboveskip=4pt,                                  % spacing above/below code block
 | 
|---|
| 92 |   belowskip=3pt,
 | 
|---|
| 93 |   keepspaces=true,
 | 
|---|
| 94 |   frame=lines,
 | 
|---|
| 95 |   literate=,
 | 
|---|
| 96 |   showlines=true,                                 % show blank lines at end of code
 | 
|---|
| 97 |   showspaces=false,
 | 
|---|
| 98 |   showstringspaces=false,
 | 
|---|
| 99 |   escapechar=\$,
 | 
|---|
| 100 |   xleftmargin=\parindentlnth,                     % indent code to paragraph indentation
 | 
|---|
| 101 |   moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
 | 
|---|
| 102 |   % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
 | 
|---|
| 103 |   % moredelim=** allows cumulative application
 | 
|---|
| 104 | }
 | 
|---|
| 105 | \lstset{
 | 
|---|
| 106 |   language = CFA,
 | 
|---|
| 107 |   style=defaultStyle
 | 
|---|
| 108 | }
 | 
|---|
| 109 | \lstMakeShortInline[basewidth=0.5em,breaklines=true]@  % single-character for \lstinline
 | 
|---|
| 110 | 
 | 
|---|
| 111 | \lstnewenvironment{cfacode}[1][]{
 | 
|---|
| 112 |   \lstset{
 | 
|---|
| 113 |     language = CFA,
 | 
|---|
| 114 |     style=defaultStyle,
 | 
|---|
| 115 |     #1
 | 
|---|
| 116 |     % belowcaptionskip=1\baselineskip,
 | 
|---|
| 117 |     % breaklines=true,
 | 
|---|
| 118 |     % frame=L,
 | 
|---|
| 119 |   }
 | 
|---|
| 120 | }{}
 | 
|---|
| 121 | 
 | 
|---|
| 122 | \lstnewenvironment{cppcode}[1][]{
 | 
|---|
| 123 |   \lstset{
 | 
|---|
| 124 |     language = c++,
 | 
|---|
| 125 |     style=defaultStyle,
 | 
|---|
| 126 |     #1
 | 
|---|
| 127 |   }
 | 
|---|
| 128 | }{}
 | 
|---|
| 129 | 
 | 
|---|
| 130 | \lstnewenvironment{javacode}[1][]{
 | 
|---|
| 131 |   \lstset{
 | 
|---|
| 132 |     language = java,
 | 
|---|
| 133 |     style=defaultStyle,
 | 
|---|
| 134 |     #1
 | 
|---|
| 135 |   }
 | 
|---|
| 136 | }{}
 | 
|---|
| 137 | 
 | 
|---|
| 138 | \lstnewenvironment{scalacode}[1][]{
 | 
|---|
| 139 |   \lstset{
 | 
|---|
| 140 |     language = scala,
 | 
|---|
| 141 |     style=defaultStyle,
 | 
|---|
| 142 |     #1
 | 
|---|
| 143 |   }
 | 
|---|
| 144 | }{}
 | 
|---|
| 145 | 
 | 
|---|
| 146 | \lstnewenvironment{smlcode}[1][]{
 | 
|---|
| 147 |   \lstset{
 | 
|---|
| 148 |     language = sml,
 | 
|---|
| 149 |     style=defaultStyle,
 | 
|---|
| 150 |     #1
 | 
|---|
| 151 |   }
 | 
|---|
| 152 | }{}
 | 
|---|
| 153 | 
 | 
|---|
| 154 | \lstnewenvironment{dcode}[1][]{
 | 
|---|
| 155 |   \lstset{
 | 
|---|
| 156 |     language = D,
 | 
|---|
| 157 |     style=defaultStyle,
 | 
|---|
| 158 |     #1
 | 
|---|
| 159 |   }
 | 
|---|
| 160 | }{}
 | 
|---|
| 161 | 
 | 
|---|
| 162 | \newcommand{\zero}{\lstinline{zero_t}\xspace}
 | 
|---|
| 163 | \newcommand{\one}{\lstinline{one_t}\xspace}
 | 
|---|
| 164 | \newcommand{\ateq}{\lstinline{\@=}\xspace}
 | 
|---|
| 165 | 
 | 
|---|
| 166 | % \lstset{ %
 | 
|---|
| 167 | %   backgroundcolor=\color{white},
 | 
|---|
| 168 | %   basicstyle=\footnotesize,
 | 
|---|
| 169 | %   breakatwhitespace=false,
 | 
|---|
| 170 | %   breaklines=true,
 | 
|---|
| 171 | %   captionpos=b,
 | 
|---|
| 172 | %   commentstyle=\color{mygreen},
 | 
|---|
| 173 | %   escapeinside={\%*}{*)},
 | 
|---|
| 174 | %   extendedchars=true,
 | 
|---|
| 175 | %   frame=single,
 | 
|---|
| 176 | %   keywordstyle=\color{blue},
 | 
|---|
| 177 | %   language=Prolog,
 | 
|---|
| 178 | %   numbers=left,
 | 
|---|
| 179 | %   numbersep=5pt,
 | 
|---|
| 180 | %   numberstyle=\tiny\color{mygray},
 | 
|---|
| 181 | %   rulecolor=\color{black},
 | 
|---|
| 182 | %   showspaces=false,
 | 
|---|
| 183 | %   showstringspaces=false,
 | 
|---|
| 184 | %   showtabs=false,
 | 
|---|
| 185 | %   stepnumber=2,
 | 
|---|
| 186 | %   stringstyle=\color{mymauve},
 | 
|---|
| 187 | %   tabsize=2,
 | 
|---|
| 188 | %   title=\lstname,
 | 
|---|
| 189 | %   morekeywords={not,\},\{,preconditions,effects },
 | 
|---|
| 190 | %   deletekeywords={time}
 | 
|---|
| 191 | % }
 | 
|---|