Contents | Prev | Next | Index


Compiler Directives

Canterbury Pascal for JVM recognizes certain compiler directives inside source file comments.Their active scope is inside the current module only. In some cases they only apply to the succeeding language construct.

The following directives are for conditional compilation:

comment      ::= (*@IF boolean_expr *)
             ::= (*@IFDEF <identifier> *)
             ::= (*@IFNDEF <identifier> *)
             ::= (*@ELSE *)
             ::= (*@ENDIF *)
boolean_expr ::= <identifier>
             ::= not <identifier>
not          ::= NOT
             ::= ~

There are a number of Java directives which are only recognized at certain places inside the source module, see language grammar for more information.

java_foreign   ::= (*@JAVA FOREIGN *)
java_package   ::= (*@JAVA PACKAGE <string> *)
java_throws    ::= (*@JAVA THROWS exception_list *)
exception_list ::= exception_list , <identifier>
               ::= <identifier>
java_name      ::= (*@JAVA NAME <string> *)
java_modifiers ::= (*@JAVA modifier_list *)
modifier_list  ::= modifier_list modifier
               ::= modifier
modifier       ::= PUBLIC
               ::= PROTECTED
               ::= PRIVATE
               ::= ABSTRACT
               ::= STATIC
               ::= FINAL
               ::= TRANSIENT
               ::= VOLATILE
               ::= SYNCHRONIZED
               ::= NATIVE
               ::= INTERFACE
               ::= CONSTRUCTOR

The JAVA FOREIGN directive is only recognized at the beginning of a definition module and tells the compiler that the module only contains type and method declarations for foreign Java classes. In most cases there is no need for explicitly writing interfacing modules for foreign Java classes. Instead they should be directly imported.

The JAVA THROWS directive can only appear after a procedure heading or procedure type heading. It tells the compiler what Java exceptions the procedure might throw. Modula-2 procedures always catch all exceptions, hence there is no need for using this directive. It is mainly there for describing method procedures in foreign definition modules. Foreign definition modules in turn are hardly ever needed because foreign Java classes can also be directly imported.

The JAVA NAME directive tells the compiler what Java name to use for the generated output file, if that one is to be different from the Modula-2 identifier.

The JAVA modifiers directive lets the programmer define certain Java attributes for records, fields, and procedures.

The JAVA PACKAGE directive is only accepted immediately after the module header. It specifies a Java package name. E.g. if the package name is "test.mystuff", then the output path for the Java and class files is the CLASSPATH-relative subdirectory "test\mystuff". See under environment variables for more information about the CLASSPATH.

Finally, there are a number of compiler pragmas controlling the behavior of the compilation. They are defined as follows and can appear anywhere in a source module. There are only valid inside the current module. Otherwise they have the same meaning as their corresponding global counterparts from the command line switches. Some of them can be followed by a "+" or "-" sign indicating that the pragma is to be turned "on" or "off".

comment     ::= (* @ pragma_list other_tokens *)
pragma_list ::= pragma_list , pragma
            ::= pragma
pragma      ::= XF+
            ::= XF-
            ::= XL+

            ::= XL-
            ::= XT+

            ::= XT-
            ::= D+
            ::= D-
            ::= JDB+
            ::= JDB-
            ::= W0
            ::= W1
            ::= R4
            ::= R8

The following pragma is compatible with Borland Object Pascal:

comment     ::= (* $ pragma_list other_tokens *)
pragma_list ::= pragma_list , pragma
            ::= pragma
pragma      ::= I+
            ::= I-

Above mentioned pragma turns runtime I/O checking on or off, see standard function IOResult for more information. All other comment embedded pragmas as defined in Borland Object Pascal are also accepted by this compiler, but they have no meaning with Canterbury Pascal.


Contents | Prev | Next | Index

Canterbury Pascal for JVM  (Last documentation update Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com  . All rights reserved.
Please send any comments or corrections to neuhoff@mhccorp.com