纲是什么意思| 月经血块是什么原因| 白天咳嗽晚上不咳嗽是什么原因| 拉屎酸臭是什么原因| 时光荏苒岁月如梭是什么意思| 指导员是什么级别| 刚愎自负是什么意思| 梦见一个人死了是什么意思| 低gi是什么意思| 林五行属什么| 胃癌低分化是什么意思| 糖尿病吃什么药| 什么笔不能写字| 滞气是什么意思| 人为什么要日b| 男人硬不起来是什么原因| boy是什么品牌| 紫砂壶适合泡什么茶| 孕酮低什么原因| 麻疹的症状是什么| 做不好的梦预示着什么| 相知是什么意思| 双侧筛窦粘膜增厚是什么意思| 家有小女是什么生肖| 郡肝是什么| 出汗少是什么原因| 什么是条件反射| 宝宝便秘吃什么食物好| 梦到捡菌子是什么意思| 前列腺炎什么症状| 梦见老人死了又活了是什么意思| 前列腺炎不治疗有什么后果| 蛇鼠一窝是什么意思| 补铁吃什么药| 石榴代表什么生肖| b型血为什么叫贵族血| 快递客服主要做什么| vvip是什么意思| 现在有什么水果| 羊五行属什么| 吃过敏药有什么副作用| 孕反应最早什么时候开始| 皮肤上出现小红点是什么原因| 有痔疮不能吃什么食物| 鼻子上长红疙瘩是什么原因| 一个均一个金念什么| 肩周炎用什么药最好| 指甲有白点是缺什么| yn是什么牌子| 涤是什么面料| 两边白头发多是什么原因造成的| 什么叫有机食品| 早上喝豆浆有什么好处| 阎王叫什么名字| 做腹腔镜手术后需要注意什么| 往返是什么意思| 阿西是什么意思| 苹果五行属什么| 高见是什么意思| 长期便秘喝什么茶好| 孩子不长个子是什么原因| 什么是毒品| 男左女右是什么意思| 白脸代表什么| 男女授受不亲是什么意思| anker是什么牌子| 什么是支原体感染| 市法院院长是什么级别| 36d什么意思| 吃钙片有什么好处| 属兔与什么属相相克| 身上长水泡是什么原因| 犀牛吃什么| 女生肚脐眼下面疼是什么原因| 早上起床口苦是什么原因| 真丝姆米是什么意思| 色字头上一把刀什么意思| 武汉什么省| 9月8号是什么星座| 民不聊生是什么意思| 安痛定又叫什么| 秒后面是什么单位| 凌空什么| 冷喷机喷脸有什么好处| 蓝瘦香菇是什么意思| 跳楼机是什么| 调制乳粉是什么意思| 阴道吹气是什么原因| 什么的元帅| 如果怀孕了会有什么预兆| 4月20是什么星座| 什么是开光| 再创佳绩是什么意思| 乳头瘤有什么症状| 爱到什么时候| smeg什么品牌| 孕妇喝可乐对胎儿有什么影响| 鼻尖发红是什么原因| 什么是鸡奸| 157是什么意思| 内热是什么意思| 不孕为什么要查胰岛素| 鸡冲什么生肖| 反贪局局长是什么级别| 梦到羊是什么意思| 花儿为什么这样红简谱| cocoon是什么品牌| 甲状腺结节不能吃什么食物| 白带是绿色的是什么原因| 正常尿液是什么颜色| 霸王别姬是什么菜| 痛风性关节炎吃什么药| 拿什么拯救你我的爱人演员表| 身份证借给别人有什么危害性| 经常偏头疼是什么原因| 矽肺是什么意思| 6月26什么星座| 洋桔梗花语是什么| 大姨妈不来是什么原因| 肺部真菌感染吃什么药| 一直吐口水是什么原因| 头顶秃了一小块是什么原因怎么办| 医生为什么喜欢开地塞米松| 一串什么| 水杯什么品牌好| 排卵期什么意思| 长期吃避孕药有什么副作用| 眼开大财主是什么生肖| ac是什么意思| cdfl是什么意思| 做梦抓到很多鱼是什么征兆| 太阳穴有痣代表什么| 虎头蛇尾是什么意思| 倒嗓是什么意思| 吃开心果有什么好处和坏处| 娃娃鱼是什么动物| 吃了避孕药后几天出血是什么原因| 钢琴10级是什么水平| 送朋友鲜花送什么花| 海带排骨汤海带什么时候放| 一阴一阳是什么数字| 宝宝风寒感冒吃什么药最好| 佛手柑是什么| 辛苦是什么意思| 气场是什么意思| qs什么意思| 月柱华盖是什么意思| 国标舞是什么舞| 慢性胰腺炎吃什么药效果最好| 整体认读音节有什么| 婴儿便便是绿色的是什么原因| 2021年属什么生肖| 冬阴功是什么意思| 五字五行属什么| 阳虚火旺吃什么中成药| 宁字五行属什么的| 子宫萎缩是什么原因| 复位是什么意思| 避火图是什么| 辟邪剑谱和葵花宝典有什么关系| 马云是什么大学毕业的| 胆囊息肉是什么| 猫的偏旁叫什么| 8月19日是什么星座| 十月十日是什么星座| 每延米是什么意思| 伤口好转的迹象是什么| 灵魂是什么意思| 小孩测骨龄挂什么科| 怀孕拉肚子吃什么药| 子母环是什么形状图片| colorful是什么牌子| 眼底筛查是检查什么| 方圆脸适合什么发型| 肝裂不宽是什么意思| 40不惑是什么意思| 云是由什么组成的| 印度为什么没把墨脱占领| 小脑延髓池是什么意思| 白完念什么| 游龙戏凤是什么意思| 歼31为什么没消息了| 五毒为什么没有蜘蛛| 腰椎间盘突出吃什么药| 什么命要承受丧子之痛| 什么是基数| 异次元是什么意思| tt什么意思| 喜欢紫色代表什么| 双下肢静脉彩超主要检查什么| 玉米什么时候打药| 巨蟹座和什么星座最配| 品牌背书是什么意思| 弱冠之年是什么意思| 吃什么增加血小板| 肌酸激酶偏低说明什么| 叫嚣是什么意思| 腌肉用什么淀粉| 乳头疼吃什么药| 什么样的夕阳| 什么地什么| 憋尿会造成什么后果| 小狗的耳朵像什么| 甲钴胺片主治什么病| 微信中抱拳是什么意思| 打扰了是什么意思| 成是什么生肖| 什么星| 支原体培养及药敏是检查什么| 壁挂式空调什么牌子好| 桃花的花语是什么| 12.16是什么星座| 什么是学前教育| 运是什么结构| 子宫腺肌症有什么症状| 屁股上长痘是什么原因| 珍贵的动物是什么生肖| 议论纷纷是什么意思| 放屁是热的是什么原因| 什么时候降温| 尿分叉吃什么药好得快| 什么花喜欢磷酸二氢钾| 什么是原研药| 贵圈是什么意思| 壁是什么意思| 大便弱阳性是什么意思| 卵巢炎症有什么症状| 拔完牙吃什么药| 产奶速度慢是什么原因| 履是什么意思| 河南属于什么平原| 水肿是什么| 一什么白菜| 大姑姐最怕弟媳什么| 一个月没有来月经是什么原因| 长胸毛的男人代表什么| 10月28日什么星座| 风湿免疫科是看什么病的| 降肝火喝什么茶| 眼睛不好吃什么补眼睛| 鳑鲏吃什么| 洋姜有什么功效与作用| hp医学上是什么意思| 怙恃是什么意思| 自叹不如什么意思| 什么是功能性消化不良| 八面玲珑指什么生肖| 月经期体重增加是什么原因| 刘海是什么意思| 鳖孙是什么意思| mm是什么意思| 好人卡什么意思| 乙肝检查挂什么科| 底细是什么意思| 为什么汤泡饭对胃不好| 考试前吃什么好| 梦见包丢了是什么意思| 乳腺靶向检查是什么| 早上起床想吐是什么原因| 火水是什么| 血糖高吃什么药最好| 产后腰疼是什么原因| 什么样的梦才算是胎梦| 眉飞色舞是什么意思| 百度
百度 虽然目前看来这一去向是最优途径,但是因为政府支持健全“三点半课堂”,无论是完善设备还是健全管理体系,不仅需要大量的时间,还受管理人员、师资、资金、设备、场地等硬性条件的限制。

