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`
ParseOperatorTable
​
ParseOperatorTable
[unit,levels]
returns the
ParserCombinator
that parses an operator-precedence expression grammar — operands separated by prefix, infix, and postfix operators — in a single linear left-to-right pass.
​
​
unit parses one operand (an atom, or a parenthesised sub-expression via
ParseRecursive
). levels is a list of precedence levels, tightest-binding first; each level is a list of operator specs
{fixity,opParser}
.
​
​
It is the
Pratt / top-down-operator-precedence
("precedence climbing") engine, exposed as a combinator: precedence becomes data (the table) instead of structure (a hand-cascaded tower of
ParseChainLeft
/
ParseChainRight
nonterminals).
​
Details and Options
▪
fixity is one of the strings
"InfixL"
(left-associative),
"InfixR"
(right-associative),
"Prefix"
, or
"Postfix"
.
▪
Operator parsers return their combining function — the same convention as
ParseChainLeft
. opParser matches the operator token and yields a function: binary
f[left,right]
for infix, unary
f[operand]
for prefix / postfix. Use
ParseAction
to attach the function, e.g.
ParseAction[ParseLiteral["+"],(Plus&)]
.
▪
Precedence is the level position. The first level binds tightest; the last binds loosest. Operators that share a level share a precedence (e.g.
+
and
-
).
▪
A lone spec stands in for a one-operator level:
{"InfixL",op}
is accepted as shorthand for
{{"InfixL",op}}
.
▪
Recursion is via
ParseRecursive
: a parenthesised-expression branch inside unit refers back to the symbol the table is bound to, so the engine re-enters at binding power 0 inside brackets.
▪
Linear time. The leading operand is parsed once; operators are then consumed while their binding power exceeds the caller's. A
ParseChoice
over
or|and|apply
re-parses the shared leading operand once per alternative and backtracks exponentially (the TPTP THF blow-up);
ParseOperatorTable
does not.
▪
Depth guard. Right-nested recursion carries the same nesting limit as the rest of the interpreter, returning a clean
Failure
["ParseError",…]
rather than tripping
$RecursionLimit
.
▪
Generalises the chain combinators. A single-level table of one
"InfixL"
operator is exactly
ParseChainLeft
; one
"InfixR"
operator is
ParseChainRight
. The table adds multiple precedence levels and prefix / postfix in one pass.
Examples  
(4)
Basic Examples  
(1)
A four-operator arithmetic calculator —
*
/
bind tighter than
+
-
, and the operator parsers return the actual arithmetic functions, so the result evaluates:
In[1]:=
num=
ParseAction

ParseRegex
["[0-9]+"],FromDigits;​​addOp=
ParseChoice

ParseAction

ParseLiteral
["+"],(Plus&),​​
ParseAction

ParseLiteral
["-"],(Subtract&);​​mulOp=
ParseChoice

ParseAction

ParseLiteral
["*"],(Times&),​​
ParseAction

ParseLiteral
["/"],(Divide&);​​unit=
ParseChoice
​​
ParseBetween

ParseLiteral
"("],
ParseRecursive
[calc],
ParseLiteral
[")",​​num;​​calc=
ParseOperatorTable
[unit,{​​{{"InfixL",mulOp}},(*tightest*)​​{{"InfixL",addOp}}(*loosest*)​​}];​​​​
Parse
[calc,"2*3+4*5"]
Out[1]=
26
Precedence and left-associativity:
In[2]:=
Parse
[calc,"1+2*3"]
Out[2]=
7
In[3]:=
Parse
[calc,"1-2-3"]
Out[3]=
-4
Parentheses re-enter the table at the bottom binding power:
In[4]:=
Parse
[calc,"(1+2)*3"]
Out[4]=
9
Scope  
(1)

Properties & Relations  
(1)

Possible Issues  
(0)

Neat Examples  
(1)

SeeAlso
ParseChainLeft
 
▪
ParseChainRight
 
▪
ParseRecursive
 
▪
ParseSequence
 
▪
ParserCombinator
RelatedGuides
▪
Parsing in the Wolfram Language
""

© 2026 Wolfram. All rights reserved.

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