The precompiler Jass translates a .jass file to a
.java. This file can be compiled with a Java
compiler in byte code. The compiler javac from Sun included in JDK 1.2 is reference. The Jass
precompiler is used from commandline like javac.
The following grammar rules specify the commandline.
| Start | ::= | ( ( CompileOptions )? ( GeneralOptions )* (<FILENAME>)+ ) <EOF> |
| CompileOptions | ::= | ( ( "-contract" | "-warning" ) ( CompileControls )? ) |
| | | "-nothing" | |
| | | "-interference" | |
| CompileControls | ::= | "[" ( "pre" | "post" | "inv" | "loop" | "check" | "forall" | "refine" | "trace" | "opt" )* "]" |
| GeneralOptions | ::= | "-depend" |
| | | "-nodepend" | |
| | | "-quiet" | |
| | | "-normal" | |
| | | "-verbose" | |
| | | "-dataflow" | |
| | | "-nodataflow" | |
| | | "-source" <FLOATING_POINT_LITERAL> | |
| | | "-d" <FILENAME> | |
| | | "-help" | |
| | | "-version" |
Start is the start symbol of the grammar and Filename a platform specific file name of the class to compile.
The options divide in two groups. Options for the [#translation]translation, called compile options, and [#general]general options. Some compile options may be annotated with a list of [#commands]control commands, called compile controls, that specify the code to generate.
There are three different translation modes and a special mode for
interference checks. The modes contract,
warning and nothing translate a
.jass file to a Java file. The modes will be explained
below.
rescue construct has no
function in this mode.main method. After an analysis Jass displays the
results of the check. This is the information if an interference is
possible and which control flow interferes with which assertion.
A list of compile controls defines which assertions should be translated, if an refinement should be taken in account and if optimization should be done.
The usage of the compile control list is optional. All controls except the command opt are used by default. The multiple use of controls has no special effects.
Versions 2.0.6 and 2.0.7 of Jass have a bug in parsing the compile control list. These version will only use the first control. The others are ignored!
With the general options the basic behaviour of the precompiler is determined.
.java suffix instead of .jass
suffix for your source code files.-source 1.4 jass.util.doc.JassDocIf contrary options (e.g. quiet and verbose) are used the last one has priority.
The following example demonstrates the simplest invocation of the precompiler (from the Jass main directory):
java jass.Jass jass/examples/Buffer.jass
This produces a file Buffer.java with can be compiled
through:
javac examples\Buffer.jass
With the commandline
java jass.Jass -warning jass/examples/Buffer.jass
Jass generates a Java file that produces an error message not an exception when an assertion is violated.
The compilation modes contract and warning can be annotated with compilation controls. The compilation controls decide which kind of assertions are handled and if optimizations should be done. The commandline
java jass.Jass -contract[pre,post,forall]
jass/examples/Buffer.jass
produces an output that contains only code for pre- and postcondition checks. The forall and exists expressions are checked trough loops. If the forall control is dropped this expressions are assumed to be true.