The sodg-maven-plugin builds a graph from an EO program.
SODG stands for Surging Object DiGraph. The primary consumer of SODG graphs is
the reo project. You can find some examples of .sodg files.
Then, start with a simple EO program in the order.eo file:
[qty price] > order
qty.mul > cost
price
That can be translated to the following XMIR:
<object>
<o name="order">
<o base="ξ" name="xi🌵"/>
<o base="∅" name="qty"/>
<o base="∅" name="price"/>
<o base="ξ.qty.mul" name="cost">
<o as="α0" base="ξ.price"/>
</o>
</o>
</object>Then, add this plugin to your pom.xml:
<plugin>
<groupId>org.eolang</groupId>
<artifactId>sodg-maven-plugin</artifactId>
<version>0.0.3</version>
<executions>
<execution>
<goals>
<goal>sodg</goal>
</goals>
</execution>
</executions>
</plugin>Or invoke it directly:
mvn org.eolang:sodg-maven-plugin:0.0.3:sodgYou should see order.sodg file being created under target/eo/sodg folder,
with the following content:
formation(b1, "xi🌵", "qty", "price", "cost")
dispatch(b2, b1, "xi🌵")
dispatch(b3, b1, "qty")
dispatch(b4, b1, "price")
dispatch(b5, b3, "mul")
application(b6, b5, α0, b4)
put(b1, "cost", b6)
To generate these text files, we first use an intermediate XML format:
<sodg>
<i name="formation">
<a>b1</a>
<a>xi🌵</a>
<a>qty</a>
<a>price</a>
<a>cost</a>
</i>
<i name="dispatch">
<a>b2</a>
<a>b1</a>
<a>xi🌵</a>
</i>
<i name="dispatch">
<a>b3</a>
<a>b1</a>
<a>qty</a>
</i>
<i name="dispatch">
<a>b4</a>
<a>b1</a>
<a>price</a>
</i>
<i name="dispatch">
<a>b5</a>
<a>b3</a>
<a>mul</a>
</i>
<i name="application">
<a>b6</a>
<a>b5</a>
<a>α0</a>
<a>b4</a>
</i>
<i name="put">
<a>b1</a>
<a>cost</a>
<a>b6</a>
</i>
</sodg>This DSL consists of these commands:
formation(o, attr0, attr1, ...)– creates a new formation objectdispatch(o, base, attr)– creates a new dispatch objectapplication(o, proto, attr, arg)– creates a new application objectdelta(o, data)– sets Δ-asset to the objectlambda(o, name)- sets λ-asset to the objectput(o, attr, kid)– sets attribute of the object
The sodg-maven-plugin performs the following steps:
- Turns
.xmirinto intermediate XML - Turns XML into a
.dotgraph (renderable by GraphViz) - Turns XML into
.sodgtext file (with DSL) - Turns XML into
.xe(Xembly) file that, if executed, would generate a graph in XML - Turns XML into
.graph.xml, which is a graph as XML
The .sodg file is essentially a sequence of instructions for a virtual machine
that parses them. An example of such a machine can be found in the SODG repo.
When the graph is built by the virtual machine, it must be possible to execute
a program using graph traversing algorithm. Once the graph is built, it can be
used to execute a program via a graph traversal algorithm. An example of such
an executor is reo.
You can configure the plugin goal's behavior using <configuration/>. The most
important parameters are:
scope- current object scope, default:compile.generateSodgXmlFiles- shall we generate.sodg.xmlfiles with SODGs?generateXemblyFiles- shall we generate.xefiles with Xembly instructions graph?generateGraphFiles- shall we generate.graph.xmlfiles with XML graph?generateDotFiles- shall we generate.dotfiles with DOT language graph commands?sodgIncludes- object names to participate in SODG generation, in the glob format, default:**.sodgExcludes- object names to be excluded from SODG generation, in the glob format.failOnXmirErrors- shall we fail SODG generation if XMIRs contain errors?
For failOnXmirErrors default value is true. It means that, if .xmir
contains /object/errors, then SODG generation will be failed:
<object>
...
<errors>
<error check="validate-object-name" severity="critical">...</error>
</errors>
</object>If failOnXmirErrors set to false, then even .xmir contains
/object/errors, the plugin will try to convert it to SODG.
Fork repository, make changes, then send us
a pull request.
We will review your changes and apply them to the master branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:
mvn clean install -PquliceYou will need Maven 3.3+ and Java 11+ installed.