After nearly a month of DIY OCL parsing I decided to throw it all away and start anew using SableCC 3.2. There is an OCL 1.5 grammar for SableCC 2.0, which did not work with version 3.2. After some tweaks I was able to get the grammar to work.
Switching to SableCC was a very good idea even tho the documentation on version 3.2 is scarce. The OCL parsing works well. SableCC generates a lot of Java classes which can be used to transform the generated concrete syntax tree (CST).
The only problem is that the generated CST is quite complex. SableCC 3.2 comes with the option to significantly reduce the size of the generated CST by specifying a mapping the the underlying abstract syntax tree. It seems like a good idea to update the grammar to work with an AST mapping as well, but I’m not quite sure if it fits into my bachelor thesis. As soon as I’m sure what to do, and how to do it, I’m going to publish the OCL grammar I’ve updated.
Cheers, Raphael