Binary file coursework/cw01.pdf has changed
--- a/coursework/cw01.tex Thu Dec 07 12:26:41 2017 +0000
+++ b/coursework/cw01.tex Mon Jan 01 15:02:03 2018 +0000
@@ -65,7 +65,7 @@
cases for the basic regular expressions, but also for explicit cases for
the extended regular expressions. That means do not treat the extended
regular expressions by just translating them into the basic ones. See
-also Question 2, where you are asked to explicitly give the rules for
+also Question 3, where you are asked to explicitly give the rules for
\textit{nullable} and \textit{der} for the extended regular
expressions.\newpage
@@ -94,7 +94,7 @@
\noindent
Be careful that your implementation of \textit{nullable} and
\textit{der} satisfies for every regular expression $r$ the following
-two properties (see also Question 2):
+two properties (see also Question 3):
\begin{itemize}
\item $\textit{nullable}(r)$ if and only if $[]\in L(r)$
@@ -106,9 +106,14 @@
\subsection*{Question 1 (Unmarked)}
What is your King's email address (you will need it in
-Question 4)?
+Question 5)?
+
+\subsection*{Question 2 (Unmarked)}
-\subsection*{Question 2}
+In which programming languages have you written a program (like spent
+at least a day working on the program)?
+
+\subsection*{Question 3}
From the
lectures you have seen the definitions for the functions
@@ -173,7 +178,7 @@
\noindent
Does your matcher produce the expected results?
-\subsection*{Question 3}
+\subsection*{Question 4}
As you can see, there are a number of explicit regular expressions
that deal with single or several characters, for example:
@@ -213,7 +218,7 @@
\end{center}
-\subsection*{Question 4}
+\subsection*{Question 5}
Suppose $[a\mbox{-}z0\mbox{-}9\_\,.\mbox{-}]$ stands for the regular expression
@@ -262,7 +267,7 @@
\item \texttt{"/*test/*test*/"}
\end{enumerate}
-\subsection*{Question 5}
+\subsection*{Question 6}
Let $r_1$ be the regular expression $a\cdot a\cdot a$ and $r_2$ be
$(a^{\{19,19\}}) \cdot (a^?)$. Decide whether the following three
--- a/handouts/ho05.tex Thu Dec 07 12:26:41 2017 +0000
+++ b/handouts/ho05.tex Mon Jan 01 15:02:03 2018 +0000
@@ -3,6 +3,9 @@
\usepackage{../langs}
\usepackage{../grammar}
+% epsilon and left-recursion elimination
+% http://www.mollypages.org/page/grammar/index.mp
+
\begin{document}
\section*{Handout 5 (Grammars \& Parser)}
--- a/progs/fib.j Thu Dec 07 12:26:41 2017 +0000
+++ b/progs/fib.j Mon Jan 01 15:02:03 2018 +0000
@@ -3,92 +3,104 @@
.super java/lang/Object
.method public <init>()V
- aload_0
- invokenonvirtual java/lang/Object/<init>()V
- return
+ aload_0
+ invokenonvirtual java/lang/Object/<init>()V
+ return
.end method
-.method public static write(I)V
- .limit locals 1
- .limit stack 2
- getstatic java/lang/System/out Ljava/io/PrintStream;
- iload 0
- invokevirtual java/io/PrintStream/println(I)V
- return
+.method public static print(Ljava/lang/String;)V
+ .limit locals 5
+ .limit stack 5
+ aload 0
+ getstatic java/lang/System/out Ljava/io/PrintStream;
+ swap
+ invokevirtual java/io/PrintStream/print(Ljava/lang/String;)V
+ return
.end method
-.method public static read()I
- .limit locals 10
+.method public static write(I)V
+ .limit locals 1
+ .limit stack 2
+ getstatic java/lang/System/out Ljava/io/PrintStream;
+ iload 0
+ invokevirtual java/io/PrintStream/println(I)V
+ return
+.end method
+
+.method public static read()I
+ .limit locals 10
.limit stack 10
- ldc 0
- istore 1 ; this will hold our final integer
-Label1:
- getstatic java/lang/System/in Ljava/io/InputStream;
- invokevirtual java/io/InputStream/read()I
- istore 2
- iload 2
- ldc 10 ; the newline delimiter
- isub
- ifeq Label2
- iload 2
- ldc 32 ; the space delimiter
- isub
+ ldc 0
+ istore 1 ; this will hold our final integer
+Label1:
+ getstatic java/lang/System/in Ljava/io/InputStream;
+ invokevirtual java/io/InputStream/read()I
+ istore 2
+ iload 2
+ ldc 10 ; the newline delimiter
+ isub
+ ifeq Label2
+ iload 2
+ ldc 32 ; the space delimiter
+ isub
ifeq Label2
- iload 2
- ldc 48 ; we have our digit in ASCII, have to subtract it from 48
- isub
- ldc 10
- iload 1
- imul
- iadd
- istore 1
- goto Label1
-Label2:
- ;when we come here we have our integer computed in local variable 1
- iload 1
- ireturn
+ iload 2
+ ldc 48 ; we have our digit in ASCII, have to subtract it from 48
+ isub
+ ldc 10
+ iload 1
+ imul
+ iadd
+ istore 1
+ goto Label1
+Label2:
+ ;when we come here we have our integer computed in local variable 1
+ iload 1
+ ireturn
.end method
.method public static main([Ljava/lang/String;)V
- .limit locals 200
- .limit stack 200
+ .limit locals 200
+ .limit stack 200
-invokestatic fib/fib/read()I
-istore 0
-ldc 0
-istore 1
-ldc 1
-istore 2
-ldc 0
-istore 3
+ ldc "Fib"
+ invokestatic fib/fib/print(Ljava/lang/String;)V
+ invokestatic fib/fib/read()I
+ istore 0
+ ldc 0
+ istore 1
+ ldc 1
+ istore 2
-Loop_begin_2:
+Loop_start_1:
+
+ iload 0
+ ldc 0
+ if_icmple Loop_end_0
-ldc 0
-iload 0
-if_icmpge Loop_end_3
-iload 2
-istore 3
-iload 1
-iload 2
-iadd
-istore 2
-iload 3
-istore 1
-iload 0
-ldc 1
-isub
-istore 0
-goto Loop_begin_2
+ iload 2
+ istore 3
+ iload 1
+ iload 2
+ iadd
+ istore 2
+ iload 3
+ istore 1
+ iload 0
+ ldc 1
+ isub
+ istore 0
-Loop_end_3:
+ goto Loop_start_1
-iload 1
-invokestatic fib/fib/write(I)V
+Loop_end_0:
+ ldc "Result"
+ invokestatic fib/fib/print(Ljava/lang/String;)V
+ iload 2
+ invokestatic fib/fib/write(I)V
- return
-
+ return
.end method