- Timestamp:
- Apr 9, 2016, 10:04:50 AM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 37218fc, df2be83
- Parents:
- 9827c7ba
- Location:
- doc/user
- Files:
-
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user/Makefile
r9827c7ba re55ca05 1 1 ## Define the appropriate configuration variables. 2 2 3 TeXLIB = .: :3 TeXLIB = .:../bibliography/:../LaTeXmacros/: 4 4 LaTeX = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex 5 BibTeX = B STINPUTS=${TeXLIB} && export BSTINPUTS && bibtex5 BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex 6 6 7 7 ## Define the text source files. … … 43 43 dvips $< -o $@ 44 44 45 ${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex ${basename ${DOCUMENT}}.bib /usr/local/bibliographies/pl.bib 45 ${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \ 46 ../LaTeXmacros/common.tex ../LaTeXmacros/indexstyle ../bibliography/cfa.bib 46 47 # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run. 47 48 if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi … … 53 54 -${BibTeX} ${basename $@} 54 55 # Make index from *.aux entries and input index at end of document 55 makeindex -s indexstyle ${basename $@}.idx56 makeindex -s ../LaTeXmacros/indexstyle ${basename $@}.idx 56 57 ${LaTeX} ${basename $@}.tex 57 58 # Run again to get index title into table of contents -
doc/user/user.tex
r9827c7ba re55ca05 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Wed Apr 6 17:37:39201614 %% Update Count : 3413 %% Last Modified On : Fri Apr 8 11:40:53 2016 14 %% Update Count : 42 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 43 43 % Names used in the document. 44 44 45 \newcommand{\CFA}{C$\mathbf\forall$\xspace} % set language symbolic name46 \newcommand{\CFL}{Cforall\xspace} % set language text name47 \newcommand{\CC}{C\kern-.1em\hbox{+\kern-.25em+}\xspace} % CC symbolic name48 \def\c11{ISO/IEC C} % C11 name (cannot have numbers in latex command name)49 45 \newcommand{\CS}{C\raisebox{-0.9ex}{\large$^\sharp$}\xspace} 50 46 … … 52 48 53 49 % Bespoke macros used in the document. 54 55 \makeatletter 56 % allow escape sequence in lstinline 57 %\usepackage{etoolbox} 58 %\patchcmd{\lsthk@TextStyle}{\let\lst@DefEsc\@empty}{}{}{\errmessage{failed to patch}} 59 60 \renewcommand\small{% 61 \@setfontsize\small{8.5}{11}% 62 \abovedisplayskip 8.5pt \@plus 3pt \@minus 4pt 63 \abovedisplayshortskip \z@ \@plus 2pt 64 \belowdisplayshortskip 4pt \@plus 2pt \@minus 2pt 65 \def\@listi{\leftmargin\leftmargini 66 \topsep 4pt \@plus 2pt \@minus 2pt 67 \parsep 2pt \@pluspt \@minuspt 68 \itemsep \parsep}% 69 \belowdisplayskip \abovedisplayskip 70 } 71 \usepackage{relsize} % must be after change to small 72 73 \renewcommand{\labelitemi}{{\raisebox{0.25ex}{\footnotesize$\bullet$}}} 74 \renewenvironment{itemize}{\begin{list}{\labelitemi}{\topsep=5pt\itemsep=5pt\parsep=0pt}}{\end{list}} 75 76 % Reduce size of section titles 77 \renewcommand\section{\@startsection{section}{1}{\z@}{-3.0ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\large\bfseries}} 78 \renewcommand\subsection{\@startsection{subsection}{2}{\z@}{-2.5ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\normalsize\bfseries}} 79 \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}{-2.5ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\normalsize\bfseries}} 80 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}{-2.0ex \@plus -1ex \@minus -.2ex}{-1em}{\normalfont\normalsize\bfseries}} 81 82 % index macros 83 \newcommand{\italic}[1]{\emph{\hyperpage{#1}}} 84 \newcommand{\definition}[1]{\textbf{\hyperpage{#1}}} 85 \newcommand{\see}[1]{\emph{see} #1} 86 87 % Define some commands that produce formatted index entries suitable for cross-references. 88 % ``\spec'' produces entries for specifications of entities. ``\impl'' produces entries for their 89 % implementations, and ``\use'' for their uses. 90 91 % \newcommand{\bold}[1]{{\bf #1}} 92 % \def\spec{\@bsphack\begingroup 93 % \def\protect##1{\string##1\space}\@sanitize 94 % \@wrxref{|bold}} 95 \def\impl{\@bsphack\begingroup 96 \def\protect##1{\string##1\space}\@sanitize 97 \@wrxref{|definition}} 98 \newcommand{\indexcode}[1]{{\lstinline$#1$}} 99 \def\use{\@bsphack\begingroup 100 \def\protect##1{\string##1\space}\@sanitize 101 \@wrxref{|hyperpage}} 102 \def\@wrxref#1#2{\let\thepage\relax 103 \xdef\@gtempa{\write\@indexfile{\string 104 \indexentry{#2@{\lstinline$#2$}#1}{\thepage}}}\endgroup\@gtempa 105 \if@nobreak \ifvmode\nobreak\fi\fi\@esphack} 106 %\newcommand{\use}[1]{\index{#1@{\lstinline$#1$}}} 107 %\newcommand{\impl}[1]{\index{\protect#1@{\lstinline$\protect#1$}|definition}} 108 109 % inline text and lowercase index: \Index{inline and lowercase index text} 110 % inline text and as-in index: \Index[as-is index text]{inline text} 111 % inline text but index with different as-is text: \Index[index text]{inline text} 112 \newcommand{\Index}{\@ifstar\@sIndex\@Index} 113 \newcommand{\@Index}[2][\@empty]{\lowercase{\def\temp{#2}}#2\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi} 114 \newcommand{\@sIndex}[2][\@empty]{#2\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi} 115 116 \newcommand{\newtermFontInline}{\emph} 117 \newcommand{\newterm}{\@ifstar\@snewterm\@newterm} 118 \newcommand{\@newterm}[2][\@empty]{\lowercase{\def\temp{#2}}{\newtermFontInline{#2}}\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi} 119 \newcommand{\@snewterm}[2][\@empty]{{\newtermFontInline{#2}}\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi} 120 \makeatother 121 122 % blocks and titles 123 \newenvironment{quote2}{% 124 \list{}{\lstset{resetmargins=true}\leftmargin=\parindent\rightmargin\leftmargin}% 125 \item\relax 126 }{% 127 \endlist 128 }% quote2 129 \newenvironment{rationale}{% 130 \begin{quotation}\noindent$\Box$\enspace 131 }{% 132 \hfill\enspace$\Box$\end{quotation} 133 }% 134 \newcommand{\define}[1]{\emph{#1\/}\index{#1}} 135 \newcommand{\rewrite}{\(\Rightarrow\)} 136 \newcommand{\rewriterules}{\paragraph{Rewrite Rules}~\par\noindent} 137 \newcommand{\examples}{\paragraph{Examples}~\par\noindent} 138 \newcommand{\semantics}{\paragraph{Semantics}~\par\noindent} 139 \newcommand{\constraints}{\paragraph{Constraints}~\par\noindent} 140 \newcommand{\predefined}{\paragraph{Predefined Identifiers}~\par\noindent} 141 142 % BNF macros 143 \def\syntax{\paragraph{Syntax}\trivlist\parindent=.5in\item[\hskip.5in]} 144 \let\endsyntax=\endtrivlist 145 \newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}} 146 \newcommand{\rhs}{\hfil\break\hbox{\hskip1in}} 147 \newcommand{\oldlhs}[1]{\emph{#1: \ldots}\index{#1@{\emph{#1}}|italic}} 148 \newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}} 149 \newcommand{\opt}{$_{opt}$\ } 150 151 % adjust varioref package with default "section" and "page" titles, and optional title with faraway page numbers 152 % \VRef{label} => Section 2.7, \VPageref{label} => page 17 153 % \VRef[Figure]{label} => Figure 3.4, \VPageref{label} => page 17 154 \renewcommand{\reftextfaceafter}{\unskip} 155 \renewcommand{\reftextfacebefore}{\unskip} 156 \renewcommand{\reftextafter}{\unskip} 157 \renewcommand{\reftextbefore}{\unskip} 158 \renewcommand{\reftextfaraway}[1]{\unskip, p.~\pageref{#1}} 159 \renewcommand{\reftextpagerange}[2]{\unskip, pp.~\pageref{#1}--\pageref{#2}} 160 \newcommand{\VRef}[2][Section]{\ifx#1\@empty\else{#1}\nobreakspace\fi\vref{#2}} 161 \newcommand{\VPageref}[2][page]{\ifx#1\@empty\else{#1}\nobreakspace\fi\pageref{#2}} 162 163 % Go programming language 164 \lstdefinelanguage{Golang}% 165 {morekeywords=[1]{package,import,func,type,struct,return,defer,panic, recover,select,var,const,iota,},% 166 morekeywords=[2]{string,uint,uint8,uint16,uint32,uint64,int,int8,int16, int32,int64, 167 bool,float32,float64,complex64,complex128,byte,rune,uintptr, error,interface},% 168 morekeywords=[3]{map,slice,make,new,nil,len,cap,copy,close,true,false, delete,append,real,imag,complex,chan,},% 169 morekeywords=[4]{for,break,continue,range,goto,switch,case,fallthrough,if, else,default,},% 170 morekeywords=[5]{Println,Printf,Error,},% 171 sensitive=true,% 172 morecomment=[l]{//},% 173 morecomment=[s]{/*}{*/},% 174 morestring=[b]',% 175 morestring=[b]",% 176 morestring=[s]{`}{`},% 177 } 178 179 % CFA based on ANSI C 180 \lstdefinelanguage{CFA}[ANSI]{C}% 181 {morekeywords={_Alignas,_Alignof,__alignof,__alignof__,asm,__asm,__asm__,_At,_Atomic,__attribute,__attribute__,auto, 182 _Bool,catch,catchResume,choose,_Complex,__complex,__complex__,__const,__const__,disable,dtype,enable,__extension__, 183 fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,__label__,lvalue,_Noreturn,otype,restrict,_Static_assert, 184 _Thread_local,throw,throwResume,trait,try,typeof,__typeof,__typeof__,}, 185 moredelim=**[is][\color{red}]{`}{`}, 186 }% 187 188 \lstset{ 189 language=CFA, 190 columns=flexible, 191 basicstyle=\sf\relsize{-1}, 192 tabsize=4, 193 xleftmargin=\parindent, 194 escapechar=@, 195 mathescape=true, 196 keepspaces=true, 197 showstringspaces=false, 198 showlines=true, 199 aboveskip=6pt, 200 belowskip=4pt, 201 literate={\\`}{\raisebox{0.3ex}{\ttfamily\upshape \hspace*{-2pt}`}}1, % escape \`, otherwise used to highlight in red 202 %extendedchars=true, 203 }% 204 205 \makeatletter 206 % replace/adjust listings characters that look bad in sanserif 207 \lst@CCPutMacro 208 \lst@ProcessOther{"22}{\lst@ttfamily{"}{\raisebox{0.3ex}{\ttfamily\upshape "}}} % replace double quote 209 \lst@ProcessOther{"27}{\lst@ttfamily{'}{\raisebox{0.3ex}{\ttfamily\upshape '\hspace*{-2pt}}}} % replace single quote 210 \lst@ProcessOther{"2D}{\lst@ttfamily{-}{\ttfamily\upshape -}} % replace minus 211 \lst@ProcessOther{"3C}{\lst@ttfamily{<}{\texttt{<}}} % replace less than 212 \lst@ProcessOther{"3E}{\lst@ttfamily{<}{\texttt{>}}} % replace greater than 213 \lst@ProcessOther{"5E}{\raisebox{0.4ex}{$\scriptstyle\land\,$}} % replace circumflex 214 \lst@ProcessOther{"5F}{\lst@ttfamily{\char95}{{\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}}}} % replace underscore 215 \lst@ProcessOther{"60}{\lst@ttfamily{`}{\raisebox{0.3ex}{\ttfamily\upshape \hspace*{-2pt}`}}} % replace backquote 216 \lst@ProcessOther{"7E}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}} % replace tilde 217 %\lst@ProcessOther{"7E}{\raisebox{-.4ex}[1ex][0pt]{\textasciitilde}} % lower tilde 218 \@empty\z@\@empty 219 \makeatother 50 \input{common} 220 51 221 52 \setcounter{secnumdepth}{3} % number subsubsections … … 4573 4404 4574 4405 4406 \section{Rational Numbers} 4407 \label{s:RationalNumbers} 4408 4409 Rational numbers are numbers written as a ratio, i.e., as a fraction, where the numerator (top number) and the denominator (bottom number) are whole numbers. 4410 When creating and computing with rational numbers, results are constantly reduced to keep the numerator and denominator as small as possible. 4411 4412 \begin{lstlisting} 4413 // implementation 4414 struct Rational { 4415 long int numerator, denominator; // invariant: denominator > 0 4416 }; // Rational 4417 4418 // constants 4419 extern struct Rational 0; 4420 extern struct Rational 1; 4421 4422 // constructors 4423 Rational rational(); 4424 Rational rational( long int n ); 4425 Rational rational( long int n, long int d ); 4426 4427 // getter/setter for numerator/denominator 4428 long int numerator( Rational r ); 4429 long int numerator( Rational r, long int n ); 4430 long int denominator( Rational r ); 4431 long int denominator( Rational r, long int d ); 4432 4433 // comparison 4434 int ?==?( Rational l, Rational r ); 4435 int ?!=?( Rational l, Rational r ); 4436 int ?<?( Rational l, Rational r ); 4437 int ?<=?( Rational l, Rational r ); 4438 int ?>?( Rational l, Rational r ); 4439 int ?>=?( Rational l, Rational r ); 4440 4441 // arithmetic 4442 Rational -?( Rational r ); 4443 Rational ?+?( Rational l, Rational r ); 4444 Rational ?-?( Rational l, Rational r ); 4445 Rational ?*?( Rational l, Rational r ); 4446 Rational ?/?( Rational l, Rational r ); 4447 4448 // conversion 4449 double widen( Rational r ); 4450 Rational narrow( double f, long int md ); 4451 4452 // I/O 4453 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * ); 4454 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, Rational ); 4455 \end{lstlisting} 4456 4457 4575 4458 \bibliographystyle{plain} 4576 \bibliography{ /usr/local/bibliographies/pl.bib}4459 \bibliography{cfa} 4577 4460 4578 4461
Note: See TracChangeset
for help on using the changeset viewer.