forked from cplusplus/draft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacros.tex
More file actions
750 lines (676 loc) · 24.8 KB
/
macros.tex
File metadata and controls
750 lines (676 loc) · 24.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
%!TEX root = std.tex
% This is the draft-to-xml version of the macro.tex file.
% Use it (only) when compiling for LXir to convert the draft to XML.
% Only the core language is supported at the moment;
% front and back matter, appendices, library parts etc. are not supported.
% dyp, 2014-04
% dyp:
% I added the package enumitem in the harmonize branch to replace the manual
% technique used to add newlines in description lists in [cpp.predefined]
% ex.
%
% \begin{description}
% \item[\tcode{\xname{cplusplus}}]\\
% The name \tcode{\,\xname{cplusplus}} is defined
% ...
%
% now:
%
% \begin{description}
% \item[\tcode{\xname{cplusplus}}]
% The name \tcode{\,\xname{cplusplus}} is defined
% ...
%
% However, enumitem seems not to be supported (natively) by lxir.
% Here's a hack that provides the minimal support required at this point.
\let\descriptionorig=\description
\let\enddescriptionorig=\enddescription
\renewenvironment{description}[1][]
{\descriptionorig}
{\enddescriptionorig}
% Definitions and redefinitions of special commands
%%--------------------------------------------------
%% Difference markups
\definecolor{addclr}{rgb}{0,.6,.6}
\definecolor{remclr}{rgb}{1,0,0}
\definecolor{noteclr}{rgb}{0,0,1}
% dyp: these macros are not used in recent drafts and therefore currently not supported
%\renewcommand{\added}[1]{\textcolor{addclr}{\uline{#1}}}
%\newcommand{\removed}[1]{\textcolor{remclr}{\sout{#1}}}
%\renewcommand{\changed}[2]{\removed{#1}\added{#2}}
%
%\newcommand{\nbc}[1]{[#1]\ }
%\newcommand{\addednb}[2]{\added{\nbc{#1}#2}}
%\newcommand{\removednb}[2]{\removed{\nbc{#1}#2}}
%\newcommand{\changednb}[3]{\removednb{#1}{#2}\added{#3}}
%\newcommand{\remitem}[1]{\item\removed{#1}}
%
%\newcommand{\ednote}[1]{\textcolor{noteclr}{[Editor's note: #1] }}
%% \newcommand{\ednote}[1]{}
%
%\newenvironment{addedblock}
%{
%\color{addclr}
%}
%{
%\color{black}
%}
%\newenvironment{removedblock}
%{
%\color{remclr}
%}
%{
%\color{black}
%}
%%--------------------------------------------------
%% Sectioning macros.
% Each section has a depth, an automatically generated section
% number, a name, and a short tag. The depth is an integer in
% the range [0,5]. (If it proves necessary, it wouldn't take much
% programming to raise the limit from 5 to something larger.)
\makeatletter
% dyp: remove the "Chapter" from "Chapter X" headings
\def\@chapapp{}
% dyp: remove the \quad from \@seccntformat
\def\@seccntformat#1{\csname the#1\endcsname}
% dyp: \paragraph and \subparagraph don't produce sectionHeaders
% this seems to be a non-trivial problem. First, the call stack:
% \paragraph in latex/base/book.cls
% \@startsection in latex kernel
% \@sect in lxir/lxir.sty
% and here's the problem:
% - book.cls defines a negative AFTERSKIP size (the 5th argument to \@startsection)
% - \@sect directly emits lxir tags if AFTERSKIP > 0,
% but only defines \@svsechd otherwise (containing the tags)
% - \@sect calls \@xsect (defined in the latex kernel),
% which *should* output the lxir tags for the first \par (using \everypar)
% - this does not seem to work: \everypar seems not be be invoked
% - no tags are emitted :(
% instead of meddling with LXir here, I chose to redefine the AFTERSKIP to a positive value
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{1ex}%
{\normalfont\normalsize\bfseries}}
\renewcommand{\subparagraph}{\@startsection{paragraph}{5}{\parindent}%
{3.25ex \@plus1ex \@minus.2ex}%
{1ex}%
{\normalfont\normalsize\bfseries}}
\makeatother
% The basic sectioning command. Example:
% \Sec1[intro.scope]{Scope}
% defines a first-level section whose name is "Scope" and whose short
% tag is intro.scope. The square brackets are mandatory.
\def\Sec#1[#2]#3{%
\ifcase#1\let\s=\chapter
\or\let\s=\section
\or\let\s=\subsection
\or\let\s=\subsubsection
\or\let\s=\paragraph
\or\let\s=\subparagraph
\fi%
% dyp: moved the label for easier restructuring of XML
%\s[#3]{#3\hfill[#2]}\label{#2}}
\s[#3]{#3\label{#2}}}
% A convenience feature (mostly for the convenience of the Project
% Editor, to make it easy to move around large blocks of text):
% the \rSec macro is just like the \Sec macro, except that depths
% relative to a global variable, SectionDepthBase. So, for example,
% if SectionDepthBase is 1,
% \rSec1[temp.arg.type]{Template type arguments}
% is equivalent to
% \Sec2[temp.arg.type]{Template type arguments}
\newcounter{SectionDepthBase}
\newcounter{scratch}
\def\rSec#1[#2]#3{%
\setcounter{scratch}{#1}
\addtocounter{scratch}{\value{SectionDepthBase}}
\Sec{\arabic{scratch}}[#2]{#3}}
\newcommand{\synopsis}[1]{\textbf{#1}}
%%--------------------------------------------------
% Indexing
% dyp: disabling indices for now
\renewcommand{\makeindex}[1][dummy]{}
\renewcommand{\index}[2][dummy]{}
% locations
\newcommand{\indextext}[1]{\index[generalindex]{#1}}
\newcommand{\indexlibrary}[1]{\index[libraryindex]{#1}}
\newcommand{\indexgram}[1]{\index[grammarindex]{#1}}
\newcommand{\indeximpldef}[1]{\index[impldefindex]{#1}}
\newcommand{\indexdefn}[1]{\indextext{#1}}
\newcommand{\indexgrammar}[1]{\indextext{#1}\indexgram{#1}}
\newcommand{\impldef}[1]{\indeximpldef{#1}implementation-defined}
% appearance
\newcommand{\idxcode}[1]{#1@\tcode{#1}}
\newcommand{\idxhdr}[1]{#1@\tcode{<#1>}}
\newcommand{\idxgram}[1]{#1@\textit{#1}}
%%--------------------------------------------------
% General code style
\newcommand{\CodeStyle}{\ttfamily}
\newcommand{\CodeStylex}[1]{\texttt{#1}}
% Code and definitions embedded in text.
%\newcommand{\tcode}[1]{\CodeStylex{#1}}
\newcommand{\tcode}[1]{\xBegin{tcode}#1\xEnd{tcode}}% dyp: used for inline code
%\newcommand{\techterm}[1]{\textit{#1}\xspace}
\newcommand{\techterm}[1]{\xBegin{techterm}#1\xEnd{tcode}\xspace}% dyp: not used?
%\newcommand{\defnx}[2]{\indexdefn{#2}\textit{#1}\xspace}
\newcommand{\defnx}[2]{\indexdefn{#2}\xBegin{defnx}#1\xEnd{defnx}\xspace}% dyp: indexed definition of a term
%\newcommand{\defn}[1]{\defnx{#1}{#1}}
\newcommand{\defn}[1]{\defnx{#1}{#1}}% dyp: ??
%\newcommand{\term}[1]{\textit{#1}\xspace}
\newcommand{\term}[1]{\xBegin{term}#1\xEnd{term}\xspace}% dyp: many different uses
% dyp: \grammarterm is sometimes used "with two arguments", even though the macro only takes a single one
% ex. \grammarterm{}{postfix-expression}
% this effectively disables the formatting of the term
% I've re-enables the formatting in the harmonize branch, but provide additional support here
% for both usages
%\newcommand{\grammarterm}[1]{\textit{#1}\xspace}
% dyp: (usage note for \grammarterm) inline occurence of a grammar term
\def\grammartermTwo#1#2{\xBegin{grammarterm}#1\xEnd{grammarterm}#2\xspace}
\newcommand{\grammartermOne}[1]{\xBegin{grammarterm}#1\xEnd{grammarterm}\xspace}
% from http://tex.stackexchange.com/a/10405 ; thanks to Joseph Wright
\NewDocumentCommand\grammarterm{m+g}{%
\IfNoValueTF{#2}
{\grammartermOne{#1}}
{\grammartermTwo{#1}{#2}}%
}
%\newcommand{\placeholder}[1]{\textit{#1}\xspace}
\newcommand{\placeholder}[1]{% dyp: placeholder variables, such as foo and bar
\xBegin{placeholder}#1\xEnd{placeholder}\xspace%
}
% For comparison of multiple ICS in [over.match.best]
%\newcommand{\ICS}[2]{$\text{ICS}#1(\text{\tcode{#2}})$}
\newcommand{\ICS}[2]{\xEmptyAA{ICS}{index=#1}{arg=#2}}
%%--------------------------------------------------
%% allow line break if needed for justification
\newcommand{\brk}{\discretionary{}{}{}}
% especially for scope qualifier
\newcommand{\colcol}{\brk::\brk}
%%--------------------------------------------------
%% Macros for funky text
%\newcommand{\Rplus}{\protect\hspace{-.1em}\protect\raisebox{.35ex}{\smaller{\smaller\textbf{+}}}}% dyp: fancy plus for nice rendering of "C++" (see below)
% \newcommand{\Rplus}{+}
%\newcommand{\Cpp}{\mbox{C\Rplus\Rplus}\xspace}
\newcommand{\Cpp}{\xEmpty{cpp}\xspace}
%\newcommand{\CppIII}{\Cpp 2003\xspace}
\newcommand{\CppIII}{\xEmpty{cpp2003}\xspace}
%\newcommand{\CppXI}{\Cpp 2011\xspace}
\newcommand{\CppXI}{\xEmpty{cpp2011}\xspace}
%\newcommand{\opt}{{\ensuremath{_\mathit{opt}}}\xspace}
\newcommand{\opt}{\xEmpty{opt}\xspace}
\newcommand{\shl}{<{<}}
\newcommand{\shr}{>{>}}
\newcommand{\dcr}{-{-}}
\newcommand{\exor}{\^{}}
\newcommand{\bigoh}[1]{\ensuremath{\mathscr{O}(#1)}}
% \renewcommand{\tilde}{{\smaller\ensuremath{\sim}}} % extra level of braces is necessary
%\renewcommand{\tilde}{\protect\raisebox{-.5ex}{\larger\textasciitilde}}
\renewcommand{\tilde}{\textasciitilde}
\def\~{\tilde}
%%--------------------------------------------------
%% States and operators
\newcommand{\state}[2]{\tcode{#1}\ensuremath{_{#2}}}
\newcommand{\bitand}{\ensuremath{\, \mathsf{bitand} \,}}
\newcommand{\bitor}{\ensuremath{\, \mathsf{bitor} \,}}
\newcommand{\xor}{\ensuremath{\, \mathsf{xor} \,}}
\newcommand{\rightshift}{\ensuremath{\, \mathsf{rshift} \,}}
\newcommand{\leftshift}[1]{\ensuremath{\, \mathsf{lshift}_#1 \,}}
%% Notes and examples
%\newcommand{\EnterBlock}[1]{[\,\textit{#1:}\xspace}
%\newcommand{\ExitBlock}[1]{\textit{\,---\,end #1}\,]\xspace}
%\newcommand{\enternote}{\EnterBlock{Note}}
\newcommand{\enternote}{\xBegin{note}}
%\newcommand{\exitnote}{\ExitBlock{note}}
\newcommand{\exitnote}{\xEnd{note}}
%\newcommand{\enterexample}{\EnterBlock{Example}}
\newcommand{\enterexample}{\xBegin{example}}
%\newcommand{\exitexample}{\ExitBlock{example}}
\newcommand{\exitexample}{\xEnd{example}}
% dyp: library currently not supported
%% Library function descriptions
%\newcommand{\Fundescx}[1]{\textit{#1}\xspace}
%\newcommand{\Fundesc}[1]{\Fundescx{#1:}}
%\newcommand{\required}{\Fundesc{Required behavior}}
%\newcommand{\requires}{\Fundesc{Requires}}
%\newcommand{\effects}{\Fundesc{Effects}}
%\newcommand{\postconditions}{\Fundesc{Postconditions}}
%\newcommand{\postcondition}{\Fundesc{Postcondition}}
%\newcommand{\preconditions}{\requires}
%\newcommand{\precondition}{\requires}
%\newcommand{\returns}{\Fundesc{Returns}}
%\newcommand{\throws}{\Fundesc{Throws}}
%\newcommand{\default}{\Fundesc{Default behavior}}
%\newcommand{\complexity}{\Fundesc{Complexity}}
%\newcommand{\remark}{\Fundesc{Remark}}
%\newcommand{\remarks}{\Fundesc{Remarks}}
%\newcommand{\note}{\remark}
%\newcommand{\notes}{\remarks}
%\newcommand{\realnote}{\Fundesc{Note}}
%\newcommand{\realnotes}{\Fundesc{Notes}}
%\newcommand{\errors}{\Fundesc{Error conditions}}
%\newcommand{\sync}{\Fundesc{Synchronization}}
%\newcommand{\implimits}{\Fundesc{Implementation limits}}
%\newcommand{\replaceable}{\Fundesc{Replaceable}}
%\newcommand{\exceptionsafety}{\Fundesc{Exception safety}}
%\newcommand{\returntype}{\Fundesc{Return type}}
%\newcommand{\cvalue}{\Fundesc{Value}}
%\newcommand{\ctype}{\Fundesc{Type}}
%\newcommand{\ctypes}{\Fundesc{Types}}
%\newcommand{\dtype}{\Fundesc{Default type}}
%\newcommand{\ctemplate}{\Fundesc{Class template}}
%\newcommand{\templalias}{\Fundesc{Alias template}}
%
%%% Cross reference
%\newcommand{\xref}{\textsc{See also:}\xspace}
%\newcommand{\xsee}{\textsc{See:}\xspace}
%% NTBS, etc.
% dyp: these are macros to print the abbreviations of
% * null-terminated byte string
% * null-terminated multi-byte string
% and so on
% in small capitals
%\newcommand{\NTS}[1]{\textsc{#1}\xspace}
\newcommand{\NTS}[1]{\xBegin{NTS}#1\xEnd{NTS}\xspace}%{\textsc{#1}\xspace}
\newcommand{\ntbs}{\NTS{ntbs}}
\newcommand{\ntmbs}{\NTS{ntmbs}}
\newcommand{\ntwcs}{\NTS{ntwcs}}
\newcommand{\ntcxvis}{\NTS{ntc16s}}
\newcommand{\ntcxxxiis}{\NTS{ntc32s}}
%% Code annotations
\newcommand{\EXPO}[1]{\textit{#1}}
%\newcommand{\expos}{\EXPO{exposition only}}
\newcommand{\expos}{\xEmptyA{exposition-only}{category=code}}
%\newcommand{\impdef}{\EXPO{implementation-defined}}
\newcommand{\impdef}{\xEmptyA{implementation-defined}{category=code}}% dyp: e.g. the return type of std::bind
%\newcommand{\impdefx}[1]{\indeximpldef{#1}\EXPO{implementation-defined}}
\newcommand{\impdefx}[1]{\indeximpldef{#1}\impdef}
%\newcommand{\notdef}{\EXPO{not defined}}
\newcommand{\notdef}{\xEmptyA{notdef}{category=code}}% dyp: currently unused
%\newcommand{\UNSP}[1]{\textit{\texttt{#1}}}% dyp: too generic formatting, using more specific replacements
%\newcommand{\unspec}{\UNSP{unspecified}\xspace}
\newcommand{\unspec}{\xEmptyA{unspecified}{category=code}}
%\newcommand{\unspecbool}{\UNSP{unspecified-bool-type}}
\newcommand{\unspecbool}{\xEmptyA{unspecified-bool-type}{category=code}}
%\newcommand{\seebelow}{\UNSP{see below}}
\newcommand{\seebelow}{\xEmptyA{see-below}{category=code}}
%\newcommand{\unspecuniqtype}{\UNSP{unspecified unique type}}
\newcommand{\unspecuniqtype}{\xEmptyA{unspecified-unique-type}{category=code}}
%\newcommand{\unspecalloctype}{\UNSP{unspecified allocator type}}
\newcommand{\unspecalloctype}{\xEmptyA{unspecified-allocator-type}{category=code}}
%% Double underscore
% dyp: multiple underscores seem to have been separated with spaces for formatting reasons
% they should actually be adjacent (w/o space characters)
%\newcommand{\unun}{\_\,\_}
\newcommand{\unun}{\_\_}
%\newcommand{\xname}[1]{\unun\,#1}
\newcommand{\xname}[1]{\unun#1}
%\newcommand{\mname}[1]{\tcode{\unun\,#1\,\unun}}
\newcommand{\mname}[1]{\tcode{\unun#1\unun}}
%% Ranges
\newcommand{\Range}[4]{\tcode{#1\brk{}#3,\brk{}#4\brk{}#2}\xspace}
\newcommand{\crange}[2]{\Range{[}{]}{#1}{#2}}
\newcommand{\brange}[2]{\Range{(}{]}{#1}{#2}}
\newcommand{\orange}[2]{\Range{(}{)}{#1}{#2}}
\newcommand{\range}[2]{\Range{[}{)}{#1}{#2}}
%% Change descriptions
% dyp: currently unused (?)
%\newcommand{\diffdef}[1]{\hfill\break\textbf{#1:}\xspace}
%\newcommand{\change}{\diffdef{Change}}
%\newcommand{\rationale}{\diffdef{Rationale}}
%\newcommand{\effect}{\diffdef{Effect on original feature}}
%\newcommand{\difficulty}{\diffdef{Difficulty of converting}}
%\newcommand{\howwide}{\diffdef{How widely used}}
%% Miscellaneous
% dyp: uniquens means "unique namespace"
%\newcommand{\uniquens}{\textrm{\textit{\textbf{unique}}} }
\newcommand{\uniquens}{\xEmpty{uniquens}}
%\newcommand{\stage}[1]{\item{\textbf{Stage #1:}}\xspace}% dyp: currently not supported
%\newcommand{\doccite}[1]{\textit{#1}\xspace}
\newcommand{\doccite}[1]{\xBegin{doccite}#1\xEnd{doccite}\xspace}
%\newcommand{\cvqual}[1]{\textit{#1}}
\newcommand{\cvqual}[1]{\xBegin{cvqual}#1\xEnd{cvqual}}
\newcommand{\cv}{\cvqual{cv}}
%\renewcommand{\emph}[1]{\textit{#1}\xspace}
\renewcommand{\emph}[1]{\xBegin{emph}#1\xEnd{emph}\xspace}
%\newcommand{\numconst}[1]{\textsl{#1}\xspace}
\newcommand{\numconst}[1]{\xBegin{numconst}#1\xEnd{numconst}}
%\newcommand{\logop}[1]{{\footnotesize #1}\xspace}
\newcommand{\logop}[1]{\xBegin{logop}#1\xEnd{logop}}
%%--------------------------------------------------
%% Environments for code listings.
% We use the 'listings' package, with some small customizations. The
% most interesting customization: all TeX commands are available
% within comments. Comments are set in italics, keywords and strings
% don't get special treatment.
\newcommand{\foo}{\xEmpty{newline}}
\lstset{language=C++,
basicstyle=\small\CodeStyle,
keywordstyle=,
stringstyle=,
xleftmargin=1em,
showstringspaces=false,
commentstyle=\itshape\rmfamily,
columns=flexible,
keepspaces=true,
texcl=true}
% Our usual abbreviation for 'listings'. Comments are in
% italics. Arbitrary TeX commands can be used if they're
% surrounded by @ signs.
% dyp: I hacked the lst environment similarly to how LXir hacked the verbatim environment:
% overwriting the macros used in the implementation to inject certain tags
% and later replacing them in xslt
\makeatletter
\let\lstoutputspaceorig=\lst@outputspace
\def\lst@outputspace{\xEmpty{verbatimSpace}\lstoutputspaceorig}
\let\lstNewLineorig=\lst@NewLine
\def\lst@NewLine{\xEmpty{verbatimLineBreak}\lstNewLineorig}
\makeatother
\newcommand{\CodeBlockSetup}{
\lstset{escapechar=@}
%\renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}}
\renewcommand{\tcode}[1]{\xBegin{tcode}##1\xEnd{tcode}}
%\renewcommand{\techterm}[1]{\textit{\CodeStylex{##1}}}
\renewcommand{\techterm}[1]{\xBegin{techterm}##1\xEnd{techterm}}
%\renewcommand{\term}[1]{\textit{##1}}
\renewcommand{\term}[1]{\xBegin{term}##1\xEnd{term}}
%\renewcommand{\grammarterm}[1]{\textit{##1}}
\renewcommand{\grammarterm}[1]{\xBegin{grammarterm}##1\xEnd{grammarterm}}
}
\lstnewenvironment{codeblock}{\CodeBlockSetup\xBegin{codeblock}}{\xEnd{codeblock}}
% A code block in which single-quotes are digit separators
% rather than character literals.
\lstnewenvironment{codeblockdigitsep}{
\CodeBlockSetup
\xBegin{codeblock}
\lstset{deletestring=[b]{'}}
}{\xEnd{codeblock}}
% Permit use of '@' inside codeblock blocks (don't ask)
% dyp: "don't ask" means that '@' is used as the listing's escape character,
% i.e. to be able to insert latex code
% not sure why '$' has not been used.
\makeatletter
\newcommand{\atsign}{@}
\makeatother
%%--------------------------------------------------
%% Indented text
\newenvironment{indented}
%{\list{}{}\item\relax}
%{\endlist}
{\xBegin{indented}}
{\xEnd{indented}}
% dyp: library not supported (yet)
%
%%%--------------------------------------------------
%%% Library item descriptions
%\lstnewenvironment{itemdecl}
%{
% \lstset{escapechar=@,
% xleftmargin=0em,
% aboveskip=2ex,
% belowskip=0ex % leave this alone: it keeps these things out of the
% % footnote area
% }
%}
%{
%}
%
%\newenvironment{itemdescr}
%{
% \begin{indented}}
%{
% \end{indented}
%}
%%--------------------------------------------------
%% Bnf environments
% dyp:
% bnf probably stands for Backus-Naur Form
% (well it's the environment used to describe the grammar rules)
% The bnf environment itself describes the rule for ONE nonterminal.
% If multiple nonterminals shall be defined, multiple bnf environments are used (contiguously).
% Here's an example from [declarations]
%
% \begin{bnf}
% \nontermdef{declaration-seq}\br
% declaration\br
% declaration-seq declaration
% \end{bnf}%
%
% As you can see, the first element is always a \nontermdef (or \nonterm), which
% * indexes a nonterminal (\nontermdef)
% * introduces a special formatting (both).
% Then, multiple sequences follow, each preceded by an \br.
% All but the first \br can be interpreted as an OR ('|' in Backus-Naur notation).
% Since I think it's awful to introduce the semantics solely via this linebreak notation,
% I'll hack the \br and add an XSLT to get a proper list.
% (Note: Although a \list is used here, it only serves indentation purposes, as far as I can see.)
%
% .... p.s. the \br sometimes is also used for pure formatting, see [dcl.enum]
%\newlength{\BnfIndent}
%\setlength{\BnfIndent}{\leftmargini}
%\newlength{\BnfInc}
%\setlength{\BnfInc}{\BnfIndent}
%\newlength{\BnfRest}
%\setlength{\BnfRest}{2\BnfIndent}
%\newcommand{\BnfNontermshape}{\small\rmfamily\itshape}
%\newcommand{\BnfTermshape}{\small\ttfamily\upshape}
%\newcommand{\nonterminal}[1]{{\BnfNontermshape #1}}
\newcommand{\nonterminal}[1]{\xBegin{nonterminal}#1\xEnd{nonterminal}}%{{\BnfNontermshape #1}}
\newenvironment{bnfbase}
{
%\newcommand{\nontermdef}[1]{\nonterminal{##1}\indexgrammar{\idxgram{##1}}:}
\newcommand{\nontermdef}[1]{\indexgrammar{\idxgram{##1}}\xBegin{nontermdef}##1\xEnd{nontermdef}}% dyp: removed a trailing ':'
%\newcommand{\terminal}[1]{{\BnfTermshape ##1}\xspace}
\newcommand{\terminal}[1]{\xBegin{terminal}##1\xEnd{terminal}\xspace}
%\newcommand{\descr}[1]{\normalfont{##1}}
\newcommand{\descr}[1]{\xBegin{description}##1\xEnd{description}}
%\newcommand{\bnfindentfirst}{\BnfIndent}
\newcommand{\bnfindentfirst}{}
%\newcommand{\bnfindentinc}{\BnfInc}
\newcommand{\bnfindentinc}{\leftmargini}
%\newcommand{\bnfindentrest}{\BnfRest}
%\begin{minipage}{.9\hsize}
%\newcommand{\br}{\hfill\\}
\newcommand{\br}{\xEmpty{grammar-rule}}
\renewcommand{\textnormal}[1]{\xBegin{description}##1\xEnd{description}}
}
{
%\end{minipage}
}
% dyp: I have no need for this, I directly hacked bnfkeywordtab instead
%\newenvironment{BnfTabBase}[1]
%{
% \begin{bnfbase}
% #1
% \begin{indented}
% \begin{tabbing}
% \hspace*{\bnfindentfirst}\=\hspace{\bnfindentinc}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\kill}
%{
% \end{tabbing}
% \end{indented}
% \end{bnfbase}
%}
% dyp:
% This environment is used twice (in [lex.operators]/1 and [over.oper]/1).
% It defines a nonterminal, where the rules are simple terminals and there are so many of them
% that you cannot (practically) put them on individual lines.
% In LaTeX code, the rules are separated by \> and the line breaks defined via \br
%
% Example:
%
% operator: one of
% new delete new delete[]
% + - * / % ^ & | ~
% [...]
%
% note the spacing between the keywords, produced by a \> (a \medmuskip)
\newenvironment{bnfkeywordtab}
{
%\begin{BnfTabBase}{\BnfTermshape}
\begin{bnfbase}
\xBegin{bnfkeywordtab}
\renewcommand{\>}{\xEmpty{next-keyword}}
\renewcommand{\br}{\xEmpty{br-hint}}
}
{
%\end{BnfTabBase}
\xEnd{bnfkeywordtab}
\end{bnfbase}
}
% dyp: This environment is used differently than the bnfkeywordtab, despite the similar name.
% It defines a nonterminal; the rules are manually indented.
% Allows additional indentation within the rule [cpp] and line-breaks within a rule,
% the following line is then continued with one more level of indentation [lex.ccon].
% ex. from [gram.lex]
% \begin{bnftab}
% \nontermdef{c-char}\br
% \>\textnormal{any member of the source character set except}\br
% \>\>\textnormal{the single-quote \terminal{'}, [...]}
% \>escape-sequence\br
% \>universal-character-name
% \end{bnftab}
\newenvironment{bnftab}
{
%\begin{BnfTabBase}{\BnfNontermshape}
\begin{bnfbase}
\xBegin{bnftab}
\renewcommand{\br}{\xEmpty{br}}
\renewcommand\>{\xEmpty{indent}}
}
{
%\end{BnfTabBase}
\xEnd{bnftab}
\end{bnfbase}
}
% dyp: the simple bnf looks just like a list of rules, what they define is specified in the text
% surrounding the simplebnf environment
% Only occurs as ncsimplebnf.
% Does not contain manual indenting and does not define a nonterminal inside the environment.
\newenvironment{simplebnf}
{
\begin{bnfbase}
%\BnfNontermshape
%\begin{indented}
\xBegin{simplebnf}
\renewcommand{\\}{\xEmpty{grammar-rule}}
}
{
%\end{indented}
\xEnd{simplebnf}
\end{bnfbase}
}
% dyp:
% Always contains a \nontermdef.
% Defines the nonterminal using one or more rules (automatic indenting).
% One exception is [dcl.fct.def.general]/1, where "function-body:" has been used
% as the nonterminal which is to be defined, instead of \nontermdef{function-body}
% or \nonterminal{function-body:}
% The non-copied version usually doesn't contain a nonterminal definition;
% the single exception being [over.match.call]/3
\newenvironment{bnf}
{
\begin{bnfbase}
%\list{}
% {
% \setlength{\leftmargin}{\bnfindentrest}
% \setlength{\listparindent}{-\bnfindentinc}
% \setlength{\itemindent}{\listparindent}
% }
%\BnfNontermshape
%\item\relax
\xBegin{bnf}
}
{
%\endlist
\xEnd{bnf}
\end{bnfbase}
}
% non-copied versions of bnf environments
\newenvironment{ncbnftab}
{
\begin{bnftab}
}
{
\end{bnftab}
}
\newenvironment{ncsimplebnf}
{
\begin{simplebnf}
}
{
\end{simplebnf}
}
\newenvironment{ncbnf}
{
\begin{bnf}
}
{
\end{bnf}
}
%%--------------------------------------------------
%% Drawing environment
%
% usage: \begin{drawing}{UNITLENGTH}{WIDTH}{HEIGHT}{CAPTION}
\newenvironment{drawing}[4]
{
\newcommand{\mycaption}{#4}
\begin{figure}[h]
\setlength{\unitlength}{#1}
\begin{center}
\begin{picture}(#2,#3)\thicklines
}
{
\end{picture}
\end{center}
\caption{\mycaption}
\end{figure}
}
%%--------------------------------------------------
%% Environment for imported graphics
% usage: \begin{importgraphic}{CAPTION}{TAG}{FILE}
% dyp: graphics are not yet supported
% the current macros should allow adding this support easily
\newenvironment{importgraphic}[3]
{%
%\newcommand{\cptn}{#1}
%\newcommand{\lbl}{#2}
%\begin{figure}[htp]\centering%
%\includegraphics[scale=.35]{#3}
\begin{figure}[htp]%
\xBegin{importgraphic}#3\xEnd{importgraphic}%
\caption{#1}\label{#2}
}
{
%\caption{\cptn}\label{\lbl}%
\end{figure}}
%% enumeration display overrides
% enumerate with lowercase letters
\newenvironment{enumeratea}
{
\renewcommand{\labelenumi}{\alph{enumi})}
\begin{enumerate}
}
{
\end{enumerate}
}
% enumerate with arabic numbers
\newenvironment{enumeraten}
{
\renewcommand{\labelenumi}{\arabic{enumi})}
\begin{enumerate}
}
{
\end{enumerate}
}
%%--------------------------------------------------
%% Definitions section
% usage: \definition{name}{xref}
%\newcommand{\definition}[2]{\rSec2[#2]{#1}}
% for ISO format, use:
% dyp: definitions only occur in [intro.defs] and are a hybrid of subsections and list items
\newcommand{\definition}[2]
{\hfill\vspace{.25ex plus .5ex minus .2ex}\\
\addtocounter{subsection}{1}%
%\textbf{\thesubsection\hfill\relax[#2]}\\
%\textbf{#1}
\xBegin{definition}\xAttr{position=\thesubsection}\xAttr{level=2}#1\xEnd{definition}
\label{#2}\\
}