# Java Tools

The Java Tools matrix is a three-dimensional origami matrix that is used to synthesize most of the Jak tools in AHEAD. The way to understand it is by looking at the AHEAD logo, which is a vertical plane (matrix) with a horizontal plan (matrix) perpendicular to it. The vertical plane is the Java Matrix, the horizontal plane is the AST-Language Matrix. Where they join is at the ast row (in purple).

> Note: in the ast row of the Java Matrix, you'll see names like ast-jak2java, ast-jampack, etc. When the AST-Language matrix is folded by rows, an equation is defined for each of the columns. The names of these columns are ast-jak2java, ast-jampack, etc. These equations are substituted into the ast row of the Java matrix.

Rows of each matrix are language features {core, lang, java, ...} 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 | jak2java | jampack | mixin | mmatrix | unmixin | bcjak2java | jrename
lang |  | dsl/kernel build/java/syntax | dsl/java/Java dsl/java/Comments dsl/java/StringAST | dsl/java/Java dsl/java/Comments dsl/java/StringAST | dsl/java/Java dsl/java/Comments dsl/java/StringAST |  | dsl/java/Java dsl/java/Comments dsl/java/StringAST | dsl/java/Java dsl/java/Comments dsl/java/StringAST | dsl/java/Java dsl/java/Comments dsl/java/StringAST
java | dsl/java/JavaGram |  | dsl/java/sortfd | dsl/java/sortfd |  | dsl/java/Java dsl/java/linenum |  | dsl/java/sortfd |
ast | dsl/java/AstGram |  | ast-jak2java | ast-jampack | ast-mixin | ast-mmatrix | ast-unmixin | ast-bcjak2java | ast-jrename
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
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
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
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 | dsl/support/antCompose | dsl/support/antDerive | dsl/support/antDerive | dsl/support/antDerive | dsl/support/antDerive

# AST-Language Interaction Matrix

| ast-grammar | ast-parser | ast-jak2java | ast-jampack | ast-mixin | ast-mmatrix | ast-unmixin | ast-bcjak2java | ast-jrename
core |  |  |  |  |  |  |  |  |
lang |  |  |  |  |  |  |  |  |
java |  |  |  |  |  |  |  |  |
ast |  |  | dsl/java/ast |  |  |  |  | dsl/java/ast | dsl/java/astError
gscope |  |  |  |  |  |  |  |  |
base |  |  | dsl/java/j2jast | dsl/java/CommonErrorAst | dsl/java/CommonErrorAst | dsl/java/mmAst | dsl/java/unmixinbaseAst |  |
source |  |  |  |  |  |  |  |  |
local-id |  |  |  | dsl/java/LocalIdAst | dsl/java/LocalIdAst |  |  |  |
layer |  |  |  |  |  |  |  |  |
sm |  |  |  |  |  |  |  |  |
compose-class |  |  |  | dsl/java/CompClassAst |  |  |  |  |
compose-int |  |  |  |  |  |  |  |  |
compose-sm |  |  |  |  |  |  |  |  |
ant |  |  |  |  |  |  |  |  |

# 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 source local-id layer
- COMPOSE = compose-class compose-int

The default language is "all".

Seven tools are currently being built. Their equations are:

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

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