Wolfram/ Parser

Parser combinators for the Wolfram Language - GrammarRules compatible, locally compiled, with a LaTeX math parser

Contributed by: Nikolay Murzin, Claude (Anthropic)

The package provides Parse and ParserCompile as the entry points, ParserCombinator as the single computable head every constructor returns, and the Parse* family of constructors - ParseLiteral, ParseCharacter, ParseSequence, ParseChoice, ParseMany, ParseSome, ParseOptional, ParseBetween, ParseAction, ParseRecursive, ParseLookahead, ParseNotFollowedBy, ParseTry. GrammarRules is accepted as input to Parse and lowered locally. LaTeXMathParse parses LaTeX math-mode source to a tree of Wolfram boxes.

Installation Instructions

To install this paclet in your Wolfram Language environment, evaluate this code:
PacletInstall["Wolfram/Parser"]


To load the code after installation, evaluate this code:
Needs["Wolfram`Parser`"]

Details

The library reuses the GrammarRules declarative slot-syntax DSL, but compiles each grammar to a local parser via FunctionCompile instead of round-tripping through CloudDeploy. The supported subset of GrammarRules is mapped in the Parsing GrammarRules Locally tech note.
A Parsec-style combinator core (Parse* constructors) covers grammars that don't fit the declarative shape: LaTeX math, custom DSLs with backtracking / lookahead, recursive descent over CodeParser ASTs.
LaTeXMathParse is a working LaTeX math-mode parser at 126 / 126 coverage of KaTeX's own screenshotter test corpus. Output is a tree of Wolfram boxes (FractionBox, SubsuperscriptBox, RadicalBox, GridBox, …) ready to drop into a notebook cell or wrap with DisplayForm for kernel-side rendering.
Operates uniformly on strings, on lists of tagged tokens, and on lists of Wolfram expressions (so the same combinators that lex a string can walk a CodeParser AST).
The kernel is dependency-free and has no C library; performance comes from FunctionCompile's LLVM backend.

Examples

Compatibility

Wolfram Language Version 14.0

Version History

  • 1.1.10 – 06 October 2026
  • 1.1.8 – 25 August 2026
  • 1.1.7 – 24 August 2026
  • 1.1.5 – 25 August 2026
  • 1.1.4 – 20 August 2026
  • 1.1.2 – 29 July 2026
  • 1.1.1 – 29 July 2026
  • 1.1.0 – 29 July 2026

License Information

MIT License

Paclet Source

Source Metadata

See Also