mirror of
https://github.com/cqfn/eo.git
synced 2024-10-04 12:19:02 +03:00
#347 xmir section
This commit is contained in:
parent
43fd1893eb
commit
9de6eb4b26
@ -86,6 +86,10 @@ formalization of OOP.
|
||||
\label{sec:pragmatics}
|
||||
\input{sections/pragmatics}
|
||||
|
||||
\section{XMIR}
|
||||
\label{sec:xmir}
|
||||
\input{sections/xmir}
|
||||
|
||||
\section{Examples}
|
||||
\label{sec:examples}
|
||||
\input{sections/examples}
|
||||
|
@ -280,7 +280,8 @@ a special syntax for data, for example:
|
||||
r.mul 2 3.14 > circumference
|
||||
\end{ffcode}
|
||||
|
||||
This syntax would be translated to XML:
|
||||
This syntax would be translated to XMIR (XML based
|
||||
data format explained in Sec.~\ref{sec:xmir}):
|
||||
|
||||
\begin{ffcode}
|
||||
<o name="circle"> |$\label{ln:xml-circle}$|
|
||||
|
59
paper/sections/xmir.tex
Normal file
59
paper/sections/xmir.tex
Normal file
@ -0,0 +1,59 @@
|
||||
Consider this sample \eo{} snippet:
|
||||
|
||||
\begin{ffcode}
|
||||
[x y...] > app
|
||||
42 > n!
|
||||
[t] > read
|
||||
sub.
|
||||
n.neg
|
||||
t
|
||||
\end{ffcode}
|
||||
|
||||
It will be compiled to the following XMIR:
|
||||
|
||||
\begin{ffcode}
|
||||
<o line="1" name="app">
|
||||
<o line="1" name="x"/>
|
||||
<o line="1" name="y" vararg=""/>
|
||||
<o base="int" const="" data="int"
|
||||
line="2" name="n">42</o> |$\label{ln:xml-data}$|
|
||||
<o line="3" name="read">
|
||||
<o line="3" name="t"/>
|
||||
<o base=".sub" line="4">
|
||||
<o base="n" line="5"/> |$\label{ln:method-start}$|
|
||||
<o base=".neg" line="5" method=""/>
|
||||
<o base="t" line="6"/> |$\label{ln:method-end}$|
|
||||
</o>
|
||||
</o>
|
||||
</o>
|
||||
\end{ffcode}
|
||||
|
||||
Each object is translated to XML element \ff{<o>}, which has
|
||||
a number of optional attributes and a mandatory one: \ff{line}.
|
||||
The attribute \ff{line} always contains a number of the
|
||||
line where this object was seen in the source code.
|
||||
|
||||
The attribute \ff{name} contains the name of the object, if
|
||||
it was specified with the \ff{>} syntax construct.
|
||||
|
||||
The attribute \ff{base} contains the name of the object, which
|
||||
is being copied. If the name starts with a dot, this means
|
||||
that it refers to the first \ff{<o>} child.
|
||||
|
||||
The attribute \ff{method} may be temporarily present, suggesting
|
||||
further steps of XMIR transformations to modify the code
|
||||
at \lrefs{method-start}{method-end} to the following:
|
||||
|
||||
\begin{ffcode}
|
||||
<o base=".neg" line="5"/>
|
||||
<o base="n" line="5"/>
|
||||
<o base="t" line="6"/>
|
||||
</o>
|
||||
\end{ffcode}
|
||||
|
||||
The attribute \ff{data} is used when the object is data. In this
|
||||
case, the data itself is in the text of the object, as in~\lref{xml-data}.
|
||||
|
||||
The attribute \ff{vararg} denotes a vararg attribute.
|
||||
|
||||
The attribute \ff{const} denotes a constant.
|
Loading…
Reference in New Issue
Block a user