Grammar for creating an Apex parser

Keep an eye on Apex tooling api, which is used in Developer console. This is supposed to be released to public access soon.


Although I already answered years ago I want to add some news. There is a wonderful Apex parser implementation as part of the Force.com IDE on GitHub. It's just a jar without source code but you can use it for whatever you want. And the developers behind it are really supportive and helpful.

We are currently building an Apex port of the famous Java static code analyzer PMD. And we use Salesforce.com interal parser. It works like a charm.

BTW: Daniel if you are interested to share your knowledge as an Salesforce.com expert and MVP I would love to show you how to contribute to our effort to bring Apex code metrics to the community.


There is now an official Apex Language syntax grammar released on GitHub.
forcedotcom/apex-tmLanguage

Salesforce Apex Language syntax grammar used for colorization

The token structure is based off of Textmate's Language Grammar guidelines

Tags:

Apex