Note: This website is archived. For up-to-date information about D projects and development, please visit

The software design of TioPort

TioPort contains two programs. A Java to XML converter and a XML to D converter.

Parsing Java

The parser is a java program with a AntLR parser. The used Java grammar is public domain grammar from Michael Studman. This makes the java parser very easy. A small main program around the generated parsers and write the XML. Java parsing complete in shortest time :)

Reading the XML

From now on, all happens in a D program. For reading the XML, a ported PULL Parser from is used.

After parsing a java file a data structure is built, which holds all data from the java file. Well not all, comments and all line informations are lost. To be able to resolve references, all envolved files should be loaded. Therefore, a configuration XML is also loaded. It contains the list of all files, which should be loaded.

The data in memory

While parsing the xml data, a object tree in memory is build. All data is help there. There are object for packages, modules, classes, interfaces, methods, ...

The visitor pattern is uses, to traverse the tree several times.

Resolving the references

Resolving is a process in multiple iterations.

  • Building a scope structure, containing all classes and interfaces.
  • Resolving base classes, base interface, outer classes.
  • Resolving all variable types, parameter types, replace every type information with a link to the type definition.

Applying refactorings

Now it is easy to make refactorings. If a type, field or method is renamed, simply rename it. All references link directly to it. So they follow the definition and read the name directly from it.

Writing the output

Traverse the complete tree, write all needed modules.