ABNFのノート
インターネットコミニュティのドキュメント(RFCなど)読む祭、重要なのはABNFの理解。しかし、悩ましいのがABNFの勉強である。RFCが英語であるため、日本語で勉強するといちいち翻訳まで頭の中でしなければならない。 そこで英文をもとに理解し、分かり難い箇所を日本語にしてメモにした。
rfc5234(2008年1月)
Augmented BNF for Syntax Specifications: ABNF
Internet standards track protocol for the Internet community
Rule Naming
Rule names are case insensitive.
The names <rulename>, <Rulename>, <RULENAME>, and <rUlENamE> all
refer to the same rule.
Rule form
name = elements crlf
Trminal Values
b = binary
d = decimal
x = hexadecimal
CR= %d13
CR= %x0D
CRLF= %d13.10
command = "command string"
ABNF strings are case insensitive.
"abc", "Abc", "aBc", "abC", "ABc", "aBC", "AbC", and "ABC".
To specify a rule that is case sensitive.
rulename = %d97.98.99
3. Operators
3.1 Concatenation: Rule1 Rule2 接続
foo = %x61 ; a
bar = %x62 ; b
mumble = foo bar foo
So that the rule <mumble> matches the lowercase string "aba".
3.2. Alternatives: Rule1 / Rule2 変換
foo / bar
will accept <foo> or <bar>.
3.3. Incremental Alternatives: Rule1 =/ Rule2
oldrule =/ additional-alternatives
So that the ruleset
ruleset = alt1 / alt2
ruleset =/ alt3
ruleset =/ alt4 / alt5
is the same as specifying
ruleset = alt1 / alt2 / alt3 / alt4 / alt5
3.4. Value Range Alternatives: %c##-##
DIGIT = %x30-39
is equivalent to:
DIGIT = "0" / "1" / "2" / "3" / "4" / "5" / "6" /
"7" / "8" / "9"
3.5. Sequence Group: (Rule1 Rule2)
elem (foo / bar) blat
matches (elem foo blat) or (elem bar blat)
elem foo / bar blat
matches (elem foo) or (bar blat).
3.6. Variable Repetition: *Rule
<a>*<b>element
where <a> and <b> are optional decimal values, indicating at least
<a> and at most <b> occurrences of the element.
*<element> 0個以上
1*<element> 最低1個許可
3*3<element> 3個正確に許可
1*2<element> 1または2個許可
3.7. Specific Repetition: nRule
<n>element
<n>*<n>element
3.8. Optional Sequence: [RULE]
Square brackets enclose an optional element sequence:
[foo bar]
is equivalent to
*1(foo bar).
3.9. Comment: ; Comment
Rule Naming
Rule names are case insensitive.
The names <rulename>, <Rulename>, <RULENAME>, and <rUlENamE> all
refer to the same rule.
Rule form
name = elements crlf
Trminal Values
b = binary
d = decimal
x = hexadecimal
CR= %d13
CR= %x0D
CRLF= %d13.10
command = "command string"
ABNF strings are case insensitive.
"abc", "Abc", "aBc", "abC", "ABc", "aBC", "AbC", and "ABC".
To specify a rule that is case sensitive.
rulename = %d97.98.99
3. Operators
3.1 Concatenation: Rule1 Rule2 接続
foo = %x61 ; a
bar = %x62 ; b
mumble = foo bar foo
So that the rule <mumble> matches the lowercase string "aba".
3.2. Alternatives: Rule1 / Rule2 変換
foo / bar
will accept <foo> or <bar>.
3.3. Incremental Alternatives: Rule1 =/ Rule2
oldrule =/ additional-alternatives
So that the ruleset
ruleset = alt1 / alt2
ruleset =/ alt3
ruleset =/ alt4 / alt5
is the same as specifying
ruleset = alt1 / alt2 / alt3 / alt4 / alt5
3.4. Value Range Alternatives: %c##-##
DIGIT = %x30-39
is equivalent to:
DIGIT = "0" / "1" / "2" / "3" / "4" / "5" / "6" /
"7" / "8" / "9"
3.5. Sequence Group: (Rule1 Rule2)
elem (foo / bar) blat
matches (elem foo blat) or (elem bar blat)
elem foo / bar blat
matches (elem foo) or (bar blat).
3.6. Variable Repetition: *Rule
<a>*<b>element
where <a> and <b> are optional decimal values, indicating at least
<a> and at most <b> occurrences of the element.
*<element> 0個以上
1*<element> 最低1個許可
3*3<element> 3個正確に許可
1*2<element> 1または2個許可
3.7. Specific Repetition: nRule
<n>element
<n>*<n>element
2DIGIT id a 2-digit number.
3ALPHA is a string of threee alphabetic.
3.8. Optional Sequence: [RULE]
Square brackets enclose an optional element sequence:
[foo bar]
is equivalent to
*1(foo bar).
3.9. Comment: ; Comment
コメント
コメントを投稿