1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
2 | %%
|
---|
3 | %% Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
|
---|
4 | %%
|
---|
5 | %% The contents of this file are covered under the licence agreement in the
|
---|
6 | %% file "LICENCE" distributed with Cforall.
|
---|
7 | %%
|
---|
8 | %% common.tex --
|
---|
9 | %%
|
---|
10 | %% Author : Peter A. Buhr
|
---|
11 | %% Created On : Sat Apr 9 10:06:17 2016
|
---|
12 | %% Last Modified By : Peter A. Buhr
|
---|
13 | %% Last Modified On : Wed May 4 08:01:10 2016
|
---|
14 | %% Update Count : 54
|
---|
15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
16 |
|
---|
17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
18 |
|
---|
19 | % Names used in the document.
|
---|
20 |
|
---|
21 | \newcommand{\CFA}{C$\mathbf\forall$\xspace} % set language symbolic name
|
---|
22 | \newcommand{\CFL}{Cforall\xspace} % set language text name
|
---|
23 | \newcommand{\CC}{C\kern-.1em\hbox{+\kern-.25em+}\xspace} % CC symbolic name
|
---|
24 | \def\c11{ISO/IEC C} % C11 name (cannot have numbers in latex command name)
|
---|
25 |
|
---|
26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
27 |
|
---|
28 | \makeatletter
|
---|
29 | % allow escape sequence in lstinline
|
---|
30 | %\usepackage{etoolbox}
|
---|
31 | %\patchcmd{\lsthk@TextStyle}{\let\lst@DefEsc\@empty}{}{}{\errmessage{failed to patch}}
|
---|
32 |
|
---|
33 | % make fontsize "small" slightly larger, specifically for san serif (helvetica) in program code
|
---|
34 | \renewcommand\small{%
|
---|
35 | \@setfontsize\small{8.5}{11}%
|
---|
36 | \abovedisplayskip 8.5pt \@plus 3pt \@minus 4pt
|
---|
37 | \abovedisplayshortskip \z@ \@plus 2pt
|
---|
38 | \belowdisplayshortskip 4pt \@plus 2pt \@minus 2pt
|
---|
39 | \def\@listi{\leftmargin\leftmargini
|
---|
40 | \topsep 4pt \@plus 2pt \@minus 2pt
|
---|
41 | \parsep 2pt \@pluspt \@minuspt
|
---|
42 | \itemsep \parsep}%
|
---|
43 | \belowdisplayskip \abovedisplayskip
|
---|
44 | }
|
---|
45 | \usepackage{relsize} % must be after change to small or selects old size
|
---|
46 |
|
---|
47 | % reduce size of chapter/section titles
|
---|
48 | \def\@makechapterhead#1{%
|
---|
49 | \vspace*{50\p@}%
|
---|
50 | {\parindent \z@ \raggedright \normalfont
|
---|
51 | \ifnum \c@secnumdepth >\m@ne
|
---|
52 | \large\bfseries \@chapapp\space \thechapter
|
---|
53 | \par\nobreak
|
---|
54 | \vskip 5\p@
|
---|
55 | \fi
|
---|
56 | \interlinepenalty\@M
|
---|
57 | \Large \bfseries #1\par\nobreak
|
---|
58 | \vskip 50\p@
|
---|
59 | }}
|
---|
60 | \def\@makeschapterhead#1{%
|
---|
61 | \vspace*{50\p@}%
|
---|
62 | {\parindent \z@ \raggedright
|
---|
63 | \normalfont
|
---|
64 | \interlinepenalty\@M
|
---|
65 | \Large \bfseries #1\par\nobreak
|
---|
66 | \vskip 50\p@
|
---|
67 | }}
|
---|
68 | \renewcommand\section{\@startsection{section}{1}{\z@}{-3.5ex \@plus -1ex \@minus -.2ex}{2.3ex \@plus .2ex}{\normalfont\large\bfseries}}
|
---|
69 | \renewcommand\subsection{\@startsection{subsection}{2}{\z@}{-3.25ex \@plus -1ex \@minus -.2ex}{1.5ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
|
---|
70 | \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}{-2.5ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
|
---|
71 | \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}{-2.0ex \@plus -1ex \@minus -.2ex}{-1em}{\normalfont\normalsize\bfseries}}
|
---|
72 |
|
---|
73 | % index macros
|
---|
74 | \newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
|
---|
75 | \newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
|
---|
76 | \newcommand{\see}[1]{\emph{see} #1}
|
---|
77 |
|
---|
78 | % reduce bullet size and spacing for "itemize" macro
|
---|
79 | \renewcommand{\labelitemi}{{\raisebox{0.25ex}{\footnotesize$\bullet$}}}
|
---|
80 | \renewenvironment{itemize}{\begin{list}{\labelitemi}{\topsep=5pt\itemsep=5pt\parsep=0pt}}{\end{list}}
|
---|
81 |
|
---|
82 | % Define some commands that produce formatted index entries suitable for cross-references.
|
---|
83 | % ``\spec'' produces entries for specifications of entities. ``\impl'' produces entries for their
|
---|
84 | % implementations, and ``\use'' for their uses.
|
---|
85 |
|
---|
86 | % \newcommand{\bold}[1]{{\bf #1}}
|
---|
87 | % \def\spec{\@bsphack\begingroup
|
---|
88 | % \def\protect##1{\string##1\space}\@sanitize
|
---|
89 | % \@wrxref{|bold}}
|
---|
90 | \def\impl{\@bsphack\begingroup
|
---|
91 | \def\protect##1{\string##1\space}\@sanitize
|
---|
92 | \@wrxref{|definition}}
|
---|
93 | \newcommand{\indexcode}[1]{{\lstinline$#1$}}
|
---|
94 | \def\use{\@bsphack\begingroup
|
---|
95 | \def\protect##1{\string##1\space}\@sanitize
|
---|
96 | \@wrxref{|hyperpage}}
|
---|
97 | \def\@wrxref#1#2{\let\thepage\relax
|
---|
98 | \xdef\@gtempa{\write\@indexfile{\string
|
---|
99 | \indexentry{#2@{\lstinline$#2$}#1}{\thepage}}}\endgroup\@gtempa
|
---|
100 | \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
|
---|
101 | %\newcommand{\use}[1]{\index{#1@{\lstinline$#1$}}}
|
---|
102 | %\newcommand{\impl}[1]{\index{\protect#1@{\lstinline$\protect#1$}|definition}}
|
---|
103 |
|
---|
104 | % inline text and lowercase index: \Index{inline and lowercase index text}
|
---|
105 | % inline text and as-in index: \Index[as-is index text]{inline text}
|
---|
106 | % inline text but index with different as-is text: \Index[index text]{inline text}
|
---|
107 | \newcommand{\Index}{\@ifstar\@sIndex\@Index}
|
---|
108 | \newcommand{\@Index}[2][\@empty]{\lowercase{\def\temp{#2}}#2\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi}
|
---|
109 | \newcommand{\@sIndex}[2][\@empty]{#2\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi}
|
---|
110 |
|
---|
111 | \newcommand{\Indexc}[1]{\lstinline$#1$\index{#1@\lstinline$#1$}}
|
---|
112 | \newcommand{\indexc}[1]{\index{#1@\lstinline$#1$}}
|
---|
113 |
|
---|
114 | \newcommand{\newtermFontInline}{\emph}
|
---|
115 | \newcommand{\newterm}{\@ifstar\@snewterm\@newterm}
|
---|
116 | \newcommand{\@newterm}[2][\@empty]{\lowercase{\def\temp{#2}}{\newtermFontInline{#2}}\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi}
|
---|
117 | \newcommand{\@snewterm}[2][\@empty]{{\newtermFontInline{#2}}\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi}
|
---|
118 | \makeatother
|
---|
119 |
|
---|
120 | \newenvironment{quote2}{%
|
---|
121 | \list{}{\lstset{resetmargins=true}\leftmargin=\parindent\rightmargin\leftmargin}%
|
---|
122 | \item\relax
|
---|
123 | }{%
|
---|
124 | \endlist
|
---|
125 | }% quote2
|
---|
126 | \newenvironment{rationale}{%
|
---|
127 | \begin{quotation}\noindent$\Box$\enspace
|
---|
128 | }{%
|
---|
129 | \hfill\enspace$\Box$\end{quotation}
|
---|
130 | }%
|
---|
131 |
|
---|
132 | % blocks and titles
|
---|
133 | \newcommand{\define}[1]{\emph{#1\/}\index{#1}}
|
---|
134 | \newcommand{\rewriterules}{\paragraph{Rewrite Rules}~\par\noindent}
|
---|
135 | \newcommand{\examples}{\paragraph{Examples}~\par\noindent}
|
---|
136 | \newcommand{\semantics}{\paragraph{Semantics}~\par\noindent}
|
---|
137 | \newcommand{\constraints}{\paragraph{Constraints}~\par\noindent}
|
---|
138 | \newcommand{\predefined}{\paragraph{Predefined Identifiers}~\par\noindent}
|
---|
139 |
|
---|
140 | % BNF macros
|
---|
141 | \def\syntax{\paragraph{Syntax}\trivlist\parindent=.5in\item[\hskip.5in]}
|
---|
142 | \let\endsyntax=\endtrivlist
|
---|
143 | \newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}}
|
---|
144 | \newcommand{\rhs}{\hfil\break\hbox{\hskip1in}}
|
---|
145 | \newcommand{\oldlhs}[1]{\emph{#1: \dots}\index{#1@{\emph{#1}}|italic}}
|
---|
146 | \newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}}
|
---|
147 | \newcommand{\opt}{$_{opt}$\ }
|
---|
148 |
|
---|
149 | % adjust varioref package with default "section" and "page" titles, and optional title with faraway page numbers
|
---|
150 | % \VRef{label} => Section 2.7, \VPageref{label} => page 17
|
---|
151 | % \VRef[Figure]{label} => Figure 3.4, \VPageref{label} => page 17
|
---|
152 | \renewcommand{\reftextfaceafter}{\unskip}
|
---|
153 | \renewcommand{\reftextfacebefore}{\unskip}
|
---|
154 | \renewcommand{\reftextafter}{\unskip}
|
---|
155 | \renewcommand{\reftextbefore}{\unskip}
|
---|
156 | \renewcommand{\reftextfaraway}[1]{\unskip, p.~\pageref{#1}}
|
---|
157 | \renewcommand{\reftextpagerange}[2]{\unskip, pp.~\pageref{#1}--\pageref{#2}}
|
---|
158 | \newcommand{\VRef}[2][Section]{\ifx#1\@empty\else{#1}\nobreakspace\fi\vref{#2}}
|
---|
159 | \newcommand{\VPageref}[2][page]{\ifx#1\@empty\else{#1}\nobreakspace\fi\pageref{#2}}
|
---|
160 |
|
---|
161 | % Go programming language
|
---|
162 | \lstdefinelanguage{Golang}{
|
---|
163 | morekeywords=[1]{package,import,func,type,struct,return,defer,panic, recover,select,var,const,iota,},%
|
---|
164 | morekeywords=[2]{string,uint,uint8,uint16,uint32,uint64,int,int8,int16, int32,int64,
|
---|
165 | bool,float32,float64,complex64,complex128,byte,rune,uintptr, error,interface},%
|
---|
166 | morekeywords=[3]{map,slice,make,new,nil,len,cap,copy,close,true,false, delete,append,real,imag,complex,chan,},%
|
---|
167 | morekeywords=[4]{for,break,continue,range,goto,switch,case,fallthrough,if, else,default,},%
|
---|
168 | morekeywords=[5]{Println,Printf,Error,},%
|
---|
169 | sensitive=true,%
|
---|
170 | morecomment=[l]{//},%
|
---|
171 | morecomment=[s]{/*}{*/},%
|
---|
172 | morestring=[b]',%
|
---|
173 | morestring=[b]",%
|
---|
174 | morestring=[s]{`}{`},%
|
---|
175 | }
|
---|
176 |
|
---|
177 | % CFA programming language, based on ANSI C
|
---|
178 | \lstdefinelanguage{CFA}[ANSI]{C}{
|
---|
179 | morekeywords={_Alignas,_Alignof,__alignof,__alignof__,asm,__asm,__asm__,_At,_Atomic,__attribute,__attribute__,auto,
|
---|
180 | _Bool,catch,catchResume,choose,_Complex,__complex,__complex__,__const,__const__,disable,dtype,enable,__extension__,
|
---|
181 | fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,__label__,lvalue,_Noreturn,otype,restrict,_Static_assert,
|
---|
182 | _Thread_local,throw,throwResume,trait,try,typeof,__typeof,__typeof__,},
|
---|
183 | }%
|
---|
184 |
|
---|
185 | \lstset{
|
---|
186 | language=CFA,
|
---|
187 | columns=flexible,
|
---|
188 | basicstyle=\sf\relsize{-1},
|
---|
189 | stringstyle=\tt,
|
---|
190 | tabsize=4,
|
---|
191 | xleftmargin=\parindent,
|
---|
192 | extendedchars=true,
|
---|
193 | escapechar=§,
|
---|
194 | mathescape=true,
|
---|
195 | keepspaces=true,
|
---|
196 | showstringspaces=false,
|
---|
197 | showlines=true,
|
---|
198 | aboveskip=4pt,
|
---|
199 | belowskip=2pt,
|
---|
200 | moredelim=**[is][\color{red}]{®}{®}, % red highlighting
|
---|
201 | % moredelim=**[is][\color{blue}]{¢}{¢}, % blue highlighting
|
---|
202 | moredelim=[is][\lstset{keywords={}}]{¶}{¶}, % temporarily turn off keywords
|
---|
203 | % literate={\\`}{\raisebox{0.3ex}{\ttfamily\upshape \hspace*{-2pt}`}}1, % escape \`, otherwise used for red highlighting
|
---|
204 | literate={...}{{$\dots$}}1 {<-}{{$\leftarrow$}}1 {=>}{{$\Rightarrow$}}1,
|
---|
205 | }%
|
---|
206 |
|
---|
207 | \lstMakeShortInline© % single-character for \lstinline
|
---|
208 |
|
---|
209 | \makeatletter
|
---|
210 | % replace/adjust listings characters that look bad in sanserif
|
---|
211 | \lst@CCPutMacro
|
---|
212 | \lst@ProcessOther{"22}{\lst@ttfamily{"}{\raisebox{0.3ex}{\ttfamily\upshape "}}} % replace double quote
|
---|
213 | \lst@ProcessOther{"27}{\lst@ttfamily{'}{\raisebox{0.3ex}{\ttfamily\upshape '\hspace*{-2pt}}}} % replace single quote
|
---|
214 | \lst@ProcessOther{"2D}{\lst@ttfamily{-}{\textbf{\texttt{-}}}} % replace minus
|
---|
215 | \lst@ProcessOther{"3C}{\lst@ttfamily{<}{\textbf{\texttt{<}}}} % replace less than
|
---|
216 | \lst@ProcessOther{"3E}{\lst@ttfamily{>}{\textbf{\texttt{>}}}} % replace greater than
|
---|
217 | \lst@ProcessOther{"5E}{\raisebox{0.4ex}{$\scriptstyle\land\,$}} % replace circumflex
|
---|
218 | \lst@ProcessOther{"5F}{\lst@ttfamily{\char95}{{\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}}}} % replace underscore
|
---|
219 | \lst@ProcessOther{"60}{\lst@ttfamily{`}{\raisebox{0.3ex}{\ttfamily\upshape \hspace*{-2pt}`}}} % replace backquote
|
---|
220 | \lst@ProcessOther{"7E}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}} % replace tilde
|
---|
221 | %\lst@ProcessOther{"7E}{\raisebox{-.4ex}[1ex][0pt]{\textasciitilde}} % lower tilde
|
---|
222 | \@empty\z@\@empty % NECESSARY DO NOT REMOVE
|
---|
223 | \makeatother
|
---|
224 |
|
---|
225 | % Local Variables: %
|
---|
226 | % tab-width: 4 %
|
---|
227 | % fill-column: 100 %
|
---|
228 | % End: %
|
---|