# Java Tools

The Java Tools matrix is a two-dimensional program cube that is used to synthesize most of the Jak tools in AHEAD. The vertical axis is the Java Feature Model (which has derivatives), and the horizontal axis is the tool feature model.

Rows of each matrix are language features {java, ast, gscope} and columns are tools { parser, jak2java, jampack, ... }. The exception is the grammar column. This column contains only grammar files which are composed to produce a single composite grammar. From this grammar, the build/java/syntax layer is generated, along with the parser for this grammar. As the build/java/syntax layer and parser are shared across all tools, it's represented by a separate column parser. (In effect, the grammar column derives the parser column).

# Java Matrix

| grammar | parser | support | sort | jak2java | jampack | mixin | mmatrix | unmixin | bcjak2java | jrename | antderive | antcompose
java | dsl/java/JavaGram | dsl/kernel build/java/syntax dsl/java/Java | dsl/java/Comments dsl/java/StringAST | dsl/java/sortfd |  |  |  | dsl/java/linenum |  |  |  |  |
ast | dsl/java/AstGram |  |  |  | dsl/java/ast |  |  |  |  | dsl/java/ast | dsl/java/astError |  |
gscope | dsl/java/GscopeGram |  |  |  | dsl/java/gscope | dsl/java/preprocessGscope |  | dsl/java/mmGscope |  | dsl/java/gscope | dsl/java/gscopeError |  |
base | dsl/java/AheadGram |  |  |  | dsl/java/j2jBase | dsl/java/CommonBase dsl/java/CommonError dsl/java/preprocess | dsl/java/CommonBase dsl/java/CommonError dsl/java/mixinbase | dsl/java/Basemm | dsl/java/unmixinbase | dsl/java/bcAhead | dsl/java/jrenBase |  |
d(base)/d(ast) |  |  |  |  | dsl/java/j2jast | dsl/java/CommonErrorAst | dsl/java/CommonErrorAst | dsl/java/mmAst | dsl/java/unmixinbaseAst |  |  |  |
source | dsl/java/SourceGram |  |  |  |  | dsl/java/SourceError |  | dsl/java/SourceMM |  |  | dsl/java/SourceError |  |
local-id | dsl/java/LocalIdGram |  |  |  | dsl/java/LocalIdError | dsl/java/LocalId | dsl/java/LocalId |  |  | dsl/java/LocalIdError | dsl/java/LocalIdError |  |
d(local-id) /d(ast) |  |  |  |  |  | dsl/java/LocalIdAst | dsl/java/LocalIdAst |  |  |  |  |  |
layer | dsl/java/LayerGram |  |  |  | dsl/java/AspectTrans | dsl/java/AspectDecl | dsl/java/AspectDecl |  |  | dsl/java/bcLayer | dsl/java/layerError |  |
sm | dsl/java/SmGram |  |  |  | dsl/java/sm5 |  |  |  |  | dsl/java/sm5 dsl/java/bcsm5 | dsl/java/smError |  |
compose-class | dsl/java/ClassXGram |  |  |  | dsl/java/j2jClassx | dsl/java/CompClass | dsl/java/mixinClass | dsl/java/Classmm | dsl/java/unmixinclass | dsl/java/bcClassx | dsl/java/ClassxError |  |
d(compose-class)/d(ast) |  |  |  |  |  | dsl/java/CompClassAst |  |  |  |  |  |  |
compose-int | dsl/java/IntXGram |  |  |  | dsl/java/j2jIntx | dsl/java/CompInt | dsl/java/mixinInt | dsl/java/Intmm | dsl/java/unmixinint | dsl/java/bcIntx | dsl/java/IntxError |  |
compose-sm | dsl/java/SmXGram |  |  |  | dsl/java/j2jSmx | dsl/java/CompSm | dsl/java/mixinSm | dsl/java/Sm2mm | dsl/java/unmixinsm | dsl/java/bcSmx | dsl/java/SmxError |  |
ant |  |  |  |  |  |  |  |  |  |  |  | dsl/support/antDerive | dsl/support/antCompose

# Synthesizing Tools

A tool is synthesized by specifying 3 equations, one per dimension. As it turns out, two of the dimensions of this matrix are identical. That is, the dimensions of this matrix are language x tools x language. So only 2 equations are needed to specify any particular tool.

Only 3 language equations are currently supported:

1. all = java AST BASE sm COMPOSE compose-sm ant
2. cat = java BASE sm COMPOSE compose-sm ant
3. utcs = java AST BASE COMPOSE ant

where AST, BASE, and COMPOSE are local variables:

- AST = ast gscope
- BASE = base d(base)/d(ast) source local-id d(local-id)/d(ast) layer
- COMPOSE = compose-class d(compose-class)/d(ast) compose-int

The default language is "all".

Seven tools are currently being built. Their equations are:

1. jak2javaTool = parser support sort jak2java antderive
2. jampackTool = parser support sort jampack antcompose
3. mixinTool = parser support mixin antcompose
4. mmatrixTool = parser mmatrix antderive
5. unmixinTool = parser support unmixin antderive
6. bcjak2javaTool = parser support sort bcjak2java antderive
7. jrenameTool = parser support jrename antderive

To see the fully expanded equations, look in fop/ahead/build/java/tools.equations.