UML Object Constraint Language (OCL) ANTLR Grammar

The Object Constraint Language (OCL) is a language for expressing constraints over objects. It was developed as part of the UML standard to define the semantics of the UML model. For more information please refer to http://www.klasse.nl/ocl/.

This page provides an OCL grammar for the ANTLR parser generator (Java).

Note: for a complete solution (including semantic analysis and evaluation) you may want to consider the Dresden OCL project.

License

Copyright © 2001 Alexander V. Konstantinou (akonstan@acm.org)

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Alexander V. Konstantinou makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

Download

Usage

  1. Unarchive

  2. Edit the Makefile and set the ANTLR_DIR to your ANTLR installation directory

  3. Compile using make (or type in compilation commands)
    $ make all
    java -classpath /usr/local/packages/antlr/2.7.1 antlr.Tool ocl.g
    ANTLR Parser Generator   Version 2.7.1   1989-2000 jGuru.com
    javac  -classpath /usr/local/packages/antlr/2.7.1:. *.java
    
    
  4. Test the parser agaist three sample OCL files (if no errors are reported then the parser build was successful)
    $ make test
    java -classpath /usr/local/packages/antlr/2.7.1:. Test inv1.ocl
    java -classpath /usr/local/packages/antlr/2.7.1:. Test inv2.ocl
    java -classpath /usr/local/packages/antlr/2.7.1:. Test oclbook.ocl
    


Please address all questions/comments to akonstan@acm.org