Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

Parser

Tutorials

  • Building Language Front-Ends
  • Inside CodeAnalysis - How CodeStructure Parses C
  • Design and Compilation Strategy
  • Implementing the LaTeX Math Parser
  • MaTeX Comparison Showcase
  • The Parser Landscape - a Survey of What Exists Today
  • The Parser Zoo - language front-ends over a shared algebra
  • Parsing BNF Grammars (and bootstrapping a TPTP parser)
  • Parsing GrammarRules Locally
  • A Markdown Inline Parser in Parser Combinators
  • ParsingOpenQASM
  • Parsing TPTP, Auto-Generated from the Published BNF
  • PrattVsPEG
  • The Wolfram Box Typesetting Reference

Guides

  • Parsing in the Wolfram Language

Symbols

  • ASTAddSource
  • ASTAlgebra
  • ASTContainer
  • ASTLeafQ
  • ASTNodeQ
  • ASTStripSource
  • BinaryNode
  • BrainfuckAST
  • BrainfuckGrammar
  • BrainfuckRun
  • BrainfuckSemantic
  • CalculatorAST
  • CalculatorEval
  • CalculatorGrammar
  • CalculatorSemantic
  • CallNode
  • ContainerNode
  • EBNFParse
  • EBNFRules
  • ErrorNode
  • ExportLaTeX
  • GroupNode
  • InfixNode
  • JSONAST
  • JSONGrammar
  • JSONImport
  • JSONSemantic
  • LambdaAST
  • LambdaEval
  • LambdaGrammar
  • LambdaSemantic
  • LaTeXMathParse
  • LaTeXMathParser
  • LaTeXMathStyle
  • LeafNode
  • LispAST
  • LispGrammar
  • LispRead
  • LispSemantic
  • LispSymbol
  • MarkdownInlineParse
  • MarkdownInlineParser
  • MarkdownParse
  • MarkdownParser
  • ParseAction
  • ParseBetween
  • ParseChainLeft
  • ParseChainRight
  • ParseCharacter
  • ParseChoiceLongest
  • ParseChoice
  • ParseFail
  • ParseLiteral
  • ParseLookahead
  • ParseMany
  • Parse
  • ParseNotFollowedBy
  • ParseOperatorTable
  • ParseOptional
  • ParsePartial
  • ParsePosition
  • ParserCombinator
  • ParserCombinatorQ
  • ParserCompile
  • ParseRecursive
  • ParseRegex
  • ParseSepBy1
  • ParseSepBy
  • ParseSequence
  • ParseSome
  • ParseSucceed
  • ParseTry
  • PostfixNode
  • PrefixNode
  • RecCell
  • RecRef
  • SetRec
  • SpannedToken
  • TernaryNode
  • ToCodeParser
  • TPTPExport
  • TPTPImport

Overviews

  • WolframParser
Wolfram`Parser`
EBNFParse
​
EBNFParse
[source]
reads a BNF / EBNF grammar from the string source and returns an
Association
mapping each rule name to the
ParserCombinator
it lowers to.
​
​
EBNFParse
[
File
[path]]
reads the grammar from a file.
​
Details and Options
▪
A grammar rule has the shape
<name>::=alt1|alt2|…
: a non-terminal name in angle brackets, an arrow, then alternatives separated by
|
. Each alternative is a whitespace-separated sequence of elements.
▪
In a rule body a non-terminal reference
<name>
lowers to a recursive reference resolved at parse time (through
ParseRecursive
), a bare token lowers to a
ParseLiteral
, and a postfix
<name>*
lowers to a
ParseMany
.
▪
Whitespace between adjacent elements is consumed automatically, so
12+34
and
12+34
both parse.
▪
Each value in the returned association is the parser for one rule; run it on input with
Parse
.
▪
Four arrow kinds are recognized:
::=
(syntactic),
:==
(semantic, same surface shape),
::-
(token construction), and
:::
(character class). The
::-
and
:::
bodies compile through a regex-style meta-parser that handles classes (
[a-z]
,
[^*]
), grouping (
(x|y)
), references (
<name>
), and the postfix operators
*
,
+
,
?
.
▪
A directly left-recursive rule
A::=Ar|b
is rewritten to the equivalent
A::=b(r)*
before lowering; indirect (mutual) left recursion is not rewritten.
▪
Each rule's alternatives are sorted longest-first by element count, so a longer shared-prefix alternative is tried before a shorter one.
▪
The BNF source is itself parsed by a grammar built entirely from
Parse*
combinators — see the tutorial
Parsing BNF Grammars
.
Option
Default
Description
"PrimitiveOverrides"
`<
​
"Actions"
`<
​
"ChoiceMode"
"Auto"
how alternatives combine:
"PEG"
(first match wins),
"Longest"
(longest match wins), or
"Auto"
(longest match only when alternatives have equal element counts)
​
Examples  
(18)
Basic Examples  
(4)
Read a three-rule arithmetic grammar; the result is an association keyed by rule name:
In[1]:=
g=
EBNFParse
[" <digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 <number> ::= <digit><digit>* <expr> ::= <number> + <number>"];​​Keys[g]
Out[1]=
{digit,number,expr}
​
Each rule name maps to the parser combinator it lowers to:
In[1]:=
g["number"]
Out[1]=
ParserCombinator
Type: Action
Arity: 2
Compiled: False

​
Run one of the lowered rules on input with
Parse
:
In[1]:=
Parse
[g["number"],"12345"]
Out[1]=
{1,{2,3,4,5}}
​
The
<expr>
rule composes the other rules, and the whitespace around
+
is optional:
In[1]:=
Parse
[g["expr"],"12 + 34"]
Out[1]=
{{1,{2}},+,{3,{4}}}
Scope  
(9)

Properties & Relations  
(2)

Possible Issues  
(2)

Neat Examples  
(1)

SeeAlso
EBNFRules
 
▪
Parse
 
▪
ParseAction
 
▪
ParseChoice
 
▪
ParseRecursive
 
▪
ParseOperatorTable
 
▪
TPTPImport
 
▪
ParserCombinator
RelatedGuides
▪
Parsing in the Wolfram Language
""

© 2026 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com