source: doc/LaTeXmacros/common.tex @ d14d96a

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since d14d96a was e229c22, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

change gitignore with respect to latex-generated files, small updates to manuals, replace bibtex link with actual file

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