summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--introexmp.tex2
-rw-r--r--rules.tex2
-rw-r--r--rulescat.tex15
-rw-r--r--rulesoutput.tex30
-rw-r--r--rulespush.tex28
-rw-r--r--rulesquotify.tex17
6 files changed, 92 insertions, 2 deletions
diff --git a/introexmp.tex b/introexmp.tex
index b0f7b4d..e372889 100644
--- a/introexmp.tex
+++ b/introexmp.tex
@@ -2,7 +2,7 @@
\subsection{Voorbeelden}
\label{sec:intro:exmp}
Nu we alle commando's hebben gezien bekijken we nog een paar voorbeelden die
-aangeven hoe conditionele executie kan worden in Smurf.
+aangeven hoe conditionele executie kan worden behaald in Smurf.
% Dit is waarschijnlijk te veel anders.
%
diff --git a/rules.tex b/rules.tex
index 664b042..8b01508 100644
--- a/rules.tex
+++ b/rules.tex
@@ -21,6 +21,6 @@ Smurfprogramma's makkelijker zal maken.
\input{rulesget}
\input{rulesput}
\input{rulesinput}
-%\input{rulesoutput}
+\input{rulesoutput}
\input{rulesexec}
diff --git a/rulescat.tex b/rulescat.tex
new file mode 100644
index 0000000..d05e0e5
--- /dev/null
+++ b/rulescat.tex
@@ -0,0 +1,15 @@
+% vim: set spelllang=nl:
+\subsection{\texttt{Cat}}
+\label{sec:rules:cat}
+
+\begin{quote}
+ + - concatenates the top two strings on the stack. The string pushed earlier
+ appears earlier in the resulting string, eg
+ "Zork" "mid" +
+ would result in the string "Zorkmid" being placed on the stack.
+\end{quote}
+
+De twee strings die als laatste op de stack zijn gezet worden dus samen gevoegd en terug op de stack gezet.
+
+Dit geeft de volgende regel:
+
diff --git a/rulesoutput.tex b/rulesoutput.tex
new file mode 100644
index 0000000..7bdc741
--- /dev/null
+++ b/rulesoutput.tex
@@ -0,0 +1,30 @@
+% vim: set spelllang=nl:
+\subsection{\texttt{Output}}
+
+\begin{quote}
+ o - Output the string at the top of the stack
+\end{quote}
+
+ Net als bij het inputcommando gaan we op een abstracte wijze met de output om.
+We houden gedurende het hele programma een stack van strings, genaamd $\Output$ bij
+waar het programma zijn output naar wegschrijft.
+
+Dit geeft de volgende regel:
+
+$$
+\prooftree
+ \trans
+ {\pgm}{\ip}{(\stk',\str)}
+ {\ip'}{[\op:\Nil]}{\st}
+ \justifies
+ \trans
+ {\StmOutput:\pgm}{\ip}{(\stk,\str)}
+ {\ip'}{[\op:[var:\Nil]]}{\st}
+ \using{\routputns}
+ \qquad
+ \text{met $(\var,\stk') = \pop{\stk}$.}
+\endprooftree
+$$
+
+Merk op dat eenzelfde regel waar $var$ niet achteraan maar vooraan zou komen te staan, even geldig is. Geen van beide opties is beter dan de ander omdat we geen aannames doen over hoe de $\Output$-stack wordt verwerkt.
+
diff --git a/rulespush.tex b/rulespush.tex
new file mode 100644
index 0000000..3362b50
--- /dev/null
+++ b/rulespush.tex
@@ -0,0 +1,28 @@
+% 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: newline, the " - character and the $\backslash$ - character
+\end{quote}
+
+De string tussen de quotes word op de stack gezet. Eerst word er nog gecontroleerd op newlines, "-characters en $\backslash$ characters. Dit gaat doormiddel van de hulpfunctie unescape.
+
+Dit geeft de volgende regel:
+
+$$
+\begin{prooftree}
+ \trans
+ {\pgm}{\ip}{(\push(\unescape(String)\stk), \str)}
+ {\ip}{\op}{\st}
+ \justifies
+ \trans
+ {\StmPush<String>:\pgm}{\ip}{(\stk,\str)}
+ {\ip}{\op}{\st}
+ \using{\rpushns}
+ \qquad
+\end{prooftree}
+$$
+
+
diff --git a/rulesquotify.tex b/rulesquotify.tex
new file mode 100644
index 0000000..50acc22
--- /dev/null
+++ b/rulesquotify.tex
@@ -0,0 +1,17 @@
+% 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
+ Arthur "two-sheds" Jackson
+ becomes
+ "Arthur $\backslash$ "two-sheds $\backslash$ " Jackson"
+\end{quote}
+
+
+Er worden dus quotes om de string heen gezet. Als er in de oorspronkelijke string quotes stonden dan wordt voor iedere van deze quotes een "$\backslash$" geplaats.
+
+Dit geeft de volgende regel:
+