
diff -r 8a09c03a098f -r 6808c4ce5fc8 slides/slides05.tex
--- a/slides/slides05.tex	Tue Oct 27 13:53:27 2020 +0000
+++ b/slides/slides05.tex	Wed Oct 28 16:56:28 2020 +0000
@@ -76,7 +76,7 @@
     
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[t]
-\frametitle{Lexer, Parser}
+\frametitle{Parser}
 \mbox{}\\[-16mm]\mbox{}
 
 \begin{center}
@@ -108,8 +108,25 @@
   \end{tikzpicture}
   \end{center}
   
-Today a parser.  
-  
+
+\only<2>{
+\begin{textblock}{1}(3,6)
+\begin{bubble}[8.5cm]
+\normalsize
+parser input: a sequence of tokens\smallskip\\
+
+{\small\hspace{5mm}\code{key(read) lpar id(n) rpar semi}}\smallskip\\
+
+parser output: an abstract syntax tree\smallskip\\
+\footnotesize
+\hspace{2cm}\begin{tikzpicture}
+  \node {\code{read}}
+    child {node {\code{lpar}}}
+    child {node {\code{n}}}
+    child {node {\code{rpar}}};
+\end{tikzpicture}
+\end{bubble}
+\end{textblock}}
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -177,6 +194,16 @@
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+\begin{frame}[c]
+  \LARGE
+  \begin{center}
+  Time flies like an arrow.\\ 
+  Fruit flies like bananas.
+  \end{center}  
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+  
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c]
 \frametitle{CFGs}
@@ -210,22 +237,22 @@
 
 A grammar for palindromes over the alphabet~\bl{$\{a,b\}$}:
 
-\bl{\begin{plstx}[margin=3cm]
+\only<1>{%
+\bl{\begin{plstx}[margin=1cm]
 : \meta{S} ::= a\cdot\meta{S}\cdot a\\
 : \meta{S} ::= b\cdot\meta{S}\cdot b\\
 : \meta{S} ::= a\\
 : \meta{S} ::= b\\
 : \meta{S} ::= \epsilon\\
-\end{plstx}}\pause
-
-or
+\end{plstx}}}
+%
+\only<2>{%
+\bl{\begin{plstx}[margin=1cm]
+: \meta{S} ::=  a\cdot \meta{S}\cdot a | b\cdot \meta{S}\cdot b | a | b | \epsilon\\
+\end{plstx}}}
 
-\bl{\begin{plstx}[margin=2cm]
-: \meta{S} ::=  a\cdot \meta{S}\cdot a | b\cdot \meta{S}\cdot b | a | b | \epsilon\\
-\end{plstx}}\pause\bigskip
-
-\small
-Can you find the grammar rules for matched parentheses?
+%\small
+%Can you find the grammar rules for matched parentheses?
 
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
@@ -235,7 +262,7 @@
 \frametitle{Arithmetic Expressions}
 
 \bl{\begin{plstx}[margin=3cm,one per line]
-: \meta{E} ::=  num\_token 
+: \meta{E} ::=  0 \mid 1 \mid 2 \mid ... \mid 9
    | \meta{E} \cdot + \cdot \meta{E} 
    | \meta{E} \cdot - \cdot \meta{E} 
    | \meta{E} \cdot * \cdot \meta{E} 
@@ -292,7 +319,7 @@
 \frametitle{Example Derivation}
 
 \bl{\begin{plstx}[margin=3cm,one per line]
-: \meta{E} ::=  num\_token 
+: \meta{E} ::=  0 \mid 1 \mid 2 \mid ... \mid 9
    | \meta{E} \cdot + \cdot \meta{E} 
    | \meta{E} \cdot - \cdot \meta{E} 
    | \meta{E} \cdot * \cdot \meta{E} 
@@ -373,10 +400,38 @@
 
 \bl{\begin{plstx}: \meta{E} ::= \meta{T} | \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 )\\
+: \meta{F} ::= 0 ... 9 | ( \cdot \meta{E} \cdot )\\
 \end{plstx}}
 
-\begin{center}\small
+\begin{textblock}{5}(6, 5)
+\small
+\begin{tikzpicture}[level distance=10mm, blue]
+  \node {$\meta{E}$}
+  child {node {$\meta{T}$}
+    child {node {$\meta{F}$} child {node {1}}}
+  }
+  child {node {+}}
+  child {node {$\meta{E}$}
+    child[sibling distance=10mm] {node {$\meta{T}$}
+      child {node {$\meta{F}$} child {node {2}}}
+      child {node {+}}
+      child {node {$\meta{T}$} child {node {$\meta{F}$} child {node {3}}}}
+    }
+    child {node {+}}
+    child {node {$\meta{E}$} child {node {$\meta{T}$}
+        child {node {$\meta{F}$} child {node {4}}}}}
+  } 
+  ;
+\end{tikzpicture}
+\end{textblock}
+
+\begin{textblock}{5}(1, 10)
+\bl{\texttt{1 + 2 * 3 + 4}}
+\end{textblock}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
 \begin{tikzpicture}[level distance=8mm, blue]
   \node {$\meta{E}$}
     child {node {$\meta{T}$} 
@@ -399,21 +454,13 @@
                  }}
     }};
 \end{tikzpicture}
-\end{center}
-
-\begin{textblock}{5}(1, 6.5)
-\bl{\texttt{(2*3)+(3+4)}}
-\end{textblock}
-
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[t]
 \frametitle{Arithmetic Expressions}
 
 \bl{\begin{plstx}[margin=3cm,one per line]
-: \meta{E} ::=  num\_token 
+: \meta{E} ::=  0..9 
    | \meta{E} \cdot + \cdot \meta{E} 
    | \meta{E} \cdot - \cdot \meta{E} 
    | \meta{E} \cdot * \cdot \meta{E} 




