From ffe6097c534c82b9402bb6f0a57abeebd075e61d Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 8 Jul 2026 11:04:34 +0200 Subject: Allow multiple fields with the same type --- doc/appendix.tex | 20 ++++++++++++-------- doc/language.tex | 52 +++++++++++++++++----------------------------------- doc/type-system.tex | 31 ++++++++++++++++++------------- 3 files changed, 47 insertions(+), 56 deletions(-) (limited to 'doc') diff --git a/doc/appendix.tex b/doc/appendix.tex index d06a49b..e98da0c 100644 --- a/doc/appendix.tex +++ b/doc/appendix.tex @@ -91,15 +91,17 @@ = \{`,' \}. + = \{`,' \}. + = \{`,' \}. = \{`,' \}. = \{`;' \}. - = [`->' `!\@' | `->' type]. + = [`:\@' `!\@' | `:\@' type]. - = `:\@' . + = `:\@' . = `[' `]' . @@ -107,9 +109,9 @@ = `record' [`(' `)'] [ \{`;' \}] `end'. - = `(' \{`,' \} `)'. + = `(' `)'. - = `proc' `(' [] `)' . + = `proc' . = \alt{} @@ -161,12 +163,14 @@ = [`import' \{import-declaration\}]. - = `proc' \\ - `(' [ \{`,' \}] `)' . + = `:\@' . + + = `(' [ \{`;' \}] `)' . - = `end'. + = `end'. - = `;' (block | `extern'). + = `proc' \\ + ( | `extern'). = diff --git a/doc/language.tex b/doc/language.tex index 26d8b48..04f8613 100644 --- a/doc/language.tex +++ b/doc/language.tex @@ -1,17 +1,5 @@ \part{Language} -An Elna program consists of one or more source files, called \textbf{modules}. - -Each module can declare \textbf{types}, \textbf{global variables} and -\textbf{procedures}, used by this module or exported to be used by other -modules. - -Each procedure can get some input and produce an output as a result of -executing a \textbf{statement block}, a list, where each \textbf{statement} -is executed in the order it appears in the block. - -\chapter{Vocabulary} - A language is an infinite set of sentences, namely the sentences well formed according to its syntax. In Elna, these sentences are called compilation units. Each unit is a finite sequence of \textit{tokens} from a finite vocabulary. @@ -19,6 +7,20 @@ The vocabulary of Elna consists of identifiers, reserved words, numbers, charact strings, operators, delimiters, and comments. They are called \textit{tokens} and are composed of sequences of characters. +To describe the syntax, an extended Backus-Naur Formalism called EBNF is used. + +\begin{itemize} + \item Alternatives are separated by |. + \item Brackets \lbrack{} and \rbrack{} denote optionality of the enclosed sentential form. + \item Braces \{ and \} denote its repetition (possibly 0 times). + \item Syntactic entities (non-terminal symbols) are denoted by English words expressing their + intuitive meaning. + \item Symbols of the language vocabulary (terminal symbols) are denoted by strings + enclosed in quote marks or by words in capital letters. +\end{itemize} + +\chapter{Vocabulary} + The following lexical rules must be observed when composing tokens. Blanks and line breaks must not occur within tokens (except in comments and strings). They are ignored unless they are essential to separate two consecutive tokens. @@ -153,29 +155,9 @@ of letters and cannot be used in the role of identifiers. \item (\ and\ ) \item \lbrack{} and \rbrack{} \item \{ and \} - \item Pointer - \item module - \item import - \item type - \item const - \item var - \item begin - \item end - \item proc - \item record - \item while - \item do - \item case - \item of - \item if - \item then - \item elsif - \item else - \item cast - \item return - \item true - \item false - \item nil + \item import, type, const, var, begin, end, proc, record + \item while, do, case, of, if, then, elsif, else, cast, return + \item true, false, nil \end{itemize} \section{Comments} diff --git a/doc/type-system.tex b/doc/type-system.tex index 3ae8a30..e1497be 100644 --- a/doc/type-system.tex +++ b/doc/type-system.tex @@ -1,5 +1,11 @@ \part{Type system} +An Elna program consists of one or more source files, called \textbf{modules}. + +Each module can declare \textbf{types}, \textbf{global variables} and +\textbf{procedures}, used by this module or exported to be used by other +modules. + \begin{grammar} = \alt{} @@ -27,7 +33,6 @@ \end{grammar} \begin{lstlisting}[caption=Example] -program; var x: Int; y: ^Int; @@ -44,7 +49,6 @@ end. \end{grammar} \begin{lstlisting}[caption=Example] -program; var array: [3]Int := [1, 2, 3]; begin @@ -55,20 +59,23 @@ end. \chapter{Procedure types} \begin{grammar} - = `proc' \\ - `(' [ \{`,' \}] `)' . + = \{`,' \}. + + = `:\@' . + + = `(' [ \{`;' \}] `)' . - = `end'. + = `end'. - = `;' (block | `extern'). + = `proc' \\ + ( | `extern'). - = [`->' `!\@' | `->' type]. + = [`:\@' `!\@' | `:\@' type]. - = `proc' `(' [] `)' . + = `proc' . \end{grammar} \begin{lstlisting}[caption=Example] -program; var a: proc(Int) -> Int; @@ -84,13 +91,12 @@ end. \chapter{Records} \begin{grammar} - = `:\@' . + = `:\@' . = `record' [`(' `)'] [ \{`;' \}] `end'. \end{grammar} \begin{lstlisting}[caption=Example] -program; type T = record x: Int @@ -111,11 +117,10 @@ end. \chapter{Enumerations} \begin{grammar} - = `(' \{`,' \} `)'. + = `(' `)'. \end{grammar} \begin{lstlisting}[caption=Example] -program; type E = (one, two, three); var -- cgit v1.2.3