Skip to content

How does csly compare

aldosa edited this page Sep 8, 2021 · 2 revisions

Comparison

There are many parser generators available for C#. Here is how csly compares to some common libraries. Remember this comparison is strongly biased. It simply reflects the motivations behind csly.

ANTLR is the reference for parser generators. It can generate fast parsers for languages ranging from simple DSLs to full-featured languages. Compared to csly:

Pros:

  • Powerful and capable: many features (token channels, island grammars) have no equivalent in csly.
  • It is fast, maybe the fastest!
  • Grammar is clearly decoupled and readable.

Cons:

  • An extra build step is needed, complicating setup.
  • It is not strongly typed, at least as strongly as csly.

Pros:

  • Embeddable, you don't need an extra build step.

Cons:

  • Despite Linq expressions being similar to (E)BNF syntax, grammar is not as easily readable.
  • Monadic parsers may be difficult to grok.

hand crafted parsers

OK that's not a library, but you often find some really simple languages parsed with handmade parsers.

Pros:

  • Embedded by nature and no dependencies.
  • Really flexible error reporting.

Cons:

  • Repetitive code.
  • Left recursion:
    • Handling right associative expressions may be cumbersome.
  • Quickly become difficult to maintain as the grammar grows (very quickly in fact).