source: doc/theses/andrew_beach_MMath/cfalab.sty@ 8cd34e9

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum stuck-waitfor-destruct
Last change on this file since 8cd34e9 was 8cd34e9, checked in by Andrew Beach <ajbeach@…>, 5 years ago

Andrew MMath: Added command signatures in cfalab.sty.

  • Property mode set to 100644
File size: 6.2 KB
Line 
1% Package for CFA Research Lab.
2%
3% This is a collection of commands everyone working on CFA related documents
4% should find useful. So mostly programming language related tools.
5%
6% Internal commands are prefixed with "\cfalab@".
7
8% I don't know what the oldest LaTeX2e version with everything needed is.
9\NeedsTeXFormat{LaTeX2e}
10\ProvidesPackage{cfalab}[2020/03/24 v0.1 CFA Laboratory LaTeX Tools]
11
12% Other packages required.
13%
14% Access to new basic LaTeX tools and other low level commands.
15\RequirePackage{etoolbox}
16% Code formatting tools and environments.
17\RequirePackage{listings}
18% Automatically adds spaces.
19\RequirePackage{xspace}
20
21% Tip for commands that end with \xspace: if the default is not correct then
22% follow the command with {} to disable \xspace, use '{} ' to force add a
23% space and '{}<whatever-follows>' to force remove one.
24%
25% \CFA
26% Cforall with the forall symbol.
27\newrobustcmd\CFA{\textsf{C\raisebox{\depth}{\rotatebox{180}{A}}}\xspace}
28% \Cpp[<std>]
29% C++ symbol name. You may optionally provide <std> to specify a standard.
30\newrobustcmd\Cpp[1][\xspace]{C++#1}
31
32% This is executed very early in the \begin{document} code, before the
33% document's contents but after packages are loaded.
34\AtEndPreamble{
35 \@ifpackageloaded{hyperref}{
36 % Convert symbols to pdf compatable forms when required.
37 \pdfstringdefDisableCommands{
38 \def\CFA{CFA}
39 \def\Cpp{C++}
40 \def\lstinline{}
41 }
42 }{}
43}
44
45% \colour{<colour>}{<text>}
46% Just \color but using the LaTeX style instead of TeX style command.
47\newcommand*\colour[2]{{\color{#1}#2}}
48
49% \codeCFA{<code>}
50% \codeC{<code>}
51% \codeCpp{<code>}
52% \codePy{<code>}
53% Use the listings package to format a snipit of <code>.
54\newrobustcmd*\codeCFA[1]{\lstinline[language=CFA]{#1}}
55\newrobustcmd*\codeC[1]{\lstinline[language=C]{#1}}
56\newrobustcmd*\codeCpp[1]{\lstinline[language=C++]{#1}}
57\newrobustcmd*\codePy[1]{\lstinline[language=Python]{#1}}
58
59% \begin{cfa}[<options>]
60% \end{cfa}
61% Use the listings package to format a block of CFA code.
62% Extra listings options can be passed in as an optional argument.
63\lstnewenvironment{cfa}[1][]{\lstset{language=CFA}\lstset{#1}}{}
64
65% \settextunderscore{(new|old)}
66% Redefines the underscore either as a new repersentation or the old one.
67% Not that some other packages (ex. hyperref) can override this. Set it up
68% after loading them.
69\let\cfalab@textunderscore@old=\textunderscore
70\newcommand\cfalab@textunderscore@new{%
71 \leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}}
72\newcommand\settextunderscore[1]{%
73 \renewcommand\textunderscore{\csuse{cfalab@textunderscore@#1}}}
74
75% The CFA listings language. Based off of ANCI C and including GCC extensions.
76% The UW dialect is the default (and only so far) dialect of the language.
77\lstdefinelanguage[UW]{CFA}[ANSI]{C}{
78 morekeywords={_Alignas, _Alignof, __alignof, __alignof__, asm, __asm,
79 __asm__, __attribute, __attribute__, auto, _Bool, catch, catchResume,
80 choose, _Complex, __complex, __complex__, __const, __const__,
81 coroutine, disable, dtype, enable, exception, __extension__,
82 fallthrough, fallthru, finally, __float80, float80, __float128,
83 float128, forall, ftype, generator, _Generic, _Imaginary, __imag,
84 __imag__, inline, __inline, __inline__, __int128, int128, __label__,
85 monitor, mutex, _Noreturn, one_t, or, otype, restrict, resume,
86 __restrict, __restrict__, __signed, __signed__, _Static_assert,
87 suspend, thread, _Thread_local, throw, throwResume, timeout, trait,
88 try, ttype, typeof, __typeof, __typeof__, virtual, __volatile,
89 __volatile__, waitfor, when, with, zero_t
90 },
91 moredirectives={defined,include_next},
92}
93\lstset{defaultdialect={[UW]CFA}}
94
95% Create an internal paragraph indent amount. This is used internally to
96% mimic the standard indent even when it has been overriden in the document.
97\newlength\cfalab@parindent
98\deflength\cfalab@parindent{\parindent}
99
100% The cfacommon style has many useful defaults for CFA and other types of
101% code. Use the listings option "style=cfacommon" to load them.
102\lstdefinestyle{cfacommon}{
103 columns=fullflexible,
104 basicstyle=\linespread{0.9}\sf,
105 stringstyle=\tt,
106 tabsize=5,
107 % Indent code to paragraph indentation.
108 xleftmargin=\cfalab@parindent,
109 % Allow ASCII characters in the range 128-255.
110 extendedchars=true,
111 % This allows you to use "math mode" to insert LaTeX into the code.
112 % Use \( and \) if you need to insert math mode inside that code.
113 escapechar=\$,
114 % Disable LaTeX math escape in CFA code $...$
115 mathescape=false,
116 keepspaces=true,
117 % Do not show spaces with cup.
118 showstringspaces=false,
119 % Show blank lines at end of code.
120 showlines=true,
121 % Spacing above/below code block.
122 aboveskip=4pt,belowskip=0pt,
123 numberstyle=\footnotesize\sf,
124 % Replace/adjust listing characters that look bad in sanserif.
125 literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.75ex}{0.1ex}}}}1
126 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1
127 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
128 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2
129 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2,
130}
131
132% common.tex Compatablity ===================================================
133% Below this line is for compatability with the old common.tex file.
134
135% Backwards compatable way to activate the cfacommon style.
136\newcommand{\CFAStyle}{\lstset{style=cfacommon}}
137
138% A couple of abbreviations are provided. Just ones someone liked.
139%
140% Abbreviation formatting commands (renew to customize):
141\newcommand{\abbrevFont}{\textit}
142%
143% Abbreviations that, if not followed by a comma or colon, add a comma.
144\newrobustcmd*\cfalab@abbrev@comma{%
145 \@ifnextchar{,}{}{\@ifnextchar{:}{}{,\xspace}}}
146\providerobustcmd*\eg{\abbrevFont{e}.\abbrevFont{g}.\cfalab@abbrev@comma}
147\providerobustcmd*\ie{\abbrevFont{i}.\abbrevFont{e}.\cfalab@abbrev@comma}
148%
149% Abbreviations that, if not followed by a period, add a period.
150\newrobustcmd*\cfalab@abbrev@period{\@ifnextchar{.}{}{.\xspace}}
151\providerobustcmd*\etc{\abbrevFont{etc}\cfalab@abbrev@period}
152\providerobustcmd*\etal{\abbrevFont{et}~\abbrevFont{al}\cfalab@abbrev@period}
153\providerobustcmd*\viz{\abbrevFont{viz}\cfalab@abbrev@period}
154
155\endinput
Note: See TracBrowser for help on using the repository browser.