BNF巴克斯范式

更新时间:2023-05-19 12:50:21 阅读: 评论:0

Backus–Naur form
In computer science, Backus–Naur form (BNF) is a metasyntax ud to express context-free grammars: that is, a formal way to describe formal languages. John Backus and Peter Naur developed a context free grammar to define the syntax of a programming language by using two ts of rules: i.e., Lexical rules and Syntactic rules.
BNF is widely ud as a notation什么心什么意 for the grammars of computer programming languages, instruction ts and communication protocols, as well as a notation for reprenting parts of natural language grammars. Many textbooks for programming language theory and/or mantics document the programming language in BNF.
There are many extensions of and variants on BNF.
Contents
1 History
2 Introduction
3 Example
4 Furtherexamples
5 Variants
6 Seealso
7 References
8 Externallinks
History
John Backus约翰.班卡斯created the notation in order to express the grammar of ALGOL. At the first World Computer Congress, which took place in Paris in 1959, Backus prented "The syntax and mantics of the propod international algebraic language of the Zurich ACM-GAMM Conference", a formal description of the IAL which was later called ALGOL 58宁波南塘老街. The formal language he prented was bad on Emil Post's productio
n system. Generative grammars were an active subject of mathematical study, e.g. by Noam Chomsky, who was applying them to the grammar of natural language.[1][2]
Peter Naur彼得诺尔(ALGOL 60, 1963) identified Backus's notation as Backus Normal Form, and simplified it to minimize the character t ud, and, at the suggestion of Donald Knuth, his name was added in recognition of his contribution, his initial replacing the N for "Normal" since, Knuth argued, the BNF is "not a normal form in any n".[3] The Backus–Naur Form or BNF grammars have significant similarities to Pānini's grammar rules, and the notation is sometimes also referred to as Panini–Backus Form.[4]
Introduction
A BNF specification is a t of derivation rules, written as
<symbol> ::= <expression with symbols>
where <symbol> is a nonterminal, and the expression consists of quences of symbols
and/or quences parated by the vertical bar, '|', indicating a choice, the whole being a possible substitution for the symbol on the left. Symbols that never appear on a left side are terminals.
Example
As an example, consider this possible BNF for a U.S. postal address:
<postal-address> ::= <name-part> <street-address> <zip-part>
<name-part> ::= <personal-part> <last-name> <opt-jr-part> <EOL>
            |  <personal-part> <name-part>
<personal-part> ::= <first-name> | <initial> "."
<street-address> ::= <opt-apt-num> <hou-num> <street-name> <EOL>
<zip-part> ::= <town-name> "," <state-code> <ZIP-code> <EOL>
实践论全文<opt-jr-part> ::= "Sr." | "Jr." | <roman-numeral> | ""
好看的卷发
This translates into English as:
梦见鱼死了是什么意思A postal address consists of a name-part, followed by a street-address part, followed by a zip-code part.
A name-part consists of either: a personal-part followed by a last name followed by an optional "jr-part" (Jr., Sr., or dynastic number) and end-of-line, or a personal part followed by a name part (this rule illustrates the u of recursion in BNFs, covering the ca of people who u multiple first and middle names and/or initials).
A personal-part consists of either a first name or an initial followed by a dot.
A street address consists of an optional apartment specifier, followed by a hou number, followed by a street name, followed by an end-of-line.
A zip-part consists of a town-name, followed by a comma, followed by a 基金转换state code, followed by a ZIP-code followed by an end-of-line.
Note that many things (such as the format of a first-name, apartment specifier, ZIP-code, and Roman numeral) are left unspecified here. If necessary, they may be described using additional BNF rules.
Further examples
BNF's syntax itlf may be reprented with a BNF like the following:
练习瑜伽的好处
<syntax> ::= <rule> | <rule> <syntax>
<rule> ::= <opt-whitespace> "<" <rule-name> ">" <opt-whitespace> "::="桑葚果酒
<opt-whitespace> <expression> <line-end>
<opt-whitespace> ::= " " <opt-whitespace> | "" 
<expression> ::= <list> | <list> "|" <expression>
<line-end> ::= <opt-whitespace> <EOL> | <line-end> <line-end>
<list> ::= <term> | <term> <opt-whitespace> <list>
<term> ::= <literal> | "<" <rule-name> ">"
<literal> ::= '"' <text> '"' | "'" <text> "'"

本文发布于:2023-05-19 12:50:21,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/694564.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:老街   实践论   好看   转换   练习   宁波
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图