788
Modeling Arithmetic, Computation, and Languages
In BNF, nonterminals are identified by < >, the production arrow becomes
::=, and 0 stands for “or,” identifying various productions having the same lefthand symbol.
In modern times, BNF notation was originally used to define the programming
language Algol (ALGOrithmic Language) in the early 1960s. However, it appears
that a similar notation was used between 400 bce and 200 bce to describe the rules
of Sanskrit grammar.
2
example 56
The markup language HTML (Hypertext Markup Language) is a specific language
for writing documents that will be transmitted across a network and displayed by a
Web browser. The browser parses and interprets the various tags that identify legal
elements of an HTML document and displays the elements accordingly. The structure of each HTML element, such as a TABLE element, is fixed; someone writing
an HTML document using TABLE elements must follow the structure of a TABLE
element as defined in HTML. XML (Extensible Markup Language) is a generalized language for defining specific markup languages, that is, it’s a language
for defining languages. The elements of an XML document can have whatever
structure the user chooses; the user defines these elements in an associated DTD
(Document Type Definition). The DTD can be part of the XML document, or it can
be in a separate file referenced by the XML document (and as such, available for
a number of XML documents to use). The following DTD gives a grammar for an
XML document about manufactured parts, and defines the structure of a “PARTSLIST” element, an “ITEM” element, and so forth.
+
)>






6>
The DTD uses notation similar to that for regular expressions, where * means
zero or more instances, + means one or more instances, and ? means zero instances
or one instance. So in the preceding DTD, a PARTSLIST consists of one or more
ITEMs, and a USEDINLIST consists of zero or more USEDINs. The notation #PCDATA stands for a “parsed character string”. In BNF notation, the grammar becomes
::5 0
::5
::5
::5l 0 0
::5
::5

::5 [as defined in Example 55]
2 “Panini-Backus Form Suggested,” Ingerman, P. Z ., Communications of the ACM, vol. 10, No. 3, 1967.
Précédent

- 805/986

Suivant