解释 RFC 2141 中 NID 的 BNF 语法

发布于 2024-11-17 09:52:55 字数 1519 浏览 3 评论 0原文

我无法理解 BNF 语法https://www.rfc-editor.org/rfc/rfc2141" rel="nofollow noreferrer">RFC2141。

该行是 ; ::=; [ 1,31; ]。我认为这意味着 是字符串的符号,受到两个规则的约束:

  1. 字符串必须以任何 的单个出现开始; 字符。
  2. 该字符后面可能出现 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:

  1. The string must be begin with a single occurence of any of the <let-num> characters.
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

述情 2024-11-24 09:52:55

你已经正确地解释了它。有哪些令人困惑的含义?

<NID> ::= <let-num> [ 1,31<let-num-hyp> ]

表示 出现一次(可选),后跟最多 31 次

考虑到其他定义,这意味着一个至少一个字符、最多 32 个字符的字符串,由任意大小写的字母、数字和连字符组成,第一个字符不允许是连字符。

You've interpreted it correctly. What are the confusing implications?

<NID> ::= <let-num> [ 1,31<let-num-hyp> ]

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文