In computer science, extended Backus–Naur form (EBNF) is a family of metasyntax notations, any of which can be used to express a context-free grammar. EBNF is used to make a formal description of a formal language such as a computer programming language. They are extensions of the basic Backus–Naur form (BNF) metasyntax notation. The earliest EBNF was developed by Niklaus Wirth, incorporating some of the concepts (with a different syntax and notation) from Wirth syntax notation. Today, many variants of EBNF are in use. The International Organization for Standardization adopted an EBNF Standard, ISO/IEC 14977, in 1996.[1][2] According to Zaytsev, however, this standard "only ended up adding yet another three dialects to the chaos" and, after noting its lack of success, also notes that the ISO EBNF is not even used in all ISO standards.[3]

This article uses EBNF as specified by the ISO for examples applying to all EBNFs. Other EBNF variants use somewhat different syntactic conventions.

Basics

edit

EBNF is a code that expresses the syntax of a formal language.[4] An EBNF consists of terminal symbols 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 alphanumeric characters, punctuation marks, and whitespace characters.

The EBNF defines production rules where sequences of symbols are respectively assigned to a nonterminal:

digit excluding zero = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
digit                = "0" | digit excluding zero ;

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:

twelve                          = "1", "2" ;
two hundred one                 = "2", "0", "1" ;
three hundred twelve            = "3", twelve ;
twelve thousand two hundred one = twelve, two hundred one ;

