Target Languages
Tools within the Jackson Workbench suite can generate code in various target
languages. This is achieved via a table-driven approach. For each language the
tool (for example the Structure Editor) has a table that contains the relevant
fragments necessary to implement the control structures for sequences, selections
and iterations, the prefixes and suffixes for boolean expressions, the delimiters
for comments ... etc.
For example when the Structure Editor is generating a non-inverted
loop, it looks in the table associated with the chosen target language for the
fragment that starts a loop. In 'C' this would be "while (" but in COBOL it
would be "PERFORM UNTIL". As another example, the fragment that starts a comment
in 'C' would be "/*", but in Delphi it would be "{".
You can choose the target language from the Code
Generation options page (selected from the Tools
menu in the Structure Editor). The available target languages may
be restricted depending on the version of the Structure Editor you have
purchased.
Note there are two special cases that are not implemented by the table driven
approach described above, these are JSP-Cobol and JSP Tool style COBOL. Instead
these cases use a specialised code generator that mimics the code generator
that was part of the relevant legacy tool. These are controlled from the JSP Tool
and JSP-Cobol options pages
respectively.
Invoking the Generator
To invoke code generation from the Structure Editor use the Tools
| Generate Code menu item. You will be prompted for the name of the output
file (via a file dialog box) and then the generated code will be written to it.
(Note: The Tools menu
also contains a 'Generate Code (for current structure)' item. This is only relevant
if you are dealing with a file format that can hold multiple structures - for
example JSP Tool.)
Correspondence of Source File Contents to Generated Code
Although the details differ with the target language and the source file format,
the basic mapping performed by the Structure Editor is like this:
- A single target language file will be generated which corresponds to the whole of the file being edited/viewed.
- The overall header from the source file will be placed at the top of the generated file.
- The overall trailer from the source will be placed at the bottom of the generated file.
- Between the overall header and overall trailer, the Structure Editor will place the following for each structure in the source file:
- The structure's header
- Code generated from the structure using the table-driven techniques mentioned above.
- The structure's trailer
In most languages the file corresponds to a 'module' of some kind, and each structure
corresponds to a 'routine'. The Structure Editor expects you to put appropriate
module/routine preludes/postludes in the headers and trailers.