diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-07-08 11:04:34 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-07-08 11:04:34 +0200 |
| commit | ffe6097c534c82b9402bb6f0a57abeebd075e61d (patch) | |
| tree | 9079255db89007046fe1446d27009df8585a154e /doc/type-system.tex | |
| parent | 79521d91b2bb85652fd29f5c44279338d55c757f (diff) | |
| download | elna-ffe6097c534c82b9402bb6f0a57abeebd075e61d.tar.gz | |
Allow multiple fields with the same type
Diffstat (limited to 'doc/type-system.tex')
| -rw-r--r-- | doc/type-system.tex | 31 |
1 files changed, 18 insertions, 13 deletions
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} <type> = <array-type> \alt{} <pointer-type> @@ -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} -<procedure-heading> = `proc' <identifier-definition> \\ - `(' [<field> \{`,' <field>\}] `)' <return-declaration>. +<identifiers> = <identifier> \{`,' <identifier>\}. + +<parameter> = <identifiers> `:\@' <type>. + +<procedure-heading> = `(' [<parameter> \{`;' <parameter>\}] `)' <return-declaration>. -<block> = <constant-part> <variable-part> <statement-part> `end'. +<procedure-body> = <constant-part> <variable-part> <statement-part> `end'. -<procedure-declaration> = <procedure-heading> `;' (block | `extern'). +<procedure-declaration> = `proc' <identifier-definition> <procedure-heading> \\ + (<procedure-body> | `extern'). -<return-declaration> = [`->' `!\@' | `->' type]. +<return-declaration> = [`:\@' `!\@' | `:\@' type]. -<procedure-type> = `proc' `(' [<types>] `)' <return-declaration>. +<procedure-type> = `proc' <procedure-heading>. \end{grammar} \begin{lstlisting}[caption=Example] -program; var a: proc(Int) -> Int; @@ -84,13 +91,12 @@ end. \chapter{Records} \begin{grammar} -<field> = <identifier> `:\@' <type>. +<field> = <identifiers> `:\@' <type>. <record-type> = `record' [`(' <identifier> `)'] [<field> \{`;' <field>\}] `end'. \end{grammar} \begin{lstlisting}[caption=Example] -program; type T = record x: Int @@ -111,11 +117,10 @@ end. \chapter{Enumerations} \begin{grammar} -<enumeration-type> = `(' <identifier> \{`,' <identifier>\} `)'. +<enumeration-type> = `(' <identifiers> `)'. \end{grammar} \begin{lstlisting}[caption=Example] -program; type E = (one, two, three); var |
