|
| 1 | +\input source_header.tex |
| 2 | + |
| 3 | +\begin{document} |
| 4 | + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 5 | + \docheader{2018}{Source}{\S 2} |
| 6 | + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7 | + |
| 8 | +\input source_intro.tex |
| 9 | + |
| 10 | +\section*{Changes} |
| 11 | + |
| 12 | +Compared to Source \S 1, Source \S 2 has the following changes: |
| 13 | +\begin{itemize} |
| 14 | +\item \lstinline{[]}: Empty list. |
| 15 | +\item List library: Functions for creating, accessing and processing lists. |
| 16 | +\end{itemize} |
| 17 | + |
| 18 | +\input source_bnf.tex |
| 19 | + |
| 20 | +\begin{alignat*}{9} |
| 21 | +&& \textit{statement} &&\quad ::= &\quad && \textbf{\texttt{const}}\ \textit{name} \ |
| 22 | + \textbf{\texttt{=}}\ \textit{expression} \ \textbf{\texttt{;}} |
| 23 | + && \textrm{constant declaration} \\ |
| 24 | +&& && | &\quad && \textbf{\texttt{function}}\ \textit{name} \ |
| 25 | + \textbf{\texttt{(}}\ \textit{parameters} \ \textbf{\texttt{)}}\\ |
| 26 | +&& && & && \textbf{\texttt{\{}}\ \textit{statement} \ \textbf{\texttt{\}}} \quad |
| 27 | + && \textrm{function declaration}\\ |
| 28 | +&& && | &\quad && \textbf{\texttt{return}}\ \textit{expression} \ \textbf{\texttt{;}} |
| 29 | + && \textrm{return statement}\\ |
| 30 | +&& && | &\quad && \textit{if-statement} \quad |
| 31 | + && \textrm{conditional statement}\\ |
| 32 | +&& && | &\quad && \textit{statement} \ |
| 33 | + \textit{statement} && \textrm{statement sequence} \\ |
| 34 | +&& && | &\quad && \textit{expression} \ \textbf{\texttt{;}} |
| 35 | + && \textrm{expression statement} \\[1mm] |
| 36 | +&& \textit{parameters} && ::= &\quad && \epsilon\ | \ \textit{name} \ |
| 37 | + (\ \textbf{\texttt{,}} \ \textit{name}\ )\ \ldots |
| 38 | + && \textrm{function parameters} \\[1mm] |
| 39 | +&& \textit{if-statement} && ::= &\quad && \textbf{\texttt{if}}\ |
| 40 | + \textbf{\texttt{(}}\ \textit{expression} \ \textbf{\texttt{)}}\ |
| 41 | + \textbf{\texttt{\{}}\ \textit{statement} \ \textbf{\texttt{\}}}\\ |
| 42 | +&& && & && \textbf{\texttt{else}}\ |
| 43 | + (\ \textbf{\texttt{\{}}\ \textit{statement}\ \textbf{\texttt{\}}} |
| 44 | + \ | \ |
| 45 | + \textit{if-statement} \ ) |
| 46 | + && \textrm{conditional statement} \\[1mm] |
| 47 | +&& \textit{expression} && ::= &\quad && \textit{number} && \textrm{primitive number expression}\\ |
| 48 | +&& && | &\quad && \textbf{\texttt{true}}\ |\ \textbf{\texttt{false}} |
| 49 | + && \textrm{primitive boolean expression}\\ |
| 50 | +&& && | &\quad && \textit{string} && \textrm{primitive string expression}\\ |
| 51 | +&& && | &\quad && \textit{name} && \textrm{name expression}\\ |
| 52 | +&& && | &\quad && \textit{expression} \ \textit{binary-operator} \ |
| 53 | + \textit{expression} \qquad |
| 54 | + && \textrm{binary operator combination}\\ |
| 55 | +&& && | &\quad && \textit{unary-operator} \ |
| 56 | + \textit{expression} |
| 57 | + && \textrm{unary operator combination}\\ |
| 58 | +&& && | &\quad && \textit{expression} \ |
| 59 | + \textbf{\texttt{(}}\ \textit{expressions}\ |
| 60 | + \textbf{\texttt{)}} |
| 61 | + && \textrm{(compound) function application}\\ |
| 62 | +&& && | &\quad && (\ \textit{name}\ | \ |
| 63 | + \textbf{\texttt{(}}\ \textit{parameters}\ \textbf{\texttt{)}}\ |
| 64 | + )\ |
| 65 | + \texttt{\textbf{=>}}\ \textit{expression} |
| 66 | + && \textrm{function definition expression}\\ |
| 67 | +&& && | &\quad && \textit{expression} \ \textbf{\texttt{?}}\ |
| 68 | + \textit{expression} |
| 69 | + \ \textbf{\texttt{:}}\ |
| 70 | + \textit{expression}\ |
| 71 | + && \textrm{conditional expression}\\ |
| 72 | +&& && | &\quad && \textbf{\texttt{[]}} |
| 73 | + && \textrm{primitive empty list expression}\\ |
| 74 | +&& && | &\quad && \textbf{\texttt{(}}\ \textit{expression} \ |
| 75 | + \textbf{\texttt{)}} && \textrm{parenthesised expression}\\[1mm] |
| 76 | +&& \textit{binary-operator} \ |
| 77 | + && ::= &\quad && \textbf{\texttt{+}}\ |\ \textbf{\texttt{-}}\ |\ \textbf{\texttt{*}}\ |\ \textbf{\texttt{/}}\ |\ \textbf{\texttt{\%}}\ |\ |
| 78 | + \textbf{\texttt{===}}\ |\ \textbf{\texttt{!==}}\ \\ |
| 79 | +&& && | &\quad && \texttt{\textbf{>}}\ |\ \texttt{\textbf{<}}\ |\ \texttt{\textbf{>=}}\ |\ \texttt{\textbf{<=}}\ |
| 80 | + |\ \textbf{\texttt{\&\&}}\ |\ \texttt{\textbf{||}}\ \\[1mm] |
| 81 | +&& \textit{unary-operator} |
| 82 | + && ::= &\quad && \textbf{\texttt{!}}\ |\ \textbf{\texttt{-}}\\[1mm] |
| 83 | +&& \textit{expressions} && ::= &\quad && \epsilon\ | \ \textit{expression}\ ( |
| 84 | + \ \textbf{\texttt{,}} \ |
| 85 | + \textit{expression} \ |
| 86 | + )\ \ldots |
| 87 | + && \textrm{argument expressions} |
| 88 | +\end{alignat*} |
| 89 | + |
| 90 | +\input source_return |
| 91 | + |
| 92 | +\input source_names |
| 93 | + |
| 94 | +\input source_lists |
| 95 | + |
| 96 | +\input source_numbers |
| 97 | + |
| 98 | +\input source_strings |
| 99 | + |
| 100 | +\input source_typing |
| 101 | + |
| 102 | +\input source_comments |
| 103 | + |
| 104 | + |
| 105 | + \end{document} |
0 commit comments