1
1
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:
Yegor Bugayenko 2021-09-24 20:09:44 +03:00
parent 43fd1893eb
commit 9de6eb4b26
No known key found for this signature in database
GPG Key ID: B8283801026E65F3
3 changed files with 65 additions and 1 deletions

View File

@ -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}

View File

@ -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
View 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.