--- a/progs/comb2.scala Wed Oct 25 00:05:59 2017 +0100
+++ b/progs/comb2.scala Tue Oct 31 21:32:12 2017 +0000
@@ -4,6 +4,7 @@
import scala.language.implicitConversions
import scala.language.reflectiveCalls
+
abstract class Parser[I <% Seq[_], T] {
def parse(ts: I): Set[(T, I)]
@@ -70,6 +71,7 @@
lazy val F: Parser[String, Int] =
("(" ~ E ~ ")") ==> { case ((x, y), z) => y} || NumParser
+println(E.parse_all("123"))
println(E.parse_all("1*2+3"))
println(E.parse_all("1+2*3"))
println(E.parse_all("1+2+3"))
--- a/progs/token.scala Wed Oct 25 00:05:59 2017 +0100
+++ b/progs/token.scala Tue Oct 31 21:32:12 2017 +0000
@@ -129,8 +129,6 @@
lexing(("ab" | "a") ~ ("b" | ONE), "ab")
-
-
// some "rectification" functions for simplification
def F_ID(v: Val): Val = v
def F_RIGHT(f: Val => Val) = (v:Val) => Right(f(v))
Binary file slides/slides05.pdf has changed
--- a/slides/slides05.tex Wed Oct 25 00:05:59 2017 +0100
+++ b/slides/slides05.tex Tue Oct 31 21:32:12 2017 +0000
@@ -274,7 +274,7 @@
\bl{$Rec(x,v)$}\medskip
\item \bl{$nullable(x:r) \dn nullable(r)$}
-\item \bl{$der\,c\,(x:r) \dn (x:der\,c\,r)$}
+\item \bl{$der\,c\,(x:r) \dn der\,c\,r$}
\item \bl{$mkeps(x:r) \dn Rec(x, mkeps(r))$}
\item \bl{$inj\,(x:r)\,c\,v \dn Rec(x, inj\,r\,c\,v)$}
\end{itemize}\bigskip\bigskip
@@ -709,15 +709,15 @@
\frametitle{Parse Trees}
\mbox{}\\[-16mm]
-\bl{\begin{plstx}: \meta{E} ::= \meta{F} | \meta{F} \cdot * \cdot \meta{F}\\
-: \meta{F} ::= \meta{T} | \meta{T} \cdot + \cdot \meta{T} | \meta{T} \cdot - \cdot \meta{T}\\
-: \meta{T} ::= num\_token | ( \cdot \meta{E} \cdot )\\
+\bl{\begin{plstx}: \meta{E} ::= \meta{F} | \meta{T} \cdot + \cdot \meta{E} | \meta{T} \cdot - \cdot \meta{E}\\
+: \meta{T} ::= \meta{F} | \meta{F} \cdot * \cdot \meta{T}\\
+: \meta{F} ::= num\_token | ( \cdot \meta{E} \cdot )\\
\end{plstx}}
\begin{center}\small
\begin{tikzpicture}[level distance=8mm, blue]
\node {$\meta{E}$}
- child {node {$\meta{F}$}
+ child {node {$\meta{T}$}
child {node {$\meta{T}$}
child {node {(\,$\meta{E}$\,)}
child {node{$\meta{F}$ *{} $\meta{F}$}