Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Extended Backus–Naur form
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Basics== EBNF is a [[code]] that expresses the [[syntax]] of a formal language.<ref>{{cite web |last=Pattis |first=Richard E. |author-link=Richard E. Pattis |date=2013-08-12<!--from PDF properties--> |title=EBNF: A Notation to Describe Syntax |url=http://www.ics.uci.edu/~pattis/misc/ebnf2.pdf |website=ICS.UCI.edu |publisher=[[University of California, Irvine]] |page=1 |access-date=2025-05-18 }}</ref> An EBNF consists of [[Terminal and nonterminal symbols#Terminal symbols|terminal symbol]]s and non-terminal production rules which are the restrictions governing how terminal symbols can be combined into a valid sequence. Examples of terminal symbols include [[Alphanumerics|alphanumeric characters]], [[Punctuation|punctuation marks]], and [[whitespace character]]s. The EBNF defines [[Production (computer science)|production rules]] where sequences of symbols are respectively assigned to a [[Terminal and nonterminal symbols#Nonterminal symbols|nonterminal]]: <syntaxhighlight lang="ebnf"> digit excluding zero = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; digit = "0" | digit excluding zero ; </syntaxhighlight> This production rule defines the nonterminal ''digit'' which is on the left side of the assignment. The vertical bar represents an alternative and the terminal symbols are enclosed with quotation marks followed by a semicolon as terminating character. Hence a ''digit'' is a ''0'' or a ''digit excluding zero'' that can be ''1'' or ''2'' or ''3'' and so forth until ''9''. A production rule can also include a sequence of terminals or nonterminals, each separated by a comma: <syntaxhighlight lang="ebnf"> twelve = "1", "2" ; two hundred one = "2", "0", "1" ; three hundred twelve = "3", twelve ; twelve thousand two hundred one = twelve, two hundred one ; </syntaxhighlight> Expressions that may be omitted or repeated can be represented through curly braces { ... }: <syntaxhighlight lang="ebnf"> positive integer = digit excluding zero, { digit } ; </syntaxhighlight> In this case, the strings ''1'', ''2'', ..., ''10'', ..., ''10000'', ... are correct expressions. To represent this, everything that is set within the curly braces may be repeated arbitrarily often, including not at all. An option can be represented through squared brackets [ ... ]. That is, everything that is set within the square brackets may be present just once, or not at all: <syntaxhighlight lang="ebnf"> integer = "0" | [ "-" ], positive integer ; </syntaxhighlight> Therefore, an [[integer]] is a zero (''0'') or a [[positive integer]] that may be preceded by an optional [[Plus and minus signs#Minus sign|minus sign]]. EBNF also provides, among other things, the syntax to describe repetitions (of a specified number of times), to exclude some part of a production, and to insert comments in an EBNF grammar. ===Table of symbols=== The following represents a proposed ISO/IEC 14977 standard, by R. S. Scowen, page 7, tables 1 and 2. {| class="wikitable" |- ! Usage ! Notation ! Alternative ! Meaning |- | definition | style="text-align:center" | {{mono|{{=}}}} | | |- | [[concatenation]] | style="text-align:center" | {{mono|,}} | | |- | termination | style="text-align:center" | {{mono|;}} | style="text-align:center" | {{Mono|.}} | |- | [[alternation (formal language theory)|alternation]] | style="text-align:center" | {{mono|{{!}}}} | style="text-align:center" | {{Mono|/ or !}} | |- | optional | style="text-align:center" | {{mono|[ ... ]}} | style="text-align:center" | {{Mono|(/ ... /)}} | style="text-align:center" | none or once |- | repetition | style="text-align:center" | {{mono|{ ... } }} | style="text-align:center" | {{Mono|(: ... :)}} | style="text-align:center" | none or more |- | grouping | style="text-align:center" | {{mono|( ... )}} | | |- | terminal string | style="text-align:center" | {{mono|" ... "}} | style="text-align:center" | {{mono|' ... '}} | |- | comment | style="text-align:center" | {{mono|(* ... *)}} | | |- | special sequence | style="text-align:center" | {{mono|? ... ?}} | | |- | exception | style="text-align:center" | {{mono|-}} | | |}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Extended Backus–Naur form
(section)
Add topic