mindpixel
mindpixel

Reputation: 15

Criteria for parser selection

lets say I have a language designed. What are the criteria to consider when it comes to selecting the "proper" parser/framework (javacc, antlr, spark, mps...), like performance, test generation, IDE support....

I know, "proper" depends on a lot of variables, but I am only interested in the list of criteria (I'll do weighting afterwards) upon which I could base and make my decision.

Thx for any input!

Upvotes: 0

Views: 134

Answers (2)

TomServo
TomServo

Reputation: 7409

LALR(1) parsers can be very fast because they can be based on pre-compiled tables, but one-character lookahead can limit your grammar. A great example is the GOLD Parser. With many engines to choose from, even though it's old, it is rather fast if you can describe your grammar using just BNF.

Upvotes: 0

Jiri Tousek
Jiri Tousek

Reputation: 12450

The most important input for such decision will likely be the complexity of the language. Different parser generators are able to process different classes of languages.

As your language will likely be a context-free language (otherwise you either can get away with a regex or you're up to quite a challenge), you'll usually be deciding between a LR parser (or some variant thereof) and LL parser. As a (simplified!) rule of thumb, LR parsers are able to parse more complicated languages, while LL parsers are more intuitive and easier to understand.

Other criteria that I find important are:

  • how easy it is to understand and debug the generated parser / the parser generation process itself
    • this may play heavily in favor of LL parsers as they are generally easier to understand to laymen
  • performance

Upvotes: 1

Related Questions