Development:Creating a new plugin

From Tom

Jump to: navigation, search
Dev : Developping

Writing JUnit tests  > Writing an Ant task  > Creating a new plugin  > Messages and exceptions : Using the logger  > PIL language  > Description of ADT  > Description of external libraries  > New parser's architecture

TEMPORARY PAGE - work in progress : description of INPUT/OUTPUT will come

Contents

PluginPlatform

The platform is a tool which allows us to manage each step in the compilation process. Each step in Tom or Gom compilation process is implemented by a plugin which inherits from TomGenericPlugin or GomGenericPlugin. Both of them implements the Plugin interface of the platform package.

Tom compilation process

Here are all the plugins that compose Tom engine (in the order), as shown below :



Tom Starter

The TomStarter plugin is only here to initialize the TomStreamManager and to initalize the plugin platform set/getargs process with it.

INPUT : Tom file name

OUTPUT : the initialized TomStreamManager


Tom Parser

The parser plugin parses the input file and creates the corresponding TomTerm.

INPUT : TomStreamManager

OUTPUT : TomTerm and TomStreamManager


Tom Syntax Checker

The syntax checker plugin checks that the generated term has a correct syntax.

INPUT : TomTerm

OUTPUT : TomTerm


Tom Typer

The typer plugin performs the expansion for Tom syntax.

INPUT : TomTerm

OUTPUT : TomTerm


Tom Type Checker

The type checker plugin checks the previous performed expansion.

INPUT : TomTerm

OUTPUT : TomTerm


Tom Expander

The expander plugin expands the term.

INPUT : TomTerm

OUTPUT : TomTerm


Tom Compiler

The compiler plugin transforms the term which has been checked before. It propagates constraints generates instruction from constraints.

INPUT : TomTerm

OUTPUT : TomTerm


Tom Optimizer

TODO

INPUT : TomTerm

OUTPUT : TomTerm


Tom Verifier

TODO

INPUT : TomTerm

OUTPUT : TomTerm


Tom Backend

The Tom backend plugin creates the generator depending on OptionManager, the output writer and generates the output code.

INPUT : Tomterm

OUTPUT : generated code (typically .java files)


Gom compilation process

Here are all the plugins that compose Gom (in the order), as shown below :

Gom Starter

The Starter "plugin" is only here to initialize the GomStreamManager and to initalize the plugin platform set/getargs process with it.

INPUT : Gom file

OUTPUT : GomEnvironment (GomStreamManager + SymbolTable)


Gom Parser

The Gom parser plugin retrieve the input Gom file and parses it.

INPUT : GomEnvironment

OUTPUT : GomModule, GomEnvironment


Gom Expander

The expander plugin parses the Gom files included by the module to be compiled and populates the GomEnvironment.

INPUT : GomModule, GomEnvironment

OUTPUT : GomModuleList, GomEnvironment


Gom Fresh Expander

The fresh expander plugin parses the Gom files included by the module to be compiled and populate the GomEnvironment.

INPUT : GomModuleList, GomEnvironment

OUTPUT : GomModuleList, GomEnvironment


Gom Type Expander

The type expander plugin produces an abstract view of the Gom input with type information. INPUT : ModuleList, GomEnvironment

OUTPUT : typedModuleList, typedHookList, GomEnvironment


Gom Graph Expander

INPUT : ModuleList, HookDecList, GomEnvironment

OUTPUT : referencedModuleList, referencedHookList, GomEnvironment


Gom Compiler

The compiler plugin translates the algebraic specifications into a set of classes.

INPUT : ModuleList, HookDecList, GomEnvironment

OUTPUT : GomClassList, GomEnvironment


Gom Backend

The BackendPlugin handles the code generation.

INPUT : GomClassList, GomEnvironment

OUTPUT : generated output files


Creating a new plugin

Mandatory methods

TomGenericPlugin (tom.engine.tools package) and GomGenericPlugin (tom.gom.tools package) are implementing the Plugin interface (tom.platform package). When creating a new Tom/Gom plugin, it is necessary to extend from one of them. Because of the fact they are abstract classes, few methods have to be implemented as described below :

Tom :

public abstract void run(Map informationTracker);
 
//setArgs(arg) and getArgs() method are not abstract and have already been defined in the class

Gom :

public abstract void setArgs(Object[] arg); //arg is the input object of the plugin
 
public abstract void run(Map informationTracker);
 
public abstract Object[] getArgs(); //returns the output object of the plugin

Configuration files

In order to be used in the compilation process, it is necessary to add it in the plugins section of the configuration file, as shown below :

src/config/Tom.xml :

<plugins>
...
    <plugin name="NameOfTheNewPlugin"
      class="tom.engine.packagepluginname.TomNameOfTheNewPlugin"/>
...
</plugins>

src/config/Gom.xml :

<plugins>
...
    <plugin name="NameOfTheNewPlugin"
      class="tom.engine.packagepluginname.GomNameOfTheNewPlugin"/>
...
<plugins>

Be careful, the order in the configuration file is important : it gives the order of plugin calls in the compilation process.

Developping

Writing JUnit tests  > Writing an Ant task  > Creating a new plugin  > Messages and exceptions : Using the logger  > PIL language  > Description of ADT  > Description of external libraries  > New parser's architecture

Development corner
Developping Tom Compiler :: Creating a Tom release
Personal tools
Create a book