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`
EBNFRules
​
EBNFRules
[source]
parses a BNF / EBNF grammar from the string source and returns the list of raw rule records, without lowering them to parsers.
​
​
EBNFRules
[
File
[path]]
reads the grammar from a file.
​
Details and Options
▪
Each record has the form
EBNFRule[name,kind,body]
: name is the rule's non-terminal name, kind is the arrow string, and body is the list of alternatives.
EBNFRule
and the body markers below are internal heads in the package's private
Wolfram`Parser`EBNFPrivate`
context.
▪
kind is one of
"::="
(syntactic),
":=="
(semantic),
"::-"
(token construction), or
":::"
(character class) — the four arrows the grammar notation distinguishes.
▪
Each alternative in body is a list of elements:
Lit[s]
for a literal token,
NonTerm[name]
for a non-terminal reference, and
Rep["Many",elt]
for a postfix-
*
repetition.
▪
Rules are returned in source order.
▪
EBNFParse
calls
EBNFRules
internally and then lowers each record to a
ParserCombinator
.
EBNFRules
stops before lowering, so it is the way to inspect a parsed grammar's shape — rule count, names, and kinds — without building parsers.
▪
Left-recursion elimination and longest-first alternative sorting are applied by
EBNFParse
during lowering, not by
EBNFRules
; the records reflect the grammar exactly as written.
​
Examples  
(8)
Basic Examples  
(4)
The raw record of a one-rule grammar:
In[1]:=
EBNFRules
["<greeting> ::= hello | bye"]
Out[1]=
{Wolfram`Parser`EBNFPrivate`EBNFRule[greeting,::=,{{Wolfram`Parser`EBNFPrivate`Lit[hello]},{Wolfram`Parser`EBNFPrivate`Lit[bye]}}]}
_________________________________________________________________________________________________________________
The result is one record per rule; here a three-rule grammar yields three:
In[1]:=
Length@
EBNFRules
[" <digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 <number> ::= <digit><digit>* <expr> ::= <number> + <number>"]
Out[1]=
3
_________________________________________________________________________________________________________________
The first field of each record is the rule name:
In[1]:=
EBNFRules
[" <digit> ::= 0 | 1 <number> ::= <digit><digit>*"]All,1
Out[1]=
{digit,number}
_________________________________________________________________________________________________________________
The second field is the arrow kind — one grammar exercising all four the notation distinguishes:
In[1]:=
EBNFRules
["<a> ::= x<b> :== y<c> ::- z<d> ::: w"]All,2
Out[1]=
{::=,:==,::-,:::}
Scope  
(2)

Properties & Relations  
(2)

SeeAlso
EBNFParse
 
▪
Parse
 
▪
ParseAction
 
▪
ParserCombinator
 
▪
TPTPImport
RelatedGuides
▪
WolframParser
""

© 2026 Wolfram. All rights reserved.

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