解释 RFC 2141 中 NID 的 BNF 语法
我无法理解 BNF 语法https://www.rfc-editor.org/rfc/rfc2141" rel="nofollow noreferrer">RFC2141。
该行是
。我认为这意味着
是字符串的符号,受到两个规则的约束:
- 字符串必须以任何
字符。的单个出现开始; - 该字符后面可能出现 0-31 次*任何
字符。
我读得正确吗?因为,如果我是的话,其中的一些含义会有点令人困惑。
*相当于“可选地,出现 1-31 次
RFC2141 是:
<NID> ::= <let-num> [ 1,31<let-num-hyp> ]
<let-num-hyp> ::= <upper> | <lower> | <number> | "-"
<let-num> ::= <upper> | <lower> | <number>
<upper> ::= "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"
<lower> ::= "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"
<number> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
"8" | "9"
I am having trouble understanding some BNF syntax from RFC2141.
The line is <NID> ::= <let-num> [ 1,31<let-num-hyp> ]
. I think it means that <NID>
is a symbol for a string, with constrained by two rules:
- The string must be begin with a single occurence of any of the
<let-num>
characters. - This character may be followed by 0-31 occurrences* of any of the
<let-num-hyp>
characters.
Am I reading this correctly? Because, if I am, some of the implications are a bit confusing.
*equivalent to "optionally, 1-31 occurrences
The complete BNF syntax for a <NID>
(Namespace Identifier) in RFC2141 is:
<NID> ::= <let-num> [ 1,31<let-num-hyp> ]
<let-num-hyp> ::= <upper> | <lower> | <number> | "-"
<let-num> ::= <upper> | <lower> | <number>
<upper> ::= "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"
<lower> ::= "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"
<number> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
"8" | "9"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你已经正确地解释了它。有哪些令人困惑的含义?
表示
出现一次(可选),后跟最多 31 次
。考虑到其他定义,这意味着一个至少一个字符、最多 32 个字符的字符串,由任意大小写的字母、数字和连字符组成,第一个字符不允许是连字符。
You've interpreted it correctly. What are the confusing implications?
means one occurrence of
<let-num>
followed optionally by up to 31 occurrences of<let-num-hyp>
.Taking into account the other definitions, this means a string of at least one character and at most 32 characters, consisting of letters of either case, numerals, and hyphens, with the first character not allowed to be a hyphen.