Expressions that may be omitted or repeated can be represented through curly braces { ... }:

positive integer = digit excluding zero, { digit } ;

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:

integer = "0" | [ "-" ], positive integer ;

Therefore, an integer is a zero (0) or a positive integer that may be preceded by an optional 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

edit

The following represents a proposed ISO/IEC 14977 standard, by R. S. Scowen, page 7, tables 1 and 2.

Usage Notation Alternative Meaning
definition =
concatenation ,
termination ; .
alternation | / or !
optional [ ... ] (/ ... /) none or once
repetition { ... } (: ... :) none or more
grouping ( ... )
terminal string " ... " ' ... '
comment (* ... *)
special sequence ? ... ?
exception -

Examples

edit

Syntax diagram

edit
 
One possible EBNF syntax diagram

EBNF

edit

Even EBNF can be described using EBNF. Consider below grammar (using conventions such as "-" to indicate set disjunction, "+" to indicate one or more matches, and "?" for optionality):

letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
       | "H" | "I" | "J" | "K" | "L" | "M" | "N"
       | "O" | "P" | "Q" | "R" | "S" | "T" | "U"
       | "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
       | "c" | "d" | "e" | "f" | "g" | "h" | "i"
       | "j" | "k" | "l" | "m" | "n" | "o" | "p"
       | "q" | "r" | "s" | "t" | "u" | "v" | "w"
       | "x" | "y" | "z" ;

digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;

symbol = "[" | "]" | "{" | "}" | "(" | ")" | "<" | ">"
       | "'" | '"' | "=" | "|" | "." | "," | ";" | "-" 
       | "+" | "*" | "?" | "\n" | "\t" | "\r" | "\f" | "\b" ;

character = letter | digit | symbol | "_" | " " ;
identifier = letter , { letter | digit | "_" } ;

S = { " " | "\n" | "\t" | "\r" | "\f" | "\b" } ;

terminal = "'" , character - "'" , { character - "'" } , "'"
         | '"' , character - '"' , { character - '"' } , '"' ;

terminator = ";" | "." ;

term = "(" , S , rhs , S , ")"
     | "[" , S , rhs , S , "]"
     | "{" , S , rhs , S , "}"
     | terminal
     | identifier ;

factor = term , S , "?"
       | term , S , "*"
       | term , S , "+"
       | term , S , "-" , S , term
       | term , S ;

concatenation = ( S , factor , S , "," ? ) + ;
alternation = ( S , concatenation , S , "|" ? ) + ;

rhs = alternation ;
lhs = identifier ;

rule = lhs , S , "=" , S , rhs , S , terminator ;

grammar = ( S , rule , S ) * ;

Pascal

