While the Java code generator that is being implemented makes certain restrictions to the OCL constructs that can be used, the other compiler modules are implemented as close to the OCL specification of UML 1.3 as possible. The compiler is constructed of modules with separated responsibilities to allow easy reuse or replacement. The architecture is flexible enough to adapt the existing modules to a variety of purposes, such as code generation for other languages or OCL interpretation. The parser is built using the tool SableCC . The parser can be examined with the applet .
Semantic analysis consists of simple consistency checks and type checking.
Besides assuring the correctness of an OCL expression with reference to some source of model information, the type checker adds type information to some abstract syntax nodes and to variables. This information is available to other modules. The applet automatically type-checks any OCL expression that is parsed. This reduces code generator complexity. Instead of defining one OCL normal form, a set of normalization steps can be fitted together to generate a normal form specific to the desired target language.