COntinue spec

This commit is contained in:
Dmitry Boulytchev 2020-02-10 15:24:45 +03:00
parent 0b26e754e3
commit 142d784174
6 changed files with 69 additions and 8 deletions

View file

@ -18,5 +18,5 @@ which can be imported by an end-user application.
The concrete syntax for compilation unit is shown on Fig.~\ref{compilation_unit}. Besides optional imports a unit must contain
a \nonterm{scopeExpression}, which may contain some definitions and computations. Note, a unit can not be empty. The computations described in
a unit are performed at unit initialization time (see~\ref{separate_compilation}).
a unit are performed at unit initialization time (see Chapter~\ref{sec:driver}).

View file

@ -115,7 +115,7 @@ designate integer constants 1 and 0 respectively, character constant is implicit
of one-byte characters. Infix constants allow to reference a functional value associated with corresponding infix operator, and functional constant (\emph{lambda-expression})
designates an anonymous functional value in the form of closure.
\subsection{\lstinline|skip| and \lstinline|return| Expressions}
\subsection{\texttt{skip} and \texttt{return} Expressions}
Expression \lstinline|skip| can be used to designate a no-value when no action is needed (for example, in the body of unit which contains only declarations).
\lstinline|return| expression can be used to immediately copmlete the execution of current function call; optional return value can be specified.

View file

@ -23,12 +23,20 @@ The driver operates in a few modes:
all external units object files, generating executable.
\end{itemize}
In the native modes, the driver also creates import files ("\texttt{.i}") which are required for external units import to
work properly. These files has to reside in the same directory as object files for corresponding units.
Each natively compiled object file implicitly references all imported units; the top-level expression of each
unit is compiled into \emph{unit initialization procedure}, which calls unit initialization procedures of
all imported units in the same order these unites were imported. It is guaranteed that unit initialization
procedure for each unit will be called only once (regardless of the imports' shape for the whole application).
Additionally, the following options can be given to the driver:
\begin{itemize}
\item "\texttt{-I $path$}"~--- specifies a path to look for external units. Multiples instances of this option can be given in driver's
invocation, and the paths are looked up in that order.
\item "\texttt{-dp}"~--- forced the driver to dump the AST of compiled unit. The dump is written in the file with the same
\item "\texttt{-dp}"~--- forces the driver to dump the AST of compiled unit. The dump is written in the file with the same
basename as the source one, with the extension replaced with "\texttt{.ast}".
\item "\texttt{-ds}"~--- forces the driver to sump stack machine code. The option is only in effect in stack interpreter on
native mode. The sump is written in the file "\texttt{.sm}".
@ -38,4 +46,4 @@ Additionally, the following options can be given to the driver:
Apart from the paths specified by the "\texttt{-I}" option the driver uses the environment variable "\texttt{LAMA\_STD}"
to locate the runtime and standard libraries (see~\ref{sec:stdlib}). Thus, the units from standard libraries are accessible
without any "-I" option given.
without any "\texttt{-I}" option given.

View file

@ -1 +1,55 @@
\chapter{Standard Library}
\label{sec:stdlib}
The standard library is comprised of the runtime for the language and the set of pre-shipped units written in \lama itself.
\section{Unit \texttt{Std}}
The unit "\texttt{Std}" provides the interface for the runtime of the language. The implementation of
entities, defined in "\texttt{Std}", reside in the runtime itself. The import of "\texttt{Std}"
is added implicitly by the compiler and can not be specified by an end user.
The following declarations are accessible:
\paragraph{\lstinline|fun read ()|}~--- reads an integer value from the standard input, printing a prompt "\texttt{>}".
\paragraph{\lstinline|fun write (int)|}~--- writes an integer value to the standard output.
\paragraph{\lstinline|sysargs|}~--- a variable which holds an array of command-lines arguments of the application (including the
name of the executable itself).
\paragraph{\lstinline|fun makeArray (size)|}~--- creates a fresh array of a given length. The elements of the array are left uninitialized.
\paragraph{\lstinline|fun makeString (size)|}~--- creates a fresh string of a given length. The elements of the string are left uninitialized.
\paragraph{\lstinline|fun stringcat (list)|}~--- takes a list of strings and returns the concatenates all its elements.
\paragraph{\lstinline|fun matchSubString (subj, patt, pos)|}~--- takes two strings "\texttt{subj}" and "\text{patt}" and integer position "\texttt{pos}" and
checks if a substing of "\texttt{subj}" starting at position "\texttt{pos}" is equal to "\text{patt}"; returns integer value.
\lstinline|fun sprintf (fmt, ...)|
\lstinline|fun substring (str, pos, len)|
\lstinline|infix ++ at + (str1, str2)|
\lstinline|fun clone (value)|
\lstinline|fun hash (value)|
\lstinline|fun compare (value1, value2)|
\lstinline|fun fst (value)|
\lstinline|fun snd (value)|
\lstinline|fun hd (value)|
\lstinline|fun tl (value)|
\lstinline|fun readLine ()|
\lstinline|fun printf (fmt, ...)|
\lstinline|fun fopen (fname, mode)|
\lstinline|fun fclose (file)|
\lstinline|fun fread (fname)|
\lstinline|fun fwrite (fname, contents)|
\lstinline|fun fprintf (file, fmt, ...)|
\lstinline|fun regexp (str)|
\lstinline|fun regexpMatch (pattern, subj, pos)|
\lstinline|fun failure (fmt, ...)|

View file

@ -1,7 +1,7 @@
all:
pdflatex spec.tex
bibtem spec
pdflatex.tex
bibtex spec
pdflatex spec.tex
clean:
rm -Rf *~ *.log *.aux
rm -Rf *~ *.log *.aux *.toc *.bbl *.blg *.out

View file

@ -26,7 +26,6 @@
\usepackage{subcaption}
\usepackage{placeins}
\usepackage{xspace}
\usepackage{ostap}
\usepackage{bm}
\makeatletter