edit

A Pascal-like programming language that allows only assignments can be defined in EBNF as follows:

 (* a simple program syntax in EBNF - Wikipedia *)
 program = 'PROGRAM', white space, identifier, white space, 
            'BEGIN', white space, 
            { assignment, ";", white space },
            'END.' ;
 identifier = alphabetic character, { alphabetic character | digit } ;
 number = [ "-" ], digit, { digit } ;
 string = '"' , { all characters - '"' }, '"' ;
 assignment = identifier , ":=" , ( number | identifier | string ) ;
 alphabetic character = "A" | "B" | "C" | "D" | "E" | "F" | "G"
                      | "H" | "I" | "J" | "K" | "L" | "M" | "N"
                      | "O" | "P" | "Q" | "R" | "S" | "T" | "U"
                      | "V" | "W" | "X" | "Y" | "Z" ;
 digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
 white space = ? white space characters ? ;
 all characters = ? all visible characters ? ;

For example, a syntactically correct program then could be:

 PROGRAM DEMO1
 BEGIN
   A:=3;
   B:=45;
   H:=-100023;
   C:=A;
   D123:=B34A;
   BABOON:=GIRAFFE;
   TEXT:="Hello world!";
 END.

The language can easily be extended with control flows, arithmetical expressions, and Input/Output instructions. Then a small, usable programming language would be developed.

Advantages over BNF

edit

Any grammar defined in EBNF can also be represented in BNF, though representations in the latter are generally lengthier. E.g., options and repetitions cannot be directly expressed in BNF and require the use of an intermediate rule or alternative production defined to be either nothing or the optional production for option, or either the repeated production of itself, recursively, for repetition. The same constructs can still be used in EBNF.

The BNF uses the symbols (<, >, |, ::=) for itself, but does not include quotes around terminal strings. This prevents these characters from being used in the languages, and requires a special symbol for the empty string. In EBNF, terminals are strictly enclosed within quotation marks ("..." or '...'). The angle brackets (<...>) for nonterminals can be omitted.

BNF syntax can only represent a rule in one line, whereas in EBNF a terminating character, the semicolon character ; marks the end of a rule.

Furthermore, EBNF includes mechanisms for enhancements, defining the number of repetitions, excluding alternatives, comments, etc.

Conventions

