-
Notifications
You must be signed in to change notification settings - Fork 7
/
listingscpp.sty
303 lines (289 loc) · 11.4 KB
/
listingscpp.sty
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
\RequirePackage{listings}
\RequirePackage{calc}
\newif\iflstcpp@mono@
\lstcpp@mono@false
\DeclareOption{mono}{\lstcpp@mono@true}
\ProcessOptions
\lstdefinelanguage{asm}%
{morekeywords={
aaa,aad,aam,aas,adc,add,and,arpl,bound,bsf,bsr,bswap,bt,btc,%
btr,bts,call,cbw,cdq,clc,cld,cli,clts,cmc,cmp,cmps,cmpsb,cmpsw,%
cmpsd,cmpxchg,cwd,cwde,daa,das,dec,div,enter,hlt,idiv,imul,in,%
inc,ins,int,into,invd,invlpg,iret,ja,jae,jb,jbe,jc,jcxz,jecxz,%
je,jg,jge,jl,jle,jna,jnae,jnb,jnbe,jnc,jne,jng,jnge,jnl,jnle,%
jno,jnp,jns,jnz,jo,jp,jpe,jpo,js,jz,jmp,lahf,lar,lea,leave,lgdt,%
lidt,lldt,lmsw,lock,lods,lodsb,lodsw,lodsd,loop,loopz,loopnz,%
loope,loopne,lds,les,lfs,lgs,lss,lsl,ltr,mov,movs,movsb,movsw,%
movsd,movsx,movzx,mul,neg,nop,not,or,out,outs,pop,popa,popad,%
popf,popfd,push,pusha,pushad,pushf,pushfd,rcl,rcr,rep,repe,%
repne,repz,repnz,ret,retf,rol,ror,sahf,sal,sar,sbb,scas,seta,%
setae,setb,setbe,setc,sete,setg,setge,setl,setle,setna,setnae,%
setnb,setnbe,setnc,setne,setng,setnge,setnl,setnle,setno,setnp,%
setns,setnz,seto,setp,setpe,setpo,sets,setz,sgdt,shl,shld,shr,%
shrd,sidt,sldt,smsw,stc,sti,stos,stosb,stosw,stosd,str,sub,%
test,verr,verw,wait,wbinvd,xadd,xchg,xlatb,xor,fabs,fadd,fbld,%
fbstp,fchs,fclex,fcom,fcos,fdecstp,fdiv,fdivr,ffree,fiadd,ficom,%
fidiv,fidivr,fild,fimul,fincstp,finit,fist,fisub,fisubr,fld,fld1,%
fldl2e,fldl2t,fldlg2,fldln2,fldpi,fldz,fldcw,fldenv,fmul,fnop,%
fpatan,fprem,fprem1,fptan,frndint,frstor,fsave,fscale,fsetpm,%
fsin,fsincos,fsqrt,fst,fstcw,fstenv,fstsw,fsub,fsubr,ftst,fucom,%
fwait,fxam,fxch,fxtract,fyl2x,fyl2xp1,f2xm1,%
vmovdqu32,vpmulld,vaddss,vaddps},%
morekeywords=[5]{%
al,ah,ax,eax,bl,bh,bx,ebx,cl,ch,cx,ecx,dl,dh,dx,edx,%
si,esi,di,edi,bp,ebp,sp,esp,cs,ds,es,ss,fs,gs,cr0,cr1,cr2,cr3,%
db0,db1,db2,db3,db4,db5,db6,db7,tr0,tr1,tr2,tr3,tr4,tr5,tr6,tr7,%
s0,v0.4s,%
st,%
rax,rbx,rcx,rdx,rdi,%
rsi,rsp,rbp,r8,r9,r10,r11,r12,r13,r14,r15,%
xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7,xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15,%
ymm0,ymm1,ymm2,ymm3,ymm4,ymm5,ymm6,ymm7,ymm8,ymm9,ymm10,ymm11,ymm12,ymm13,ymm14,ymm15,%
zmm0,zmm1,zmm2,zmm3,zmm4,zmm5,zmm6,zmm7,zmm8,zmm9,zmm10,zmm11,zmm12,zmm13,zmm14,zmm15,%
},%
morekeywords=[6]{.align,.alpha,assume,byte,code,comm,comment,.const,%
.cref,.data,.data?,db,dd,df,dosseg,dq,dt,dw,dword,else,end,endif,%
endm,endp,ends,eq,equ,.err,.err1,.err2,.errb,.errdef,.errdif,%
.erre,.erridn,.errnb,.errndef,.errnz,event,exitm,extrn,far,%
.fardata,.fardata?,fword,ge,group,gt,high,if,if1,if2,ifb,ifdef,%
ifdif,ife,ifidn,ifnb,ifndef,include,includelib,irp,irpc,label,%
.lall,le,length,.lfcond,.list,local,low,lt,macro,mask,mod,.model,%
name,ne,near,offset,org,out,page,proc,ptr,public,purge,qword,.%
radix,record,rept,.sall,seg,segment,.seq,.sfcond,short,size,%
.stack,struc,subttl,tbyte,.tfcond,this,title,type,.type,width,%
word,.xall,.xcref,.xlist,xmmword,ymmword,zmmword},%
alsoletter=.,alsodigit=?,%
sensitive=f,%
morestring=[b]",%
morestring=[b]',%
morecomment=[l];%
}[keywords,comments,strings]
\lstdefinelanguage{MyC++}{
sensitive,
comment=[s]{/*}{*/},
morecomment=[l]//,
string=[b]",
morestring=[b]',
%statements
keywords=[0]{goto,break,return,continue,asm,__asm__,new,delete,this,friend,using,override,final,requires,concept,static_assert},
%labels
keywords=[1]{case,default},
%conditionals
keywords=[2]{if,else,switch},
%repeat
keywords=[3]{while,for,do},
%operators
keywords=[4]{typeof,operator,typeid,sizeof,alignof,alignas,decltype,noexcept},
%types
keywords=[12]{
int,long,short,char,void,signed,unsigned,float,double,bool,wchar_t,char8_t,
char16_t,char32_t
},
keywords=[5]{array,deque,vector,map,unordered_map,common_type,common_type_t,
span,projected,
floating_point,integral,boolean,totally_ordered,partially_ordered,
reference_wrapper,Incomplete,Holder,Iterator,IteratorImpl,Data,Ptr,Testable,Unused,Wrap,
type,
simd,simd_mask,native_simd,fixed_size_simd,native_simd_mask,fixed_size_simd_mask,
basic_simd,basic_simd_mask,
duration,time_point,integer,fractional,fixed_point,is_bounded_integer,rational,
A,B,C,D,E,F,G,I,R,T,U,V,X,Y,Z,
It,Flags,
A0,B0,C0,XRef,
Point,Abi,
memory_alignment,element_aligned_tag,vector_aligned_tag,overaligned_tag,deduce,deduce_t,
is_simd,is_simd_mask,is_abi_tag,is_simd_flag_type,
shared_ptr,unique_ptr,weak_ptr,default_delete,
size_t,ssize_t,off_t,
ptrdiff_t,sig_atomic_t,fpos_t,
clock_t,time_t,va_list,jmp_buf,FILE,DIR,div_t,ldiv_t,
mbstate_t,wctrans_t,wint_t,wctype_t,
int8_t,int16_t,int32_t,int64_t,
uint8_t,uint16_t,uint32_t,uint64_t,
int_least8_t,int_least16_t,int_least32_t,int_least64_t,
uint_least8_t,uint_least16_t,uint_least32_t,uint_least64_t,
int_fast8_t,int_fast16_t,int_fast32_t,int_fast64_t,
uint_fast8_t,uint_fast16_t,uint_fast32_t,uint_fast64_t,
intptr_t,uintptr_t,intmax_t,uintmax_t,
__m128,__m128i,__m128d, __m256,__m256i,__m256d, __m512,__m512i,__m512d},
%structure
keywords=[6]{struct,union,enum,typedef,class,typename,template,namespace},
%storage class
keywords=[7]{static,register,auto,volatile,extern,const,constexpr,virtual,
explicit,export,inline,restrict,__restrict__,mutable},
%constants
keywords=[8]{M_PI,true,false,nullptr,memory_alignment_v,max_fixed_size,
is_same_v,value,
is_simd_v,is_simd_mask_v,is_abi_tag_v,is_simd_flag_type_v,
element_aligned,vector_aligned,overaligned,simd_size_v},
%access
keywords=[9]{public,protected,private,adl},
%exceptions
keywords=[10]{throw,try,catch},
%casts
keywords=[11]{const_cast,static_cast,dynamic_cast,reinterpret_cast,static_pointer_cast,
const_pointer_cast,dynamic_pointer_cast,simd_cast,static_simd_cast},
moredelim=**[s][\color{directives}\bfseries]{[[}{]]},
moredelim=**[s][\color{directives}\bfseries]{__attribute__((}{))},
moredelim=**[s][\color{namespacequal}]{std:}{:},
moredelim=**[s][\color{namespacequal}]{xstd:}{:},
moredelim=**[s][\color{namespacequal}]{stdx:}{:},
moredelim=**[s][\color{namespacequal}]{smd:}{:},
moredelim=**[s][\color{namespacequal}]{simd:}{:},
moredelim=**[s][\color{namespacequal}]{simd_generic:}{:},
moredelim=**[s][\color{namespacequal}]{bounded:}{:},
moredelim=**[s][\color{namespacequal}]{experimental:}{:},
moredelim=*[directive]\#,
directives={define,elif,else,endif,error,if,ifdef,ifndef,line,
include,pragma,undef,warning}
}[keywords,comments,strings,directives]
\iflstcpp@mono@
\definecolor{identifier}{cmyk}{0, 0, 0, 1}
\definecolor{namespacequal}{cmyk}{0, 0, 0, .7}
\definecolor{constants}{cmyk}{0, 0, 0, 1}
\definecolor{types}{gray}{0.2}
\definecolor{storageclass}{gray}{0.2}
\definecolor{codekeywords}{gray}{0.2}
\definecolor{strings}{cmyk}{0, 0, 0, 0.9}
\definecolor{directives}{cmyk}{0, 0, 0, 1}
\definecolor{comments}{cmyk}{0, 0, 0, 0.7}
\definecolor{lstoverlay}{gray}{0.4}
\else
\definecolor{identifier}{cmyk}{0, 0, 0, 1}
\definecolor{namespacequal}{cmyk}{0, 0, 0, .7}
\definecolor{constants}{rgb}{0.3, 0, 0}
\definecolor{types}{cmyk}{0.9, 0.2, 0.0, 0.4}
\definecolor{storageclass}{cmyk}{0.8, 0, 1.0, 0.4}
\definecolor{codekeywords}{cmyk}{0, 0, 1, 0.6}
\definecolor{strings}{rgb}{0.5, 0, 0.5}
\definecolor{directives}{rgb}{0, 0, 0.6}
\definecolor{comments}{cmyk}{1.0, 0.8, 0, 0.4}
\definecolor{lstoverlay}{cmyk}{0, 0.4, 0.5, 0.1}
\@ifclassloaded{beamer}{%
\mode<handout>{
\definecolor{identifier}{rgb}{0, 0, 0}
\definecolor{constants}{rgb}{0.3, 0, 0}
\definecolor{types}{rgb}{0, 0.1, 0}
\definecolor{storageclass}{rgb}{0, 0.2, 0}
\definecolor{codekeywords}{rgb}{0.2, 0.2, 0}
\definecolor{strings}{rgb}{0.2, 0, 0.2}
\definecolor{directives}{rgb}{0, 0, 0.3}
\definecolor{comments}{rgb}{0, 0, 0.6}
}
\mode<presentation>{
\usebeamercolor{normal text}
\usebeamercolor{alerted text}
\usebeamercolor{example text}
\usebeamercolor{local structure}
\colorlet{identifier}{normal text.fg}
\colorlet{namespacequal}{normal text.fg!33!normal text.bg}
\colorlet{types}{example text.fg!50!alerted text.fg}
\colorlet{storageclass}{example text.fg!75!normal text.fg}
\colorlet{constants}{alerted text.fg!75!normal text.fg}
\colorlet{codekeywords}{local structure.fg!75!normal text.fg}
\colorlet{comments}{local structure.fg!75!normal text.fg}
\colorlet{lstoverlay}{alerted text.fg}
}
}
\fi
\lstset{language=MyC++,
escapeinside={/*!}{*/},
basicstyle=\ttfamily,
identifierstyle=\color{identifier},
numberstyle=\ttfamily\tiny,
stepnumber=1,
stringstyle=\color{strings},
commentstyle=\color{comments},
directivestyle=\color{directives},
% combine: access,statements,casts (9,0,11)
keywordstyle=[0]\color{codekeywords}\bfseries,
keywordstyle=[9]\color{codekeywords}\bfseries,
keywordstyle=[11]\color{codekeywords}\bfseries,
%labels
keywordstyle=[1]\color{codekeywords}\bfseries,
%conditionals
keywordstyle=[2]\color{codekeywords}\bfseries,
%repeat
keywordstyle=[3]\color{codekeywords}\bfseries,
%operators
keywordstyle=[4]\color{codekeywords}\bfseries,
%types
keywordstyle=[5]\color{types},
%built-in types
keywordstyle=[12]\color{types}\bfseries,
%structure
keywordstyle=[6]\color{storageclass}\bfseries,
%storage class
keywordstyle=[7]\color{storageclass}\bfseries,
%constants
keywordstyle=[8]\color{constants},
%exceptions
keywordstyle=[10]\color{codekeywords}\bfseries,
aboveskip=0ex,belowskip=0ex,
showstringspaces=false
}
\lstdefinestyle{alert}{basicstyle=\ttfamily\bfseries\color{darkred},identifierstyle=\color{darkred}}
\newcommand{\lstalert}[1]{\alert{\underbar{\lstinline[style=alert]#1}}}
\lstdefinestyle{Vc}{}
\lstdefinestyle{VcHighlight}
{
emph={
simd,simd_mask
},emphstyle=\color{types}\bfseries\underbar,
emph={[2]
IndexesFromZero,Zero,One,Size
},emphstyle={[2]\color{constants}\bfseries\underbar},
emph={[3]
foreach_bit,any_of,all_of,none_of,some_of
},emphstyle={[3]\color{codekeywords}\bfseries\underbar}
}
% \lstoverlay[<height in number of lines>]{line-number}
% Don't forget to set the lst basicstyle font size before calling \lstoverlay
\newcommand\lstoverlay[2][1]{%
%\\\vspace{-\baselineskip}
\ifdefined\mode\mode<beamer>\fi%
\par\noindent%
\begin{tikzpicture}[overlay]
\draw[%
anchor=north west,
outer sep=0,
rounded corners,
opacity=1.0,
minimum width=\linewidth,
minimum height=#1\baselineskip%
] let
\n1 = {(#2-1.7)},
\p1 = (-0.5em,-\n1\baselineskip)
in
(\p1) node[draw=lstoverlay,very thin,fill=lstoverlay!15!white] {};
\end{tikzpicture}%
\vskip-\baselineskip\par%
\ifdefined\mode\mode<all>\fi%
}
\newcommand\lstoverlayX[3]{
\ifdefined\mode\mode<beamer>\fi%
\begin{tikzpicture}[overlay]
\path[anchor=west,rounded corners,opacity=1.0,minimum
width=#3 em,minimum height=\baselineskip] let
\n1 = {(#1)},
\n2 = {#2},
\p1 = (-0.5em+\n2 em,0.25em-\n1\baselineskip)
in
(\p1) node[draw=lstoverlay,very thin,fill=lstoverlay!15!white] {};
\end{tikzpicture}%\vskip-\baselineskip
\ifdefined\mode\mode<all>\fi%
}
% {line-number}{first char}{width in chars}
\newcommand\lstoverlayA[4][\ttfamily]{
\ifdefined\mode\mode<beamer>\fi%
\par\noindent\begingroup#1\begin{tikzpicture}[overlay]
\path[anchor=west,rounded corners,opacity=1.0,minimum
width={(#4 + 0.2) * width("x")},minimum height=\baselineskip] let
\p1 = ({((#3 - 0.1) * width("x")-0em)},0.25em-\directlua{tex.print(#2-1)}\baselineskip)
in
(\p1) node[draw=lstoverlay,very thin,fill=lstoverlay!15!white] {};
\end{tikzpicture}\vskip-\baselineskip\endgroup\par%
\ifdefined\mode\mode<all>\fi%
}
\lstset{frame=none,captionpos=b}
% vim: sw=2 sts=2 ai tw=120 et