slides08.tex
changeset 70 e6868bd2942b
parent 69 cc3f7908b942
child 76 373cf55a3ca5
--- a/slides08.tex	Wed Nov 21 07:28:28 2012 +0000
+++ b/slides08.tex	Wed Nov 21 09:04:11 2012 +0000
@@ -151,7 +151,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \mode<presentation>{
 \begin{frame}[c]
-\frametitle{\begin{tabular}{c}Building a Web Browser\end{tabular}}
+\frametitle{\begin{tabular}{c}Building a ``Web Browser''\end{tabular}}
 
 Using a lexer: assume the following regular expressions
 
@@ -171,11 +171,11 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \mode<presentation>{
 \begin{frame}[c]
-\frametitle{\begin{tabular}{c}Interpreting a List of Token\end{tabular}}
+\frametitle{\begin{tabular}{c}Interpreting a List of Tokens\end{tabular}}
 
 \begin{itemize}
-\item text should be formatted consistently up to a specified width, say 60 characters 
-\item potential linebreaks are inserted by the formatter
+\item the text should be formatted consistently up to a specified width, say 60 characters 
+\item potential linebreaks are inserted by the formatter (not the input)
 \item repeated whitespaces are ``condensed'' to a single whitepace
 \item \bl{$<\!p\!>$} \bl{$<\!\slash{}p\!>$}  start/end paragraph
 \item \bl{$<\!b\!>$} \bl{$<\!\slash{}b\!>$}  start/end bold
@@ -190,7 +190,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \mode<presentation>{
 \begin{frame}[c]
-\frametitle{\begin{tabular}{c}Interpreting a List of Token\end{tabular}}
+\frametitle{\begin{tabular}{c}Interpreting a List of Tokens\end{tabular}}
 
 The lexer cannot prevent errors like
 
@@ -256,9 +256,9 @@
 Sequence parser (code \bl{$p\sim q$})\bigskip
 
 \begin{itemize}
-\item apply \bl{$p$} first producing a set of pairs
+\item apply first \bl{$p$} producing a set of pairs
 \item then apply \bl{$q$} to the unparsed parts
-\item the combine the results:\\ \mbox{}\;\;((input$_1$, input$_2$), unparsed part)
+\item then combine the results:\\ \mbox{}\;\;((output$_1$, output$_2$), unparsed part)
 \end{itemize}
 
 \begin{center}
@@ -282,15 +282,16 @@
 
 \begin{itemize}
 \item apply \bl{$p$} producing a set of pairs
-\item then apply the function \bl{$f$} to each fist component
+\item then apply the function \bl{$f$} to each first component
 \end{itemize}
 
 \begin{center}
 \begin{tabular}{l}
 \large \bl{$\{(f(o_1), u_1) \;|\; (o_1, u_1) \in p(\text{input})\}$}
 \end{tabular}
-\end{center}
+\end{center}\bigskip\bigskip\pause
 
+\bl{$f$} is the semantic action (``what to do with the parsed input'')
 
 \end{frame}}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
@@ -396,7 +397,7 @@
 \bl{$(ntp \sim ntp) \Longrightarrow f$}
 \end{center}
 
-where \bl{$f$} is the semantic action (what to do with the pair)
+where \bl{$f$} is the semantic action (``what to do with the pair'')
 
 \end{itemize}
 
@@ -478,6 +479,39 @@
 \end{frame}}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\mode<presentation>{
+\begin{frame}[c]
+\frametitle{\begin{tabular}{c}Scannerless Parsers\end{tabular}}
+
+\begin{itemize}
+\item input: \alert{string}
+\item output: set of (output\_type, \alert{string})
+\end{itemize}\bigskip
+
+but lexers are better when whitespaces or comments need to be filtered out
+
+\end{frame}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\mode<presentation>{
+\begin{frame}[c]
+\frametitle{\begin{tabular}{c}Successful Parses\end{tabular}}
+
+\begin{itemize}
+\item input: string
+\item output: \alert{set of} (output\_type, string)
+\end{itemize}\bigskip
+
+a parse is successful whenever the input has been
+fully ``consumed'' (that is the second component is empty)
+
+
+\end{frame}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \mode<presentation>{
 \begin{frame}[c]
@@ -578,7 +612,7 @@
 \begin{itemize}
 \item we record when we recursively called a parser\bigskip
 \item whenever the is a recursion, the parser must have consumed something --- so
-I can decrease the input string/list of token by one (at the end)
+we can decrease the input string/list of token by one (at the end)
 \end{itemize}
 \end{frame}}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
@@ -590,15 +624,17 @@
 
 
 \begin{center}
-\bl{\begin{tabular}{lcl}
+\bl{\begin{tabular}{@{}lcl@{}}
 $Stmt$ & $\rightarrow$ &  $\text{skip}$\\
               & $|$ & $Id := AExp$\\
               & $|$ & $\text{if}\; B\!Exp \;\text{then}\; Block \;\text{else}\; Block$\\
-              & $|$ & $\text{while}\; B\!Exp \;\text{do}\; Block$\bigskip\\
+              & $|$ & $\text{while}\; B\!Exp \;\text{do}\; Block$\medskip\\
 $Stmt$ & $\rightarrow$ &  $Stmt \;\text{;}\; Stmts$\\
-              & $|$ & $Stmt$\bigskip\\
+              & $|$ & $Stmt$\medskip\\
 $Block$ & $\rightarrow$ &  $\{ Stmts \}$\\
-                & $|$ & $Stmt$\\
+                & $|$ & $Stmt$\medskip\\
+$AExp$ & $\rightarrow$ & \ldots\\
+$BExp$ & $\rightarrow$ & \ldots\\
 \end{tabular}}
 \end{center}