自己开发计算器(0)-扩展巴科斯范式(EBNF)
来源:西尖山笔记 责任编辑:栏目编辑 发表时间:2013-07-02 02:53 点击:次
基本信息
扩展巴科斯-瑙尔范式(EBNF)是表达作为描述计算机编程语言和形式语言的正规方式的上下文无关文法的元语法符号表示法。它是基本巴科斯范式(BNF)元语法符号表示法的一种扩展。
它最初由尼古拉斯·沃斯开发,最常用的 EBNF 变体由标准,特别是 ISO-14977 所定义。
在这里我们介绍EBNF的一种形式,它由W3C定义。我们可以在XML Path Language (XPath) 2.0 (Second Edition)中找到它的细节,内容如下
A.1.1 Notation
The following definitions will be helpful in defining precisely this exposition. [Definition: Each rule in the grammar defines one symbol, using the following format:
symbol ::= expression ] [Definition: A terminal is a symbol or string or pattern that can appear in the right-hand side of a rule, but never appears on the left hand side in the main grammar, although it may appear on the left-hand side of a rule in the grammar for terminals.]
The following constructs are used to match strings of one or more characters in a terminal:
[a-zA-Z]
matches any Char with a value in the range(s) indicated (inclusive). [abc]
matches any Char with a value among the characters enumerated. [^abc]
matches any Char with a value not among the characters given. "string"
matches the sequence of characters that appear inside the double quotes. 'string'
matches the sequence of characters that appear inside the single quotes. [http://www.w3.org/TR/REC-example/#NT-Example] matches any string matched by the production defined in the external specification as per the provided reference.
Patterns (including the above constructs) can be combined with grammatical operators to form more complex patterns, matching more complex sets of character strings. In the examples that follow, A and B represent (sub-)patterns. (A)
A is treated as a unit and may be combined as described in this list. 相关新闻>>最新推荐更多>>>
|