Super Prev Next

Customizing the compiler


Super Prev Next

Customizing compiler messages

The file jc.msg contains texts of error messages in the form

    number text

The following is an extract from jc.msg:

001 illegal character
002 comment not closed; started at line %d
...
042 incompatible assignment
...

Some messages contain format specifiers for additional arguments. In the above example, the message 002 contains a %d specifier used to print a line number.

To use a language other than English for compiler messages it is sufficient to translate jc.msg, preserving error numbers and the order of format specifiers.


Super Prev Next

Error message format specification

The format in which JET reports errors is user configurable through the ERRFMT equation. Its syntax is as follows:

    { string "," [ argument ] ";" }

Any format specification allowed in the C procedure printf can be used in string.

Argument Type Meaning
line integer position in a source text
column integer position in a source text
file string name of a source file
module string class name
errmsg string message text
errno integer error code
mode string ERROR, FAULT, NOTICE, or WARNING
utility string name of an utility

Argument names are not case sensitive. By default, the error message format includes the following clauses:

"(%s",file; a file name
"%d",line; a line number
",%d",column; a column number
") [%.1s] ",mode; the first letter of an error mode
"%s\n",errmsg; an error message

If a warning is reported for the file test.mod at line 5, column 6, the generated error message will look like this:

    (test.mod 5,6) [W] variable declared but never used


Super Prev Next

Regular expression

The compiler recognizes filename patterns in the redirection file and LOOKUP directives. Though in most cases you would use patterns like *.class, they are actually treated like regular expressions:

Sequence Denotes
* an arbitrary sequence of any characters, possibly empty
  (equivalent to {\000-\377} expression)
? any single character
  (equivalent to [\000-\377] expression)
[...] one of the listed characters
{...} an arbitrary sequence of the listed characters, possibly empty
\nnn the ASCII character with octal code nnn, where n is [0-7]
& the logical AND
| the logical OR
^ the logical NOT
(...) the priority of operations

A sequence of the form a-b used within either [] or {} brackets denotes all characters from a to b.

Examples

project.*

files which name is project with an arbitrary extension
*.obj|*.sym|*.bod

matches any file with extension .obj, .sym or .bod
{a-z}*X.class

matches files starting with any sequence of lowercaseletters, ending in one final "X" and having the extension .class


Super Prev Next

Template files

A template file /In the most, it is efficient to use default template file (jc.tem)/ is used to build a "makefile" in the PROJECT operation mode.

The compiler copies lines from a template file into the output file verbatim, except lines marked with an exclamation mark (’!’)

A template file is also subject to preprocessing.

A marked line (or template) has the following format /The same syntax is used in the LINK equation./ :

    Template  = "!" { Sentence }.
    Sentence  = Item { "," Item } ";" | Iterator.
    Item      = Atom | [ Atom | "^" ] "#" [ Extension ].
    Atom      = String | EquationName.
    String    = '"' { character } '"'
              | "'" { character } "'".
    Extension = [ ">" ] Atom.
    Iterator  = "{" Set ":" { Sentence } "}".
    Set       = { Keyword | String }
    Keyword   = JAVA | CLASS | OBJ | MAIN.

EquationName is a name of a compiler or user-defined equation. Not more than three Items may be used in a Sentence. A first item in a sentence is a format string, while others are arguments.

The JET distribution contains a template file jc.tem which can be used to produce a linker response file.


Super Prev Next

Using equation values

In the simplest form, a template line may be used to output a value of an equation. For example, if the template file contains the line

     ! "The current project is %s.\n",prj;

and the project prj/test.prj is processed, the output will contain the line

    The current project is prj/test.prj.

Note: the line

    ! prj;

is valid, but may produce unexpected results under systems in which the backslash character ("\") is used as a directory names separator (e.g. Windows):

    prj     est.prj

because "\t" in a format string is replaced with the tab character. Use the following form instead:

    ! "%s",prj;


Super Prev Next

File name construction

The "#" operator constructs a file name from a name and an extension, each specified as an equation name or literal string. A file is then searched for using lookup paths and the resulting name is substituted. For example, if the file useful.lib resides in the directory ’../mylibs’ and the redirection file contains the following line:

    *.lib = /xds/lib;../mylibs

the line

    ! "useful"#"lib"

will produce

    ../mylibs/useful.lib

If the modifier ">" is specified, the compiler assumes that the file being constructed is an output file and creates its name according to the strategy for output files (See Redirection file).

The "#" operator is also used to represent the current value of an iterator. The form in which a name or extension is omitted can be used in an iterator only.

The form "^#" may be used in a second level iterator to represent the current value of the first level iterator.


Super Prev Next

Iterators

Iterators are used to generate some text for all modules from a given set. Sentences inside the first level of braces are repeated for all modules of the project, while sentences inside the second level are repeated for all modules imported into the module currently iterated at the first level. A set is a sequence of keywords and strings. Each string denotes a specific module, while a keyword denotes all modules of specific kind.

The meaning of keywords is as follows:

Keyword Meaning
CLASS bytecode file
JAVA Java source file
MAIN Java main class (Java bytecode or source file with public static void main (String[]) method.)
OBJ object file

A keyword not listed above is treated as filename extension. Sentences are repeated for all files with that extension which are explicitly specified in the project file using !module directives (see Project files). This allows, for instance, additional libraries to be specified in a project file:

sample.prj:

    -template = mytem.tem
    !module Sample.class
    !module mylib.lib

mytem.tem:
      .  .  .
    ! "%s","libxds"#"lib"
    ! { lib: "+%s",#; }
    ! "\n"
      .  .  .

Generated file:
      .  .  .
    d:\xds\lib\x86\libxds.lib+mylib.lib
      .  .  .


Super Prev Next

Examples

Consider a sample project which consists of a main class A, which uses classes B and C; and B, in turn, uses D (all modules are bytecode files):

                   A.class
                     / \
              B.class   C.class
                 |
              D.class

The following examples illustrate template files usage:

This template line lists all project modules for which bytecode files are available:

    ! { main class: "%s ",#; }

For the sample project, it would generate the following line:

    A.class B.class C.class D.class

To output main classes, the following line may be used:

    ! { main: "%s ",#; }

The output would be:

    A.class