Debian Codegraph @

texmf-dist/source/latex/qsharp/qsharp.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2018 by Microsoft.
4 % ---------------------------------------------------------------------------
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 % http://www.latex-project.org/lppl.txt
10 % and version 1.3 or later is part of all distributions of LaTeX
11 % version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status `maintained'.
14 %
15 % The Current Maintainer of this work is Christopher Granade ([email protected]).
16 %
17 % This work consists of the files qsharp.dtx and qsharp.ins,
18 % the derived filebase qsharp.sty, and the associated installer file Install.ps1.
19 %
20 % \fi
21 %
22 % \iffalse
23 %<*driver>
24 \ProvidesFile{qsharp.dtx}
25 %</driver>
26 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
27 %<package>\ProvidesPackage{qsharp}
28 %<*package>
29 [2019/01/14 v0.3.1901.1401 Initial public version.]
30 %</package>
31 %
32 %<*driver>
33 \documentclass{ltxdoc}
34 \usepackage[pretty,uselistings]{revquantum}[2015/12/29]
35 \lstset{basicstyle=\ttfamily\footnotesize, commentstyle=\rmfamily}
36 \usepackage{xcolor}
37 \usepackage{qsharp}
38 \usepackage{sourcecodepro}
39 \EnableCrossrefs
40 \CodelineIndex
41 \RecordChanges
42 \begin{document}
43 \DocInput{qsharp.dtx}
44 \PrintChanges
45 ^^A \PrintIndex
46 \end{document}
47 %</driver>
48 % \fi
49 %
50 % \CheckSum{0}
51 %
52 % \CharacterTable
53 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
54 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
55 % Digits \0\1\2\3\4\5\6\7\8\9
56 % Exclamation \! Double quote \" Hash (number) \#
57 % Dollar \$ Percent \% Ampersand \&
58 % Acute accent \' Left paren \( Right paren \)
59 % Asterisk \* Plus \+ Comma \,
60 % Minus \- Point \. Solidus \/
61 % Colon \: Semicolon \; Less than \<
62 % Equals \= Greater than \> Question mark \?
63 % Commercial at \@ Left bracket \[ Backslash \\
64 % Right bracket \] Circumflex \^ Underscore \_
65 % Grave accent \` Left brace \{ Vertical bar \|
66 % Right brace \} Tilde \~}
67 %
68 %
69 % \changes{v0.3.1901.1401}{2019/01/14}{Initial public version.}
70 % \changes{v0.1}{2018/12/04}{Initial version.}
71 %
72 % \DoNotIndex{\newcommand,\newenvironment}
73 %
74 % \providecommand*{\url}{\texttt}
75 % \newcommand{\DescribeColor}[1]{%
76 % \DescribeMacro{#1}%
77 % {\color{#1} \textbullet}
78 %
79 % }
80 %
81 % \GetFileInfo{qsharp.dtx}
82 % \title{The \textsf{qsharp} package}
83 % \author{Christopher Granade \\ \url{[email protected]}}
84 % \date{\fileversion~from \filedate}
85 %
86 % \maketitle
87 %
88 % \section{Introduction}
89 %
90 % The \textsf{qsharp} package provides syntax highlighting for the \qs~language \citeneed.
91 %
92 % \section{Examples}
93 %
94 % \begin{lstlisting}[style=QSharp]
95 % namespace Example {
96 % open Microsoft.Quantum.Primitive;
97 %
98 % /// # Summary
99 % /// Prepares $(\ket{00} + \ket{11}) / \sqrt{2}$.
100 % operation PrepareEntangledPair(left : Qubit, right : Qubit) : Unit {
101 % body {
102 % H(left);
103 % CNOT(left, right);
104 % }
105 % adjoint auto;
106 % controlled auto;
107 % controlled adjoint auto;
108 % }
109 % }
110 % \end{lstlisting}
111 %
112 % \StopEventually{}
113 %
114 % \section{Implementation}
115 %
116 % \iffalse
117 %<*package>
118 % \fi
119 %
120
121 % \begin{macrocode}
122
123 \usepackage{listings}
124 \usepackage{xcolor}
125
126 % \end{macrocode}
127
128 % \subsection{Notation} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129
130 % \begin{macrocode}
131
132 \newcommand{\qs}{Q\#}
133
134 % \end{macrocode}
135
136 % \subsection{Color Definitions} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137
138 % \begin{macrocode}
139
140 \definecolor{cud-reddish-purple}{RGB}{204,121,167}
141 \colorlet{doc-comment}{cud-reddish-purple!60!black}
142
143 % \end{macrocode}
144
145 % \subsection{Language Definition} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146
147 % \begin{macrocode}
148
149 \makeatletter
150 \lstdefinelanguage{QSharp}{
151 morekeywords={
152 namespace,
153 open,
154 operation,
155 function,
156 body,
157 adjoint,
158 auto,
159 controlled,
160 let,
161 set,
162 mutable,
163 using,
164 borrowing,
165 Adjoint,
166 Qubit, Unit,
167 Zero, One
168 },
169 % Define built-in primitives as second-order keywords.
170 morekeywords=[2]{H, CNOT, I, X, Y, Z, Message},
171 sensitive=true,
172 morecomment=[l]{//},
173 morecomment=[l][\lst@commentstyle\color{doc-comment}]{///}
174 }
175 \makeatother
176
177 % \end{macrocode}
178 %
179 % We also provide styles that set options that are commonly useful with \qs.
180 %
181 % \begin{macrocode}
182
183 \lstdefinestyle{QSharp}{
184 language=QSharp,
185 mathescape=true
186 }
187
188 % \end{macrocode}
189
190 %
191 % \iffalse
192 %</package>
193 % \fi
194 %
195 % \Finale
196 \endinput