\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{} \alt{} \alt{} \alt{} \alt{} . \end{grammar} \chapter{Primitive types} \begin{itemize} \item Pointer \item Word \item Int \item Bool \item String \item Char \end{itemize} \chapter{Pointer types} \begin{grammar} = `^' . \end{grammar} \begin{lstlisting}[caption=Example] var x: Int; y: ^Int; begin y := @x; y^ := 0 end. \end{lstlisting} \chapter{Static array} \begin{grammar} = `[' `]' . \end{grammar} \begin{lstlisting}[caption=Example] var array: [3]Int := [1, 2, 3]; begin array[1] := array[2] end. \end{lstlisting} \chapter{Procedure types} \begin{grammar} = \{`,' \}. = `:\@' . = `(' [ \{`;' \}] `)' . = [`return' ] `end'. = `proc' \\ ( | `extern'). = [`:\@' `!\@' | `:\@' type]. = `proc' . \end{grammar} \begin{lstlisting}[caption=Example] var a: proc(Int) -> Int; proc f(x: Int) -> Int; end; begin a := f; a(0) end. \end{lstlisting} \chapter{Records} \begin{grammar} = `:\@' . = `record' [`(' `)'] [ \{`;' \}] `end'. \end{grammar} \begin{lstlisting}[caption=Example] type T = record x: Int end; U = record(T) y: Int; z: Int end; var u: U; begin u := U{x: 0, y: 1, z: 2}; u.x := 3 end. \end{lstlisting} \chapter{Enumerations} \begin{grammar} = `(' `)'. \end{grammar} \begin{lstlisting}[caption=Example] type E = (one, two, three); var e: E; begin e := E.one end. \end{lstlisting}