summaryrefslogtreecommitdiff
path: root/rulespush.tex
blob: 8bc94e6e9e6015b0c231299e5932a78c7b74710e (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
41
42
43
44
% vim: set spelllang=nl:
\subsection{\texttt{Push}}
\label{sec:rules:push}

\begin{quote}
	"text" - Places the string on top of the stack (without the quotes). The
	string may include the following escape sequences:
	
	\verb$\n$ = newline \\
	\verb$\"$ = the \verb$"$ character \\
	\verb$\\$ = the \verb$\$ character.
\end{quote}

De string tussen de aanhalingstekens wordt op de stack gezet, nadat escape
sequences eruit zijn gehaald middels de hulpfunctie $\unescapeop$. Het is,
zoals het commentaar op de specificatie~\cite{safalra} aangeeft, niet
gedefinieerd wat er met ongeldige escape sequences gebeurt.

Dit geeft de volgende regel:
\therpushns%

De definitie van $\unescapeop$ is als volgt:

$$
	\unescape c =
		\begin{cases}
			\text{het LF-karakter}      & \text{als $c=\texttt{n}$} \\
			\texttt{"}                  & \text{als $c=\texttt{"}$} \\
			\texttt{\textbackslash}     & \text{als $c=\texttt{\textbackslash}$} \\
			\texttt{\textbackslash~$c$} & \text{anderszins}
		\end{cases}
$$

Het laatste alternatief geeft aan dat `ongeldige escape sequences' worden
behandeld alsof de backslash er twee keer stond. Dit is in overeenstemming met
het commentaar op de specificatie en met de Perl-interpreter: %todo referentie
\begin{quote}
	This [the specification] does not specify the behaviour of invalid escape
	sequences. The Perl-interpreter treats invalid escape sequences as if the
	backslash had occured twice - that is, \textbackslash X is treated as
	\textbackslash\textbackslash X. For maximum compatibility, Smurf programs
	should not rely on this behaviour and should always ensure valid escape
	sequences are used.
\end{quote}