mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Fixed docs
This commit is contained in:
parent
bad97b4d6f
commit
eff25f1cf4
1 changed files with 7 additions and 7 deletions
14
doc/05.tex
14
doc/05.tex
|
|
@ -121,7 +121,7 @@ Procedures are unit-returning functions. We consider adding procedures as a sepa
|
||||||
essential redefinition of the semantics for expressions; at the same time the code generation for funictions is a little trickier, than for procedures, so
|
essential redefinition of the semantics for expressions; at the same time the code generation for funictions is a little trickier, than for procedures, so
|
||||||
it is reasonable to split the implementation in two steps.
|
it is reasonable to split the implementation in two steps.
|
||||||
|
|
||||||
At the source level the procedures are added as a separate syntactic category~--- definition $\mathscr D$:
|
At the source level procedures are added as a separate syntactic category~--- definition $\mathscr D$:
|
||||||
|
|
||||||
\[
|
\[
|
||||||
\begin{array}{rcl}
|
\begin{array}{rcl}
|
||||||
|
|
@ -130,7 +130,7 @@ At the source level the procedures are added as a separate syntactic category~--
|
||||||
\end{array}
|
\end{array}
|
||||||
\]
|
\]
|
||||||
|
|
||||||
In other words, a definition is a (possibly empty) sequence of procedure description. Each description consists of the a name of the procedure, a
|
In other words, a definition is a (possibly empty) sequence of procedure descriptions. Each description consists of a name for the procedure, a
|
||||||
list of names for its arguments and local variables, and a body (statement). In concrete syntax a single definition looks like
|
list of names for its arguments and local variables, and a body (statement). In concrete syntax a single definition looks like
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
|
|
@ -140,7 +140,7 @@ list of names for its arguments and local variables, and a body (statement). In
|
||||||
}
|
}
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
where $name$~--- a name for a procedure, $a_i$~--- its arguments, $l_i$~--- local variables, $s$~--- body.
|
where $name$~--- a name for the procedure, $a_i$~--- its arguments, $l_i$~--- local variables, $s$~--- body.
|
||||||
|
|
||||||
We also need to add a call statement to the language:
|
We also need to add a call statement to the language:
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ Finally, we have to redefine the syntax category for programs at the top level:
|
||||||
\mathscr L = \mathscr D\mathscr S
|
\mathscr L = \mathscr D\mathscr S
|
||||||
\]
|
\]
|
||||||
|
|
||||||
In other words, we extended a statement with a set of definitions.
|
In other words, we extend a statement with a set of definitions.
|
||||||
|
|
||||||
With procedures, we need to introduce the notion of \emph{scope}. When a procedure is called, its arguments
|
With procedures, we need to introduce the notion of \emph{scope}. When a procedure is called, its arguments
|
||||||
are associated with actual parameter values. A procedure is also in ``posession'' of its local variables.
|
are associated with actual parameter values. A procedure is also in ``posession'' of its local variables.
|
||||||
|
|
@ -216,8 +216,8 @@ Finally, we need two transformations for states:
|
||||||
\end{array}
|
\end{array}
|
||||||
\]
|
\]
|
||||||
|
|
||||||
The first one simlulates the entering the new scope with a set of local variables $S$; the second one simulates the leaving
|
The first one simlulates entering the new scope with a set of local variables $S$; the second one simulates leaving
|
||||||
from inner scope (described by the first state) to outer one (described by the second).
|
from an inner scope (described by the first state) to an outer one (described by the second).
|
||||||
|
|
||||||
\setarrow{\xRightarrow}
|
\setarrow{\xRightarrow}
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ In order to support procedures and calls, we enrich the stack machine with three
|
||||||
\]
|
\]
|
||||||
|
|
||||||
Informally speaking, instruction \llang{BEGIN} performs entering into the scope of a procedure; its operands are the lists of argument names and
|
Informally speaking, instruction \llang{BEGIN} performs entering into the scope of a procedure; its operands are the lists of argument names and
|
||||||
local variables; \llang{END} leaves the scope and returns to the call site, and \llang{CALL} performs the call.
|
local variables; \llang{END} leaves the scope and returns to the call site, and \llang{CALL} performs the call itself.
|
||||||
|
|
||||||
We need to enrich the configurations for the stack machine as well:
|
We need to enrich the configurations for the stack machine as well:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue