33 lines
984 B
Markdown
33 lines
984 B
Markdown
# Grammar
|
|
Basically just an outline of how to type things out and how things work syntactically.
|
|
$$
|
|
\begin{align}
|
|
[\text{prog}] &\to [\text{stmt}]^* \\
|
|
[\text{stmt}]^* &\to
|
|
\begin{cases}
|
|
\text{exit}([\text{expr}]); \\
|
|
\text{var}\space\text{ident} = [\text{expr}]; \\
|
|
\end{cases} \\
|
|
[\text{expr}] &\to
|
|
\begin{cases}
|
|
\text{[Term]}
|
|
\text{[BinExpr]} \\
|
|
\end{cases} \\
|
|
[\text{BinExpr}]
|
|
\begin{cases}
|
|
[\text[{Expr}]!] &prec=3\\
|
|
[\text[{Expr}] ^ \text{[Expr]}] &prec=2\\
|
|
[\text[{Expr}] \times \text{[Expr]}] &prec=1\\
|
|
[\text[{Expr}] \div \text{[Expr]}] &prec=1\\
|
|
[\text[{Expr}] + \text{[Expr]}] &prec=0\\
|
|
[\text[{Expr}] - \text{[Expr]}] &prec=0\\
|
|
\end{cases} \\
|
|
[\text{Term}] &\to
|
|
\begin{cases}
|
|
\text{int\_lit} \\
|
|
\text{ident} \\
|
|
(\text{Expr}) \\
|
|
\end{cases} \\
|
|
\end{align}
|
|
$$
|
|
### Note: i hate katex or however you spell it. Its hell. |