--- a/LINKS Tue Nov 06 08:18:53 2018 +0000
+++ b/LINKS Mon Nov 12 11:33:51 2018 +0000
@@ -1,3 +1,7 @@
+Thinking Forth (Book to read)
+=================
+
+
Compiler courses
http://www.cse.chalmers.se/edu/year/2017/course/TDA283/lectures/
http://www.cs.columbia.edu/~sedwards/classes/2017/4115-fall/index.html
Binary file coursework/cw02.pdf has changed
Binary file coursework/cw03.pdf has changed
--- a/progs/comb1.scala Tue Nov 06 08:18:53 2018 +0000
+++ b/progs/comb1.scala Mon Nov 12 11:33:51 2018 +0000
@@ -99,7 +99,15 @@
lazy val F: Parser[String, Int] =
("(" ~ E ~ ")") ==> { case ((x, y), z) => y } | NumParserInt
+lazy val E: Parser[String, String] =
+ (T ~ "+" ~ E) ==> { case ((x, y), z) => "(" + x + ")+(" + z + ")"} | T
+lazy val T: Parser[String, String] =
+ (F ~ "*" ~ T) ==> { case ((x, y), z) => "(" + x + ")*("+ z + ")"} | F
+lazy val F: Parser[String, String] =
+ ("(" ~ E ~ ")") ==> { case ((x, y), z) => y } | NumParser
+println(E.parse_all("1+3+4"))
+println(E.parse("1+3+4"))
println(E.parse_all("4*2+3"))
println(E.parse_all("4*(2+3)"))
println(E.parse_all("(4)*((2+3))"))
@@ -126,12 +134,12 @@
lazy val S : Parser[String, String] =
("1" ~ S ~ S) ==> { case ((x, y), z) => x + y + z } | ""
-S.parse("1" * 15)
+S.parse("1" * 17)
lazy val U : Parser[String, String] =
("1" ~ U) ==> { case (x, y) => x + y } | ""
-U.parse("1" * 15)
+U.parse("1" * 25)
U.parse("11")
U.parse("11111")
Binary file slides/slides06.pdf has changed
--- a/slides/slides06.tex Tue Nov 06 08:18:53 2018 +0000
+++ b/slides/slides06.tex Mon Nov 12 11:33:51 2018 +0000
@@ -29,7 +29,7 @@
\begin{tabular}{ll}
Email: & christian.urban at kcl.ac.uk\\
Office: & N\liningnums{7.07} (North Wing, Bush House)\\
- Slides: & KEATS (also home work is there)\\
+ Slides: & KEATS (also homework is there)\\
\end{tabular}
\end{center}