summaryrefslogtreecommitdiff
path: root/rulesquotify.tex
blob: d218fd6e091b90c533241de431e2e797a5ec4620 (plain) (blame)
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
% vim: set spelllang=nl:
\subsection{\texttt{Quotify}}
\label{sec:rules:quotify}

\begin{quote}
	q - "Quotifies" the string on top of the stack, so that it can be placed into
	a Smurf program as a literal string, eg \texttt{Arthur "two-sheds" Jackson}
	becomes \texttt{"Arthur $\backslash$"two-sheds$\backslash$" Jackson"}.
\end{quote}


Er worden aanhalingstekens om de string bovenop de stack gezet. Als er in de
oorspronkelijke string aanhalingstekens, backslashes of LF-karakters staan, dan
wordt hier een \verb$\$ voor geplaatst. Hiervoor gebruiken we de hulpfunctie
$\escapeop$.

Dit geeft de volgende regel:
$$
\begin{prooftree}
	\trans
		{\pgm}{\ip}{(\push{\texttt{"}\escape{s}\texttt{"}}{\stk'}, \str) }
		{\ip}{\op}{\st}
	\justifies
	\trans
		{\StmQuotify:\pgm}{\ip}{(\stk,\str)}
		{\ip}{\op}{\st}
	\using{\rquotifyns}
	\qquad
	\text{met $(s, stk') = \pop{\stk}$.}
\end{prooftree}
$$

$$
	\escape{c~s} =
		\begin{cases}
			\texttt{\textbackslash}~c~s & \text{als
				$c\in\{\texttt{"},\texttt{\textbackslash},\text{het LF-karakter}\}$} \\
			c~\escape{s}                & \text{anderszins}
		\end{cases}
$$