36 lines
1.1 KiB
Markdown
36 lines
1.1 KiB
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}]; \\
|
|
\text{if}\ ([\text{Expr}])\ [\text{Scope}] \\
|
|
[\text{Scope}] \\
|
|
\end{cases} \\
|
|
[\text{Expr}] &\to
|
|
\begin{cases}
|
|
\text{[Term]} \\
|
|
\text{[BinExpr]} \\
|
|
\end{cases} \\
|
|
[\text{Scope}] &\to \{[\text{Stmt}]^*\} \\
|
|
[\text{BinExpr}] &\to
|
|
\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. |