QQ on parser rules
GM Scott,
just a quick question, what is your parsing engine rules based on? from a few articles I see that a lot of people use PMD, just wondering so that I have a place to start when trying to author a ‘best practice’ doc. (theres not a good reason to re-invent the wheel there…)
Also, what are you using for Apex and if you know off the top of your head what Webstrom uses for JS?
ty so much!
Chris
Comments (7)
-
repo owner -
repo owner - changed status to resolved
Resolved as Q&A. Happy to answer other questions here if you have them, though.
-
reporter Followup,
would you have the ‘rules’ in a consumable format (or can I export/get it from Jetbrains/Webstorm?)
I am just trying to author something and don’t want to start at 0 and really want to align with the IC parsing engine.
-
reporter - changed status to open
see prior comment
-
repo owner No, the IC2 Apex parser is part of its implementation and is commercial/closed source. AFAIK there isn't really a published grammar for Apex out there, in part because it's not a language that lends itself to a grammar in isolation to frame its syntax. This was discussed recently on Twitter:
https://twitter.com/rsoesemann/status/1491743982262624258
Without knowing what you're trying to do and speaking as someone who has written and maintained an Apex parser and runtime expression type inference engine, I would strongly recommend that you try starting with the Salesforce jorje parser and the AST that it produces (just as PMD Apex does) and see whether that gives you what you need.
As for parsers for other languages such as JavaScript, there are plenty of them out there including V8, closure-compiler, etc. Again, without knowing what you're trying to do, it's difficult to know which might be a good fit.
-
reporter thanks Scott!
-
reporter - changed status to resolved
- Log in to comment
IC2 uses its own Apex/SOQL/SOSL parser (and another parser for Visualforce/Aura expression languages).
For what it's worth, PMD Apex uses the Salesforce jorje parser. WebStorm and other commercial JetBrains IDEs use a JavaScript parser created by JetBrains. That's generally going to be the case with JetBrains language support plugins, whether created by JetBrains or by others (e.g., IC2), though I think there are a few instances of folks adapting existing parsers to work with JetBrains plugins.
Regards, Scott Wells