edit
  1. According to the section 4 of the ISO/IEC 14977 standard, the following conventions are used:
    • Each meta-identifier of Extended BNF is written as one or more words joined together by hyphens. However, joining the words seems to apply only to referencing meta-identifiers outside of the metalanguage itself, as seen in the examples of the standard.
    • A meta-identifier ending with -symbol is the name of a terminal symbol of Extended BNF.
  2. The normal character representing each operator of Extended BNF and its implied precedence is (highest precedence at the top):
     * repetition-symbol
     - except-symbol
     , concatenate-symbol
     | definition-separator-symbol
     = defining-symbol
     ; terminator-symbol
     . terminator-symbol
    
  3. The normal precedence is overridden by the following bracket pairs:
     (* start-comment-symbol          end-comment-symbol *)
     '  first-quote-symbol            first-quote-symbol  '
     (  start-group-symbol              end-group-symbol  )
     [  start-option-symbol            end-option-symbol  ]
     {  start-repeat-symbol            end-repeat-symbol  }
     ?  special-sequence-symbol  special-sequence-symbol  ?
     "  second-quote-symbol          second-quote-symbol  "
    
    The first-quote-symbol is the apostrophe as defined by ISO/IEC 646:1991, that is to say Unicode U+0027 ('); the font used in ISO/IEC 14977:1996(E) renders it very much like the acute, Unicode U+00B4 (), so confusion sometimes arises. However, the ISO Extended BNF standard invokes ISO/IEC 646:1991, "ISO 7-bit coded character set for information interchange", as a normative reference and makes no mention of any other character sets, so formally, there is no confusion with Unicode characters outside the 7-bit ASCII range.

As examples, the following syntax rules illustrate the facilities for expressing repetition:

aa = "A";
bb = 3 * aa, "B";
cc = 3 * [aa], "C";
dd = {aa}, "D";
ee = aa, {aa}, "E";
ff = 3 * aa, 3 * [aa], "F";
gg = {3 * aa}, "G";
hh = (aa | bb | cc), "H";

Terminal strings defined by these rules are as follows:

aa: A
bb: AAAB
cc: C AC AAC AAAC
dd: D AD AAD AAAD AAAAD etc.
ee: AE AAE AAAE AAAAE AAAAAE etc.
ff: AAAF AAAAF AAAAAF AAAAAAF
gg: G AAAG AAAAAAG etc.
hh: AH AAABH CH ACH AACH AAACH

Extensibility

edit

According to the ISO 14977 standard EBNF is meant to be extensible, and two facilities are mentioned. The first is part of EBNF grammar, the special sequence, which is arbitrary text enclosed with question marks. The interpretation of the text inside a special sequence is beyond the scope of the EBNF standard. For example, the space character could be defined by the following rule:

 space = ? ASCII character 32 ?;

The second facility for extension is using the fact that parentheses in EBNF cannot be placed next to identifiers (they must be concatenated with them). The following is valid EBNF:

 something = foo, ( bar );

The following is not valid EBNF:

 something = foo ( bar );

Therefore, an extension of EBNF could use that notation. For example, in a Lisp grammar, function application could be defined by the following rule:

 function application = list( symbol, { expression } );
edit
  • The W3C publishes an EBNF notation.
  • The W3C used a different EBNF to specify the XML syntax.
  • The British Standards Institution published a standard for an EBNF: BS 6154 in 1981.
  • The IETF uses augmented BNF (ABNF), specified in RFC 5234.

See also

edit

References

edit
  1. ^ Scowen, Roger S. (1993). Extended BNF — A generic base standard. Software Engineering Standards Symposium.
  2. ^ International standard (ISO 14977), which is one of many formats for EBNF, is now freely available as Zip-compressed PDF file.
  3. ^ Zaytsev, Vadim (March 26–30, 2012). "BNF Was Here: What Have We Done about the Unnecessary Diversity of Notation for Syntactic Definitions?" (PDF). Proceedings of the 27th Annual ACM Symposium on Applied Computing (SAC '12). Riva del Garda, Italy. p. 1 – via GrammarWare.net.
  4. ^ Pattis, Richard E. (2025-08-05). "EBNF: A Notation to Describe Syntax" (PDF). ICS.UCI.edu. University of California, Irvine. p. 1. Retrieved 2025-08-05.
edit
jdv是什么牌子 手麻是什么引起的 虾滑可以做什么菜 什么是实性结节 流动人口是什么意思
毛毛虫吃什么 半夜鸡叫是什么征兆 鼻翼长痘是什么原因 肠瘘是什么意思 取痣用什么方法最好
梦见媳妇出轨什么预兆 壬午日五行属什么 mar什么意思 灰指甲是什么症状 眼带用什么方法消除
水肿是什么样子 蜂胶是什么 六月十七是什么星座 脚发痒是什么原因 前列腺增大钙化是什么意思
瓜皮是什么意思hcv8jop1ns8r.cn 敢爱敢恨是什么意思hcv8jop5ns1r.cn 爱到极致是什么hcv8jop5ns6r.cn 胃溃疡能吃什么水果xinjiangjialails.com 为什么男生喜欢女生叫爸爸hcv9jop7ns3r.cn
依达拉奉注射功效与作用是什么hcv7jop5ns3r.cn 女人梦见下雪是什么征兆hcv9jop5ns0r.cn 胃病四联疗法是什么药xinmaowt.com 出马仙是什么意思hcv9jop3ns4r.cn 皓五行属什么520myf.com
双肺纹理增强是什么意思chuanglingweilai.com 升结肠憩室是什么意思hcv9jop6ns5r.cn 咳嗽有白痰吃什么药最好hcv7jop5ns6r.cn 吃龟苓膏有什么好处hcv9jop1ns6r.cn 想要什么样的爱luyiluode.com
气短挂什么科hcv8jop6ns2r.cn 为什么拔牙后不能吐口水hcv9jop3ns4r.cn 10.25是什么星座hcv8jop9ns7r.cn ards是什么病hcv8jop6ns8r.cn 黑脸娃娃有什么功效hcv9jop3ns1r.cn
百度