From 0b26e754e3b9a5153cba7fb1778bb06b649b8886 Mon Sep 17 00:00:00 2001 From: Dmitry Boulytchev Date: Mon, 10 Feb 2020 04:05:53 +0300 Subject: [PATCH] Spec driver section --- doc/spec/03.04.expressions.tex | 2 +- doc/spec/04.driver_options.tex | 1 - doc/spec/04.extensions.tex | 10 +++++ doc/spec/05.driver_options.tex | 41 +++++++++++++++++++ ...rd_library.tex => 06.standard_library.tex} | 0 doc/spec/Makefile | 7 ++++ doc/spec/spec.tex | 5 ++- 7 files changed, 62 insertions(+), 4 deletions(-) delete mode 100644 doc/spec/04.driver_options.tex create mode 100644 doc/spec/04.extensions.tex create mode 100644 doc/spec/05.driver_options.tex rename doc/spec/{05.standard_library.tex => 06.standard_library.tex} (100%) create mode 100644 doc/spec/Makefile diff --git a/doc/spec/03.04.expressions.tex b/doc/spec/03.04.expressions.tex index 872c6a87b..9c8476885 100644 --- a/doc/spec/03.04.expressions.tex +++ b/doc/spec/03.04.expressions.tex @@ -113,7 +113,7 @@ Multiple postfixes are allowed, for example The basic form of expression is \nonterm{primary}. The simplest form of primary is an identifier or constant. Keywords \lstinline|true| and \lstinline|false| designate integer constants 1 and 0 respectively, character constant is implicitly converted into its ASCII code. String constants designate arrays of one-byte characters. Infix constants allow to reference a functional value associated with corresponding infix operator, and functional constant (\emph{lambda-expression}) -designates a anonymous functional value in the form of closure. +designates an anonymous functional value in the form of closure. \subsection{\lstinline|skip| and \lstinline|return| Expressions} diff --git a/doc/spec/04.driver_options.tex b/doc/spec/04.driver_options.tex deleted file mode 100644 index 7ab6098d9..000000000 --- a/doc/spec/04.driver_options.tex +++ /dev/null @@ -1 +0,0 @@ -\chapter{Driver Options and Separate Compilation} diff --git a/doc/spec/04.extensions.tex b/doc/spec/04.extensions.tex new file mode 100644 index 000000000..f91572a63 --- /dev/null +++ b/doc/spec/04.extensions.tex @@ -0,0 +1,10 @@ +\chapter{Extensions} +\label{sec:extensions} + +\section{Custom Infix Operators} + +\section{Lazy Values and Eta-extension} + +\section{Dot Notation} + +\section{Mutable Closures} diff --git a/doc/spec/05.driver_options.tex b/doc/spec/05.driver_options.tex new file mode 100644 index 000000000..4396ff061 --- /dev/null +++ b/doc/spec/05.driver_options.tex @@ -0,0 +1,41 @@ +\chapter{Driver Options and Separate Compilation} +\label{sec:driver} + +Driver is a command-line unitility "\texttt{lamac}" which controls the invocation of the compiler. The +general format of invocation is + +\begin{lstlisting} + lamac $\;options\; filename$ +\end{lstlisting} + +Only one file name can be processed at once, the file name and the options can be specified in +arbitrary order. + +The driver operates in a few modes: + +\begin{itemize} +\item Interpreter mode. Performs an interpretation of a source program using the reference source-level interpreter ("\texttt{-i}") or + compiles and runs a source on the stack machine ("\texttt{-s}"). In this mode separate compilation is not supported, thus no external + units can be accessed (including "\lstinline|Std|"), only the standard set of builtins is available. +\item Native mode, compilation ("\lstinline{-c}"). Compiles a source file into native code and writes an object file. All referenced + external unit interfaces must have to be accessible; however no linking is performed and no executable is built. +\item Native mode, build (default). Same as for the native compilation, but additionally performs linking with the runtime library and + all external units object files, generating executable. +\end{itemize} + +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 + 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}". +\item "\texttt{-v}"~--- makes the dirver to print the version of the compiler. +\item "\texttt{-h}"~--- makes the driver to print the helpon options. +\end{itemize} + +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. diff --git a/doc/spec/05.standard_library.tex b/doc/spec/06.standard_library.tex similarity index 100% rename from doc/spec/05.standard_library.tex rename to doc/spec/06.standard_library.tex diff --git a/doc/spec/Makefile b/doc/spec/Makefile new file mode 100644 index 000000000..daa39256e --- /dev/null +++ b/doc/spec/Makefile @@ -0,0 +1,7 @@ +all: + pdflatex spec.tex + bibtem spec + pdflatex.tex + +clean: + rm -Rf *~ *.log *.aux diff --git a/doc/spec/spec.tex b/doc/spec/spec.tex index 9275575ae..710bbd963 100644 --- a/doc/spec/spec.tex +++ b/doc/spec/spec.tex @@ -129,8 +129,9 @@ language=alm \input{01.introduction} \input{02.abstract_syntax_and_semantics} \input{03.concrete_syntax} -\input{04.driver_options} -\input{05.standard_library} +\input{04.extensions} +\input{05.driver_options} +\input{06.standard_library} \bibliographystyle{plainurl} \bibliography{spec}