Add grammar.tex, shamelessly copying from Pixeled. But the grammar is not exactly as implemented here, must revise it.
This commit is contained in:
parent
8f8bb8f918
commit
e137c28e81
2 changed files with 53 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
.idea/
|
||||
target/
|
||||
out/
|
||||
|
|
52
src/main/resources/docs/grammer.tex
Normal file
52
src/main/resources/docs/grammer.tex
Normal file
|
@ -0,0 +1,52 @@
|
|||
%! Author = manuel
|
||||
%! Date = 24.03.24
|
||||
|
||||
% Preamble
|
||||
\documentclass[11pt]{article}
|
||||
|
||||
% Packages
|
||||
\usepackage{amsmath}
|
||||
|
||||
% Document
|
||||
\begin{document}
|
||||
\begin{align}
|
||||
[\text{Prog}]
|
||||
&\to [\text{Stmt}]^* \\
|
||||
[\text{Stmt}] &\to
|
||||
\begin{cases}
|
||||
\text{exit}([\text{Expr}]); \\
|
||||
\text{let}\ \text{ident} = [\text{Expr}]; \\
|
||||
\text{ident} = \text{[Expr]}; \\
|
||||
\text{if} ([\text{Expr}])[\text{Scope}]\text{[IfPred]}\\
|
||||
[\text{Scope}]
|
||||
\end{cases} \\
|
||||
\text{[Scope]} &\to {[\text{Stmt}]^*} \\
|
||||
\text{[IfPred]} &\to
|
||||
\begin{cases}
|
||||
\text{elif}(\text{[Expr]})\text{[Scope]}\text{[IfPred]} \\
|
||||
\text{else}\text{[Scope]} \\
|
||||
\epsilon
|
||||
\end{cases} \\
|
||||
[\text{Expr}] &\to
|
||||
\begin{cases}
|
||||
[\text{Term}]
|
||||
\\
|
||||
[\text{BinExpr}]
|
||||
\end{cases} \\
|
||||
[\text{BinExpr}] &\to
|
||||
\begin{cases}
|
||||
[\text{Expr}] \^\ [\text{Expr}] & \text{prec} = 3 \\
|
||||
[\text{Expr}] * [\text{Expr}] & \text{prec} = 2 \\
|
||||
[\text{Expr}] / [\text{Expr}] & \text{prec} = 2 \\
|
||||
[\text{Expr}] \% [\text{Expr}] & \text{prec} = 2 \\
|
||||
[\text{Expr}] + [\text{Expr}] & \text{prec} = 1 \\
|
||||
[\text{Expr}] - [\text{Expr}] & \text{prec} = 1 \\
|
||||
\end{cases} \\
|
||||
[\text{Term}] &\to
|
||||
\begin{cases}
|
||||
\text{int\_lit} \\
|
||||
\text{ident} \\
|
||||
([\text{Expr}])
|
||||
\end{cases}
|
||||
\end{align}
|
||||
\end{document}
|
Loading…
Reference in a new issue