Package org.ek9lang.compiler.directives


package org.ek9lang.compiler.directives

The directives are really aimed at helping the creation of the EK9 language, but they maybe very useful in the early stages of adoption of EK9 (should there be any).

Because they enable an EK9 developer to send the EK9 compiler developers (me) an example of code that is broken.

The example below shows that the type for 'value' is an integer at declaration, but later in the code an attempt is made to assign a float value to it. The 'at' Error is this directive that looks for this error to ensue it it present.

The 'FULL_RESOLUTION' is the 'phase' of compilation this error was detected in, and the 'INCOMPATIBLE_TYPES' is the error enumeration from 'ErrorListener.SemanticClassification'.

 #!ek9
 defines module bad.assignment.check
   defines program

     badAssignment()
       value as Integer: 1

       //As it is an Integer, you cannot assign a Float to it.
       @Error: FULL_RESOLUTION: INCOMPATIBLE_TYPES
       value := 7.0
       assert value?

  //EOF
 

This mechanism is used widely in development, to ensure that correct code does not emit errors, but importantly incorrect code does emit errors (and the right sort of errors in the right phase of compilation).

  • Class
    Description
    To be used in EK9 source code to assert that a specific class or function has a particular level of complexity.
    Checks if there are any directives that relate to complexity in the parsed module.
    Provides basic interface for the EK9 internal @ type directives.
    Provides the listeners for directive checks.
    Extracts the compilation phase or throws an illegal argument exception.
    Finds the next line number from where a directive has been used.
    Specification of a directive, all the common details used in a range of directives.
    Extracts the 'spec' from the free format data in the directive.
    Extracts the symbol category or throws an illegal argument exception.
    Extracts the symbol name or throws an illegal argument exception.
    To be used in EK9 source code, for things like internal tests or compiler directives, instrumentation, reified type retention etc.
    To be used in EK9 source code to assert that an error will be created.
    Checks if there are any directives that relate to errors in the parsed module and tallies those up with any errors held for the phase of compilation.
    To be used in EK9 source code to assert that a type can or cannot be resolved.
    Checks if there are any directives that relate to @Genus in the parsed module and checks the resolution through the symbol and its genus.
    To be used in EK9 source code to assert that a type can or cannot be resolved as extending a type or function.
    Checks if there are any directives that relate to @Implements in the parsed module and checks the resolution through the symbol and its hierarchy.
    To be used in EK9 source code to assert that a type can or cannot be resolved.
    Checks if there are any directives that relate to @Resolved in the parsed module and checks the non-resolution.
    To be used in EK9 source code to assert that a type can or cannot be resolved.
    Checks for resolutions directives.
    To be used in EK9 source code to assert that a type can or cannot be resolved.
    Checks if there are any directives that relate to @Resolved in the parsed module and checks the resolution.