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`
CalculatorAST
​
CalculatorAST
[expr]
parses the arithmetic expression string expr to a standard syntax tree - a
ContainerNode
of
BinaryNode
,
PrefixNode
and
LeafNode
.
​
Details and Options
▪
CalculatorAST
is the standard-AST mode of the calculator grammar: it runs
CalculatorGrammar
over the shared
ASTAlgebra
, so the result carries no language-specific meaning, only structure.
▪
The grammar covers
+
-
*
/
^
, unary minus, parentheses, integer and real literals, and bare identifiers. Precedence, tightest first: parentheses, unary minus,
^
(right associative),
*
/
,
+
-
.
▪
CalculatorEval
runs the same grammar over
CalculatorSemantic
instead, evaluating to a number. The grammar is written once; only the algebra differs.
▪
A
LeafNode
keeps the literal source text (
"1"
, not
1
); the value is only interpreted in the
CalculatorEval
mode.
▪
Every node carries a
"Source"
span in its metadata, a
CodeParser
line-column pair
{{startLine,startCol},{endLine,endCol}}
. A leaf spans its own text; a composite spans its children, so a multi-line input gives a span whose endpoints sit on different lines.
▪
Input that does not parse to completion returns a
Failure
(see
Parse
).
​
Examples  
(4)
Basic Examples  
(1)
The tree nests by precedence -
*
binds tighter than
+
:
In[1]:=
CalculatorAST
["1 + 2*3"]
Out[1]=
ContainerNode[String,{BinaryNode[+,{LeafNode[Integer,1,Source{{1,1},{1,2}}],BinaryNode[*,{LeafNode[Integer,2,Source{{1,5},{1,6}}],LeafNode[Integer,3,Source{{1,7},{1,8}}]},Source{{1,5},{1,8}}]},Source{{1,1},{1,8}}]},Source{{1,1},{1,8}}]
Unary minus is a
PrefixNode
, and an identifier is a
"Symbol"
LeafNode
:
In[2]:=
CalculatorAST
["-x"]
Out[2]=
ContainerNode[String,{PrefixNode[-,LeafNode[Symbol,x,Source{{1,2},{1,3}}],Source{{1,2},{1,3}}]},Source{{1,2},{1,3}}]
The same source through
CalculatorEval
is a number, not a tree:
In[3]:=
CalculatorEval
["1 + 2*3"]
Out[3]=
7
Scope  
(1)

Properties & Relations  
(1)

Possible Issues  
(1)

SeeAlso
CalculatorEval
 
▪
CalculatorGrammar
 
▪
BinaryNode
 
▪
PrefixNode
 
▪
ASTAlgebra
RelatedGuides
▪
ParserZoo
""

© 2026 Wolfram. All rights reserved.

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