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.
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.
$ 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
$ 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