mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-24 15:48:47 +00:00
External/public, better options
This commit is contained in:
parent
5a883d8fa9
commit
1a849e7a56
12 changed files with 294 additions and 93 deletions
13
doc/spec/01.general_characteristic.tex
Normal file
13
doc/spec/01.general_characteristic.tex
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
\section{General Characteristic of the Language}
|
||||
|
||||
\begin{itemize}
|
||||
\item procedural with first-class functions~--- functions can be passed as arguments, placed in data structures,
|
||||
returned and constructed at runtime via closures mechanism;
|
||||
\item with lexical static scoping;
|
||||
\item strict~--- all arguments of function application are evaluated before function's body;
|
||||
\item imperative~--- variables can be re-assigned, function calls can have side effects;
|
||||
\item untyped~--- no static type checking is performed;
|
||||
\item supports S-expressions and pattern-matching;
|
||||
\item supports user-defined infix operators, including those defined in local scopes;
|
||||
\item with automatic memory management (garbage collection).
|
||||
\end{itemize}
|
||||
50
doc/spec/02.notation.tex
Normal file
50
doc/spec/02.notation.tex
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
\section{Notation}
|
||||
|
||||
Pairs and tuples:
|
||||
|
||||
\[
|
||||
\inbr{\bullet,\,\bullet,\,\dots}
|
||||
\]
|
||||
|
||||
Lists of elements of kind $X$:
|
||||
|
||||
\[
|
||||
X^*
|
||||
\]
|
||||
|
||||
Deconstructing lists into sublists:
|
||||
|
||||
\[
|
||||
h\circ t
|
||||
\]
|
||||
|
||||
This applies also to lists of length 1. Empty list is denoted
|
||||
|
||||
\[
|
||||
\epsilon
|
||||
\]
|
||||
|
||||
|
||||
For a mapping $f : X\to Y$ we use the following definition:
|
||||
|
||||
\[
|
||||
f [x\gets y] = \lambda\,z\,.\,
|
||||
\left\{
|
||||
\begin{array}{rcl}
|
||||
y &,& x = z \\
|
||||
f\;x &,& x\neq z
|
||||
\end{array}
|
||||
\right.
|
||||
\]
|
||||
|
||||
Empty mapping (undefined everywhere) is denoted $\Lambda$, the domain of a mapping $f$~--- $\dom{f}$, and we abbreviate
|
||||
|
||||
\[
|
||||
\Lambda[x_1\gets y_1][x_2\gets y_2]\dots[x_k\gets y_k]
|
||||
\]
|
||||
|
||||
as
|
||||
|
||||
\[
|
||||
[x_1\gets y_1,\,x_2\gets y_2,\,\dots,\,x_k\gets y_k]
|
||||
\]
|
||||
20
doc/spec/03.values.tex
Normal file
20
doc/spec/03.values.tex
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
\section{Names, Values and States}
|
||||
|
||||
\begin{table}[t]
|
||||
\begin{tabular}{cccl}
|
||||
denotation & instances & definition & comments \\
|
||||
\hline
|
||||
$\mathscr X$ & $x,\,y,\,z,\,\dots$ & & variables \\
|
||||
$\mathscr T$ & $\llang{C},\,\llang{D},\,\dots$ & & tags (constructors) \\
|
||||
$\Sigma$ & $\sigma$ & $\mathscr X\to\mathscr V$ & bindings (a partial map from variables to values) \\
|
||||
$\Sigma_{\mathscr X}$ & $\inbr{\sigma,\,S}$ & $2^{\mathscr X}\times\Sigma$ & local scope (a set of variable and bindings) \\
|
||||
$St$ & $\inbr{\sigma_g,\,ss}$ & $\Sigma\times\Sigma^*_{\mathscr X}$ & state (global bindings and a stack of local scopes) \\
|
||||
$\mathscr L$ & $l$ & & locations \\
|
||||
$M$ & $\mu$ & $\mathscr L\to\mathscr C$ & abstract memory (a partial map from locations to composite values) \\
|
||||
$\mathscr V$ & $v$ & $\mathbb Z\uplus \mathscr L$ & values (integer values or locations) \\
|
||||
$\mathscr C$ & & $Arr\uplus Sexp \uplus Clo$ & composite values (arrays, S-expressions or closures) \\
|
||||
$Arr$ & & $\mathbb N\times (\mathbb N\to\mathscr V)$ & arrays (length and element function) \\
|
||||
$Sexp$ & & $\mathscr T \times Arr$ & S-expressions (tag and array of subvalues) \\
|
||||
$Clo$ & & $\mathscr X \times \Sigma^*_{\mathscr X}$ & closures (function name and a stack of local scopes)
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
\usepackage{multirow,bigdelim}
|
||||
\usepackage{subcaption}
|
||||
\usepackage{placeins}
|
||||
\usepackage{xspace}
|
||||
|
||||
\makeatletter
|
||||
|
||||
|
|
@ -71,15 +72,12 @@
|
|||
\renewcommand{\emptyset}{\varnothing}
|
||||
\newcommand{\dom}[1]{\mathtt{dom}\;{#1}}
|
||||
\newcommand{\primi}[2]{\mathbf{#1}\;{#2}}
|
||||
|
||||
\newcommand{\sial}{S\textit{\lower -.5ex\hbox{I}\kern -.1667em\lower .5ex\hbox {A}}\kern -.125emL\@\xspace}
|
||||
\definecolor{light-gray}{gray}{0.90}
|
||||
\newcommand{\graybox}[1]{\colorbox{light-gray}{#1}}
|
||||
|
||||
\lstdefinelanguage{ocaml}{
|
||||
keywords={let, begin, end, in, match, type, and, fun,
|
||||
function, try, mod, with, class, object, method, of, rec, repeat, until,
|
||||
while, not, do, done, as, val, inherit, module, sig, @type, struct,
|
||||
if, then, else, open, virtual, new, fresh, skip, od, fi, elif, for, local, return, read, write, fi, case, esac, od},
|
||||
\lstdefinelanguage{sial}{
|
||||
keywords={fun, case, esac, do, od, if, then, else, elif, fi, skip, repeat, until, for, local},
|
||||
sensitive=true,
|
||||
%basicstyle=\small,
|
||||
commentstyle=\scriptsize\rmfamily,
|
||||
|
|
@ -88,7 +86,7 @@ identifierstyle=\ttfamily,
|
|||
basewidth={0.5em,0.5em},
|
||||
columns=fixed,
|
||||
fontadjust=true,
|
||||
literate={->}{{$\to$}}3 {===}{{$\equiv$}}1 {=/=}{{$\not\equiv$}}1 {|>}{{$\triangleright$}}3 {\&\&\&}{{$\wedge$}}2 {|||}{{$\vee$}}2 {^}{{$\uparrow$}}1,
|
||||
literate={->}{{$\to$}}3,
|
||||
morecomment=[s]{(*}{*)}
|
||||
}
|
||||
|
||||
|
|
@ -101,16 +99,12 @@ commentstyle=\scriptsize\rmfamily,
|
|||
basewidth={0.5em,0.5em},
|
||||
fontadjust=true,
|
||||
escapechar=!,
|
||||
language=ocaml
|
||||
language=sial
|
||||
}
|
||||
|
||||
\sloppy
|
||||
|
||||
\newcommand{\ocaml}{\texttt{OCaml}\xspace}
|
||||
|
||||
\theoremstyle{definition}
|
||||
|
||||
\title{Introduction to Programming Languages, Compilers and Tools}
|
||||
\title{\sial Language Definition}
|
||||
|
||||
\author{Dmitry Boulytchev}
|
||||
|
||||
|
|
@ -118,13 +112,8 @@ language=ocaml
|
|||
|
||||
\maketitle
|
||||
|
||||
\input{01}
|
||||
\input{02}
|
||||
\input{03}
|
||||
\input{04}
|
||||
\input{05}
|
||||
\input{06}
|
||||
\input{07}
|
||||
\input{08}
|
||||
\input{01.general_characteristic}
|
||||
\input{02.notation}
|
||||
\input{03.values}
|
||||
|
||||
\end{document}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue