source: doc/LaTeXmacros/common.tex @ 8bc4ef8

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 8bc4ef8 was 8bc4ef8, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

small updates missing from last commit

  • Property mode set to 100644
File size: 9.5 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 : Thu Apr 28 14:41:09 2016
14%% Update Count     : 5
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\newcommand{\indexc}[1]{\index{#1@\lstinline$#1$}}
111
112\newcommand{\newtermFontInline}{\emph}
113\newcommand{\newterm}{\@ifstar\@snewterm\@newterm}
114\newcommand{\@newterm}[2][\@empty]{\lowercase{\def\temp{#2}}{\newtermFontInline{#2}}\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi}
115\newcommand{\@snewterm}[2][\@empty]{{\newtermFontInline{#2}}\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi}
116\makeatother
117
118\newenvironment{quote2}{%
119        \list{}{\lstset{resetmargins=true}\leftmargin=\parindent\rightmargin\leftmargin}%
120        \item\relax
121}{%
122        \endlist
123}% quote2
124\newenvironment{rationale}{%
125  \begin{quotation}\noindent$\Box$\enspace
126}{%
127  \hfill\enspace$\Box$\end{quotation}
128}%
129
130% blocks and titles
131\newcommand{\define}[1]{\emph{#1\/}\index{#1}}
132\newcommand{\rewrite}{\(\Rightarrow\)}
133\newcommand{\rewriterules}{\paragraph{Rewrite Rules}~\par\noindent}
134\newcommand{\examples}{\paragraph{Examples}~\par\noindent}
135\newcommand{\semantics}{\paragraph{Semantics}~\par\noindent}
136\newcommand{\constraints}{\paragraph{Constraints}~\par\noindent}
137\newcommand{\predefined}{\paragraph{Predefined Identifiers}~\par\noindent}
138
139% BNF macros
140\def\syntax{\paragraph{Syntax}\trivlist\parindent=.5in\item[\hskip.5in]}
141\let\endsyntax=\endtrivlist
142\newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}}
143\newcommand{\rhs}{\hfil\break\hbox{\hskip1in}}
144\newcommand{\oldlhs}[1]{\emph{#1: \ldots}\index{#1@{\emph{#1}}|italic}}
145\newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}}
146\newcommand{\opt}{$_{opt}$\ }
147
148% adjust varioref package with default "section" and "page" titles, and optional title with faraway page numbers
149% \VRef{label} => Section 2.7, \VPageref{label} => page 17
150% \VRef[Figure]{label} => Figure 3.4, \VPageref{label} => page 17
151\renewcommand{\reftextfaceafter}{\unskip}
152\renewcommand{\reftextfacebefore}{\unskip}
153\renewcommand{\reftextafter}{\unskip}
154\renewcommand{\reftextbefore}{\unskip}
155\renewcommand{\reftextfaraway}[1]{\unskip, p.~\pageref{#1}}
156\renewcommand{\reftextpagerange}[2]{\unskip, pp.~\pageref{#1}--\pageref{#2}}
157\newcommand{\VRef}[2][Section]{\ifx#1\@empty\else{#1}\nobreakspace\fi\vref{#2}}
158\newcommand{\VPageref}[2][page]{\ifx#1\@empty\else{#1}\nobreakspace\fi\pageref{#2}}
159
160% Go programming language
161\lstdefinelanguage{Golang}{
162        morekeywords=[1]{package,import,func,type,struct,return,defer,panic, recover,select,var,const,iota,},%
163        morekeywords=[2]{string,uint,uint8,uint16,uint32,uint64,int,int8,int16, int32,int64,
164                bool,float32,float64,complex64,complex128,byte,rune,uintptr, error,interface},%
165        morekeywords=[3]{map,slice,make,new,nil,len,cap,copy,close,true,false, delete,append,real,imag,complex,chan,},%
166        morekeywords=[4]{for,break,continue,range,goto,switch,case,fallthrough,if, else,default,},%
167        morekeywords=[5]{Println,Printf,Error,},%
168        sensitive=true,%
169        morecomment=[l]{//},%
170        morecomment=[s]{/*}{*/},%
171        morestring=[b]',%
172        morestring=[b]",%
173        morestring=[s]{`}{`},%
174}
175
176% CFA programming language, based on ANSI C
177\lstdefinelanguage{CFA}[ANSI]{C}{
178        morekeywords={_Alignas,_Alignof,__alignof,__alignof__,asm,__asm,__asm__,_At,_Atomic,__attribute,__attribute__,auto,
179                _Bool,catch,catchResume,choose,_Complex,__complex,__complex__,__const,__const__,disable,dtype,enable,__extension__,
180                fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,__label__,lvalue,_Noreturn,otype,restrict,_Static_assert,
181                _Thread_local,throw,throwResume,trait,try,typeof,__typeof,__typeof__,},
182}%
183
184\lstset{
185language=CFA,
186columns=flexible,
187basicstyle=\sf\relsize{-1},
188stringstyle=\tt,
189tabsize=4,
190xleftmargin=\parindent,
191escapechar=@,
192mathescape=true,
193keepspaces=true,
194showstringspaces=false,
195showlines=true,
196aboveskip=4pt,
197belowskip=2pt,
198moredelim=**[is][\color{red}]{`}{`}, % red highlighting of program text
199literate={\\`}{\raisebox{0.3ex}{\ttfamily\upshape \hspace*{-2pt}`}}1, % escape \`, otherwise used for red highlighting
200}%
201
202\makeatletter
203% replace/adjust listings characters that look bad in sanserif
204\lst@CCPutMacro
205\lst@ProcessOther{"22}{\lst@ttfamily{"}{\raisebox{0.3ex}{\ttfamily\upshape "}}} % replace double quote
206\lst@ProcessOther{"27}{\lst@ttfamily{'}{\raisebox{0.3ex}{\ttfamily\upshape '\hspace*{-2pt}}}} % replace single quote
207\lst@ProcessOther{"2D}{\lst@ttfamily{-}{\ttfamily\upshape -}} % replace minus
208\lst@ProcessOther{"3C}{\lst@ttfamily{<}{\texttt{<}}} % replace less than
209\lst@ProcessOther{"3E}{\lst@ttfamily{<}{\texttt{>}}} % replace greater than
210\lst@ProcessOther{"5E}{\raisebox{0.4ex}{$\scriptstyle\land\,$}} % replace circumflex
211\lst@ProcessOther{"5F}{\lst@ttfamily{\char95}{{\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}}}} % replace underscore
212\lst@ProcessOther{"60}{\lst@ttfamily{`}{\raisebox{0.3ex}{\ttfamily\upshape \hspace*{-2pt}`}}} % replace backquote
213\lst@ProcessOther{"7E}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}} % replace tilde
214%\lst@ProcessOther{"7E}{\raisebox{-.4ex}[1ex][0pt]{\textasciitilde}} % lower tilde
215\@empty\z@\@empty % NECESSARY DO NOT REMOVE
216\makeatother
217
218% Local Variables: %
219% tab-width: 4 %
220% fill-column: 100 %
221% End: %
Note: See TracBrowser for help on using the repository browser.