X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=Docsyntax.tex;h=f8ad812f68132a4a546510dfa5330591f4c81986;hp=e0d2758fa311ea43031e94b4f8e449d033227bba;hb=HEAD;hpb=565fbd61dca527c23888e08783d0d91cee458524 diff --git a/Docsyntax.tex b/Docsyntax.tex index e0d2758..f8ad812 100644 --- a/Docsyntax.tex +++ b/Docsyntax.tex @@ -42,8 +42,8 @@ The reserved words used in syntax are the following: \\ \begin{tabular}{lll} {\reserved{bool}} &{\reserved{else}} &{\reserved{false}} \\ {\reserved{if}} &{\reserved{int}} &{\reserved{print}} \\ -{\reserved{readBool}} &{\reserved{readInt}} &{\reserved{true}} \\ -{\reserved{while}} & & \\ +{\reserved{readBool}} &{\reserved{readInt}} &{\reserved{return}} \\ +{\reserved{true}} &{\reserved{while}} & \\ \end{tabular}\\ The symbols used in syntax are the following: \\ @@ -52,10 +52,10 @@ The symbols used in syntax are the following: \\ {\symb{;}} &{\symb{\{}} &{\symb{\}}} \\ {\symb{{$=$}}} &{\symb{(}} &{\symb{)}} \\ {\symb{{$+$}{$+$}}} &{\symb{{$-$}{$-$}}} &{\symb{{$-$}}} \\ -{\symb{!}} &{\symb{{$<$}}} &{\symb{{$<$}{$=$}}} \\ -{\symb{{$>$}}} &{\symb{{$>$}{$=$}}} &{\symb{{$=$}{$=$}}} \\ -{\symb{!{$=$}}} &{\symb{{$+$}}} &{\symb{*}} \\ -{\symb{/}} & & \\ +{\symb{!}} &{\symb{,}} &{\symb{{$<$}}} \\ +{\symb{{$<$}{$=$}}} &{\symb{{$>$}}} &{\symb{{$>$}{$=$}}} \\ +{\symb{{$=$}{$=$}}} &{\symb{!{$=$}}} &{\symb{{$+$}}} \\ +{\symb{*}} &{\symb{/}} & \\ \end{tabular}\\ \subsection*{Comments} @@ -78,20 +78,19 @@ All other symbols are terminals.\\ \end{tabular}\\ \begin{tabular}{lll} -{\nonterminal{Stms}} & {\arrow} &{\nonterminal{ListStm}} \\ +{\nonterminal{Program}} & {\arrow} &{\nonterminal{ListFuncStm}} \\ \end{tabular}\\ \begin{tabular}{lll} {\nonterminal{Stm}} & {\arrow} &{\nonterminal{Exp}} {\terminal{;}} \\ & {\delimit} &{\terminal{\{}} {\nonterminal{ListStm}} {\terminal{\}}} \\ - & {\delimit} &{\terminal{int}} {\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}} {\terminal{;}} \\ - & {\delimit} &{\terminal{bool}} {\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}} {\terminal{;}} \\ - & {\delimit} &{\terminal{int}} {\nonterminal{Ident}} {\terminal{;}} \\ - & {\delimit} &{\terminal{bool}} {\nonterminal{Ident}} {\terminal{;}} \\ + & {\delimit} &{\nonterminal{Type}} {\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}} {\terminal{;}} \\ + & {\delimit} &{\nonterminal{Type}} {\nonterminal{Ident}} {\terminal{;}} \\ & {\delimit} &{\terminal{while}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} \\ & {\delimit} &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} {\terminal{else}} {\nonterminal{Stm}} \\ & {\delimit} &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} \\ & {\delimit} &{\terminal{print}} {\nonterminal{Exp}} {\terminal{;}} \\ + & {\delimit} &{\terminal{return}} {\nonterminal{Exp}} {\terminal{;}} \\ \end{tabular}\\ \begin{tabular}{lll} @@ -120,6 +119,7 @@ All other symbols are terminals.\\ & {\delimit} &{\terminal{!}} {\nonterminal{Exp3}} \\ & {\delimit} &{\terminal{readInt}} \\ & {\delimit} &{\terminal{readBool}} \\ + & {\delimit} &{\nonterminal{Ident}} {\terminal{(}} {\nonterminal{ListExp}} {\terminal{)}} \\ & {\delimit} &{\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} \\ \end{tabular}\\ @@ -128,6 +128,41 @@ All other symbols are terminals.\\ & {\delimit} &{\nonterminal{Stm}} {\nonterminal{ListStm}} \\ \end{tabular}\\ +\begin{tabular}{lll} +{\nonterminal{ListExp}} & {\arrow} &{\emptyP} \\ + & {\delimit} &{\nonterminal{Exp}} \\ + & {\delimit} &{\nonterminal{Exp}} {\terminal{,}} {\nonterminal{ListExp}} \\ +\end{tabular}\\ + +\begin{tabular}{lll} +{\nonterminal{Decl}} & {\arrow} &{\nonterminal{Type}} {\nonterminal{Ident}} \\ +\end{tabular}\\ + +\begin{tabular}{lll} +{\nonterminal{ListDecl}} & {\arrow} &{\emptyP} \\ + & {\delimit} &{\nonterminal{Decl}} \\ + & {\delimit} &{\nonterminal{Decl}} {\terminal{,}} {\nonterminal{ListDecl}} \\ +\end{tabular}\\ + +\begin{tabular}{lll} +{\nonterminal{Func}} & {\arrow} &{\nonterminal{Type}} {\nonterminal{Ident}} {\terminal{(}} {\nonterminal{ListDecl}} {\terminal{)}} {\terminal{\{}} {\nonterminal{ListStm}} {\terminal{\}}} \\ +\end{tabular}\\ + +\begin{tabular}{lll} +{\nonterminal{ListFunc}} & {\arrow} &{\emptyP} \\ + & {\delimit} &{\nonterminal{Func}} {\nonterminal{ListFunc}} \\ +\end{tabular}\\ + +\begin{tabular}{lll} +{\nonterminal{FuncStm}} & {\arrow} &{\nonterminal{Stm}} \\ + & {\delimit} &{\nonterminal{Func}} \\ +\end{tabular}\\ + +\begin{tabular}{lll} +{\nonterminal{ListFuncStm}} & {\arrow} &{\emptyP} \\ + & {\delimit} &{\nonterminal{FuncStm}} {\nonterminal{ListFuncStm}} \\ +\end{tabular}\\ + \begin{tabular}{lll} {\nonterminal{Op0}} & {\arrow} &{\terminal{{$<$}}} \\ & {\delimit} &{\terminal{{$<$}{$=$}}} \\