Skip to content

Alternatives

Each tab compares Hyperlark with the main parsing libraries in one language and says when to prefer which.

Hyperlark loads a .lark grammar when your program runs and compiles it in memory, with no code generation. It has two parsers, LALR and Earley: Earley accepts grammars LALR rejects and is slower on every input here. Python, Rust and TypeScript (through WASM) have both; C has LALR only, for now.

In Python, Hyperlark is often a drop-in replacement for lark: the same grammar and nearly the same API, with the parse running in native Rust.

ParserApproachProsCons
HyperlarkRust core behind a Lark-compatible APIParse in native code; LALR and Earley; no runtime dependency on larkIn beta: fewer users and examples; close to lark, with documented gaps; wheels only, for CPython 3.10+ on Linux, macOS 13+ and Windows x64 (install); no PyPy
larkPure Python; the library Hyperlark reimplementsMature; Earley, LALR and CYK, a reconstructor and tree templates; large community; no compiled dependencySlower than Hyperlark and sly (chart below)
PLYPython lex-yacc (LALR)Stable; well documentedRules in method docstrings; no tree by default
slyPLY’s successor (yacc-style LALR)Reduces straight to a value, no treeThe grammar is Python code; less active
pyparsingCombinators (PEG-like), pure PythonNo grammar file: the grammar is Python expressionsPure Python; ordered choice with |, so the first alternative that matches wins
parsimoniousPEG with a grammar fileShort declarative grammarsPure Python; PEG semantics (ordered choice, no left recursion)
ANTLR4 (Python target)ALL(*) parser generator (codegen)One grammar, many target languages; mature toolingCodegen through a Java tool; heavy, verbose runtime

PLY, pyparsing and ANTLR are not in the chart below.

JSON → digest (Python, 134 KB)
Hyperlark (LALR) 4.74 ms
sly 42.3 ms
lark (LALR) 52.6 ms
Hyperlark (Earley) 62.9 ms
parsimonious 194 ms
Hyperlark's LALR is 11.1× faster than Lark's and ahead of sly. The three LALR rows compute the value during the parse with no tree (Hyperlark and Lark: a transformer; sly: reduce actions). Lark's Earley (1096 ms) is off the chart's scale; Hyperlark's Earley is 17.4× faster than it.

Which to pick:

  • Hyperlark for Lark’s grammar and API with a much faster parse.
  • Lark for a feature Hyperlark lacks, such as the reconstructor or tree templates (full list), for pure Python with no compiled dependency, or on PyPy.
  • sly for a yacc-style evaluator with no tree.
  • ANTLR for its tooling, or for a target language Hyperlark does not have.