# HG changeset patch # User Christian Urban # Date 1573085236 0 # Node ID 75d9f9e5906f32c18691954540ab9c38a81114a5 # Parent 1ee523c4f09891922fa4f05cf4dd6d2fb504e1cc updated diff -r 1ee523c4f098 -r 75d9f9e5906f progs/comb2.scala --- a/progs/comb2.scala Wed Nov 06 23:27:19 2019 +0000 +++ b/progs/comb2.scala Thu Nov 07 00:07:16 2019 +0000 @@ -103,13 +103,13 @@ } lazy val AExp: Parser[String, AExp] = - (Te ~ "+" ~ AExp) ==> { case x ~ y ~ z => Aop("+", x, z): AExp } || - (Te ~ "-" ~ AExp) ==> { case x ~ y ~ z => Aop("-", x, z): AExp } || Te + (Te ~ "+" ~ AExp) ==> { case x ~ _ ~ z => Aop("+", x, z): AExp } || + (Te ~ "-" ~ AExp) ==> { case x ~ _ ~ z => Aop("-", x, z): AExp } || Te lazy val Te: Parser[String, AExp] = - (Fa ~ "*" ~ Te) ==> { case x ~ y ~ z => Aop("*", x, z): AExp } || - (Fa ~ "/" ~ Te) ==> { case x ~ y ~ z => Aop("/", x, z): AExp } || Fa + (Fa ~ "*" ~ Te) ==> { case x ~ _ ~ z => Aop("*", x, z): AExp } || + (Fa ~ "/" ~ Te) ==> { case x ~ _ ~ z => Aop("/", x, z): AExp } || Fa lazy val Fa: Parser[String, AExp] = - ("(" ~ AExp ~ ")") ==> { case x ~ y ~ z => y } || + ("(" ~ AExp ~ ")") ==> { case _ ~ y ~ _ => y } || IdParser ==> Var || NumParser ==> Num @@ -119,8 +119,8 @@ (AExp ~ "!=" ~ AExp) ==> { case x ~ _ ~ z => Bop("!=", x, z): BExp } || (AExp ~ "<" ~ AExp) ==> { case x ~ _ ~ z => Bop("<", x, z): BExp } || (AExp ~ ">" ~ AExp) ==> { case x ~ _ ~ z => Bop(">", x, z): BExp } || - ("(" ~ BExp ~ ")" ~ "&&" ~ BExp) ==> { case x ~ y ~ z ~ u ~ v => And(y, v): BExp } || - ("(" ~ BExp ~ ")" ~ "||" ~ BExp) ==> { case x ~ y ~ z ~ u ~ v => Or(y, v): BExp } || + ("(" ~ BExp ~ ")" ~ "&&" ~ BExp) ==> { case _ ~ y ~ _ ~ _ ~ v => And(y, v): BExp } || + ("(" ~ BExp ~ ")" ~ "||" ~ BExp) ==> { case _ ~ y ~ _ ~ _ ~ v => Or(y, v): BExp } || ("true" ==> (_ => True: BExp )) || ("false" ==> (_ => False: BExp )) || ("(" ~ BExp ~ ")") ==> { case _ ~ x ~ _ => x } @@ -128,14 +128,14 @@ // statement / statements lazy val Stmt: Parser[String, Stmt] = (("skip" ==> (_ => Skip: Stmt)) || - (IdParser ~ ":=" ~ AExp) ==> { case x ~ y ~ z => Assign(x, z): Stmt } || - ("write(" ~ IdParser ~ ")") ==> { case x ~y ~ z => Write(y): Stmt } || + (IdParser ~ ":=" ~ AExp) ==> { case x ~ _ ~ z => Assign(x, z): Stmt } || + ("write(" ~ IdParser ~ ")") ==> { case _ ~ y ~ _ => Write(y): Stmt } || ("if" ~ BExp ~ "then" ~ Block ~ "else" ~ Block) ==> - { case x ~ y ~ z ~ u ~ v ~ w => If(y, u, w): Stmt } || - ("while" ~ BExp ~ "do" ~ Block) ==> { case x ~ y ~ z ~ w => While(y, w) }) + { case _ ~ y ~ _ ~ u ~ _ ~ w => If(y, u, w): Stmt } || + ("while" ~ BExp ~ "do" ~ Block) ==> { case _ ~ y ~ _ ~ w => While(y, w) }) lazy val Stmts: Parser[String, Block] = - (Stmt ~ ";" ~ Stmts) ==> { case x ~ y ~ z => x :: z : Block } || + (Stmt ~ ";" ~ Stmts) ==> { case x ~ _ ~ z => x :: z : Block } || (Stmt ==> ( s => List(s) : Block)) // blocks (enclosed in curly braces) diff -r 1ee523c4f098 -r 75d9f9e5906f slides/slides06.pdf Binary file slides/slides06.pdf has changed diff -r 1ee523c4f098 -r 75d9f9e5906f slides/slides06.tex --- a/slides/slides06.tex Wed Nov 06 23:27:19 2019 +0000 +++ b/slides/slides06.tex Thu Nov 07 00:07:16 2019 +0000 @@ -373,31 +373,31 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[c] -\frametitle{Operator Precedences} - - -To disambiguate - -\begin{center} -\bl{\begin{tabular}{lcl} -$\meta{E}$ & $::=$ & $\meta{E} \cdot + \cdot \meta{E} \;|\;\meta{E} \cdot * \cdot \meta{E} \;|\;( \cdot \meta{E} \cdot ) \;|\;\meta{N}$ \\ -\end{tabular}} -\end{center} - -Decide on how many precedence levels, say\medskip\\ -highest for \bl{$()$}, medium for \bl{*}, lowest for \bl{+} - -\begin{center} -\bl{\begin{tabular}{lcl} -$\meta{E}_{low}$ & $::=$ & $\meta{E}_{med} \cdot + \cdot \meta{E}_{low} \;|\; \meta{E}_{med}$ \\ -$\meta{E}_{med}$ & $::=$ & $\meta{E}_{hi} \cdot * \cdot \meta{E}_{med} \;|\; \meta{E}_{hi}$\\ -$\meta{E}_{hi}$ & $::=$ & $( \cdot \meta{E}_{low} \cdot ) \;|\;\meta{N}$ \\ -\end{tabular}} -\end{center}\pause - -\small What happens with \bl{$1 + 3 + 4$}? -\end{frame} +%\begin{frame}[c] +%\frametitle{Operator Precedences} +% +% +%To disambiguate +% +%\begin{center} +%\bl{\begin{tabular}{lcl} +%$\meta{E}$ & $::=$ & $\meta{E} \cdot + \cdot \meta{E} \;|\;\meta{E} \cdot * \cdot \meta{E} \;|\;( \cdot \meta{E} \cdot ) \;|\;\meta{N}$ \\ +%\end{tabular}} +%\end{center} +% +%Decide on how many precedence levels, say\medskip\\ +%highest for \bl{$()$}, medium for \bl{*}, lowest for \bl{+} +% +%\begin{center} +%\bl{\begin{tabular}{lcl} +%$\meta{E}_{low}$ & $::=$ & $\meta{E}_{med} \cdot + \cdot \meta{E}_{low} \;|\; \meta{E}_{med}$ \\ +%$\meta{E}_{med}$ & $::=$ & $\meta{E}_{hi} \cdot * \cdot \meta{E}_{med} \;|\; \meta{E}_{hi}$\\ +%$\meta{E}_{hi}$ & $::=$ & $( \cdot \meta{E}_{low} \cdot ) \;|\;\meta{N}$ \\ +%\end{tabular}} +%\end{center}\pause +% +%\small What happens with \bl{$1 + 3 + 4$}? +%\end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -672,22 +672,38 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\mode{ \begin{frame}[c] -\frametitle{\begin{tabular}{c}Java Virtual Machine\end{tabular}} +\frametitle{Java Virtual Machine} \begin{itemize} \item introduced in 1995 \item is a stack-based VM (like Postscript, CLR of .Net) -\item contains a JIT compiler -\item many languages take advantage of JVM's infrastructure (JRE) +\item contains a JIT compiler\\ +\begin{itemize} +\item From the Cradle to the Holy Graal - the JDK Story +\item \url{https://www.youtube.com/watch?v=h419kfbLhUI} +\end{itemize} \item is garbage collected $\Rightarrow$ no buffer overflows \item some languages compile to the JVM: Scala, Clojure\ldots \end{itemize} -\end{frame}} +\end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] +\frametitle{LLVM} + +\begin{itemize} +\item LLVM started by academics in 2000 (University of Illinois in +Urbana-Champaign) +\item suite of compiler tools +\item SSA-based intermediate language +\item no need to allocate registers +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\begin{frame}[c]