Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Salesforce by (11.9k points)

I'm looking into the feasibility of writing a code formatting tool for the Apex language, a variation on Java, and perhams VisualForce, its tag based markup language.

I have no idea on where to start this, apart from feeling/knowing that writing a language parser from scratch is probably not the best approach.

I have a fairly thin grasp of what Antlr is and what it does, but conceptually, I'm imagining one could 'train' antlr to understand the syntax of Apex. I could then get a structured version of the code in a data structure (AST?) which I could then walk to produce correctly formatted code.

Is this the right concept? Is Antlr a tool to do that? Any links to a brief synopsis on this? I'm looking for investing a few days in this task, not months, and I'm not sure if its even vaguely achievable.

1 Answer

0 votes
by (32.1k points)
edited by

You can use Eclipse’s JDT as Apex syntax is similar to Java. You can edit the Java grammar to match it with Apex. You can go ahead and do the same with formatting options/rules. But, this will actually take you a few more days than a week.

Are you interested in learning Salesforce from scratch! Have a look at this interesting video on Salesforce provided by Intellipaat:

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories