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`Languages`Calculator`
CalculatorGrammar
​
CalculatorGrammar
[alg]
builds the calculator parser - a
ParserCombinator
- over the algebra alg, an
Association
of builder functions its semantic actions call.
​
Details and Options
▪
CalculatorGrammar
is the heart of the calculator's dual-algebra design: the grammar is written once, parameterized over alg. Hand it
ASTAlgebra
and the same grammar emits a standard syntax tree; hand it
CalculatorSemantic
and it folds straight to a number. The grammar never changes; only the algebra does.
▪
The semantic actions never construct nodes directly. They call into alg by key -
alg["Leaf"][kind,src]
,
alg["Binary"][op,l,r]
,
alg["Prefix"][op,x]
- so swapping the algebra reroutes every action at once.
▪
The grammar covers
+
-
*
/
^
, unary minus, parentheses, integer and real literals, and bare identifiers. Precedence is set by
ParseOperatorTable
, the library's Pratt / precedence-climbing combinator: tightest first, parentheses, unary minus,
^
(right associative),
*
/
,
+
-
.
▪
The result is a built
ParserCombinator
. Run it on input either as
pc[input]
or equivalently with
Parse
[pc,input]
.
▪
CalculatorAST
and
CalculatorEval
are thin wrappers:
CalculatorAST
runs
CalculatorGrammar[ASTAlgebra]
(wrapping the result in a
ContainerNode
), and
CalculatorEval
runs
CalculatorGrammar[CalculatorSemantic]
.
​
Examples  
(4)
Basic Examples  
(1)
Building the grammar over an algebra yields a
ParserCombinator
:
In[1]:=
Head
CalculatorGrammar

CalculatorSemantic

Out[1]=
ParserCombinator
The two algebras share this one grammar. Over
CalculatorSemantic
, the same input folds to a number:
In[2]:=
CalculatorGrammar

CalculatorSemantic
["1+2*3"]
Out[2]=
7
Over
ASTAlgebra
, the same grammar emits a standard syntax-tree node instead:
In[3]:=
CalculatorGrammar

ASTAlgebra
["1+2"]
Out[3]=
BinaryNode[+,{LeafNode[Integer,1,Source{1,2}],LeafNode[Integer,2,Source{3,4}]},]
Scope  
(1)

Properties & Relations  
(1)

Possible Issues  
(1)

SeeAlso
CalculatorAST
 
▪
CalculatorEval
 
▪
CalculatorSemantic
 
▪
ASTAlgebra
 
▪
ParseOperatorTable
 
▪
ParserCombinator
RelatedGuides
▪
ParserZoo
""

© 2026 Wolfram. All rights reserved.

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