defined trait Expr defined class N defined class Plus
Thursday, September 19, 2024
What questions does your neighbor have?
Concrete syntax is …
Abstract syntax is …
Parsers convert …, which have deal with …
… and … are ways to to describe and deal with a common form of ambiguity.
\[\begin{array}{rrrl} \text{expressions} & e & \mathrel{::=}& n \mid e\;\texttt{/}\;e \mid e\;\texttt{-}\;e \end{array}\]
\[\begin{array}{rrrl} \text{expressions $\texttt{Expr}$} & e & \mathrel{::=}& \texttt{N(} n \texttt{)} \\ & & \mid& \texttt{Divide(}e_1\texttt{,}\;e_2\texttt{)} \\ & & \mid& \texttt{Minus(}e_1\texttt{,}\;e_2\texttt{)} \\ \text{integers} & n \end{array}\]
Try hard to read this as concrete syntax. It is unambiguous, right? Why?
Take a Theory of Computation course for more language theory. We focus here on the practical aspect of reading and writing BNF grammars.
There are also many advanced parser libraries and generator tools. You might use one in a Compiler Construction course.
\[ \begin{array}{rrrl} \text{expressions} & e & \mathrel{::=}& n \mid e + e \\ \text{numbers} & n \end{array} \]
defined trait Expr defined class N defined class Plus
Automate the top-down, leftmost parsing derivation.
Two rules:
import $ivy.$
What’s a combinator?
defined object ExprParser