back

by matheusmoreira·9y ago·view on hn ↗
The difference in performance is explained by the capabilities of the algorithms used by each parser library.

The Earley algorithm can parse any context-free grammar while Chevrotain appears to be restricted to the LL(k) class of grammars. Earley is O(n³) in the worst case but it performs better with more restricted classes of context-free grammars. Even if given the same grammar, Earley will still incur the cost of generality, a cost which LL(k) parsers don't have to pay.

1 comments
Okay, do you have a non-contrived, practical example that can be handled by Nearley but not LL(k)?

It also doesn't help that linear LL(k) performance/optimizations is the first feature listed.