Code Monkey home page Code Monkey logo

deog's Introduction

logo

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

License

Decoration graph of EO program

DEOG is a JVM API for building decoration graph of EO program.

DEOG takes a path to a collection of .xmir files and constructs a decoration graph, connecting all the EO objects. With this graph you can access the list of all the attributes present in an object in constant time.

Usage

Installation

Just add this to your pom.xml file

<dependency>
  <groupId>org.eolang</groupId>
  <artifactId>deog</artifactId>
  <version>0.0.3</version>
</dependency>

API

You can build a graph like this:

DeogLauncher.launchDeog(PATH_TO_XMIR_SOURCES, "postfix")

By default, DEOG will generate a new directory with a name ${PATH_TO_XMIR_SOURCES}_deog, but you can change the postfix with the postfix parameter.

launchDeog returns a DeogGraph object, which has a number of useful attributes, i.g. you can look at the set of nodes of a graph via deogGraph.dgNodes

Nodes are represented by DGraphNode object with parameters such as

  • name - EO object name
  • packageName - EO package name
  • attributes - representing eo attributes
  • children and parents in the graph
  • body - corresponding org.w3c.dom.Node

Each EO attribute is represented by DGraphAttr object with parameters such as

  • name - EO object name
  • parentDistance - distance in the decoration tree to the object in which the attribute was initially defined
  • body - corresponding org.w3c.dom.Node

Below you can see a usage example:

val graph = DeogLauncher.launchDeog(PATH_TO_XMIR_SOURCES, "deog")
graph.dgNodes.forEach { node ->          // traversing each node
    if (node.name?.startsWith("a")) {    // checking if node name starts with "a"
        node.attributes.forEach {        // traversing node attributes
            println(it.name)             // printlng out attribute name
        }
    }
}

AttributesUtil file provides a useful API for getting quick access to org.w3c.dom.Node objects' attributes.

For instance, this is how you would access the line attribute of EO object: line(node)
You also can find which abstract object the ref attribute points to like this:

findRef(
    node,                       // node, ref of which you want to find
    deogGraph.initialObjects,   // initial set of org.w3c.dom.Node objects
    deogGraph                   // graph
)

Graph overview:

Consider the following EO program.

[] > animal
  [] > live
    [] > eat
      stdout > @
        "Animal is eating"
    stdout > @
      "Animal is alive"
  [t] > talk
    live > @

[] > mouse
  animal > @
  [] > mouse_live
    ^.live > @

[] > cat
  animal > @
  [m] > meow
    ^.talk "Meow" > @

The resulting graph can be considered to look like below. Each node is represented by a rectangle. All the attributes of the node are listed in the rectangle.

deog's People

Contributors

olesiasub avatar renovate[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.