bootconfig: Add EBNF definition and more tests
Subsystems (3)
Masami Hiramatsu (Google)
maintainercover bootconfig: Add EBNF definition and more tests
Hi,
Here is a pair of patches to add the EBNF definition and more parser test cases of bootconfig to formally define the bootconfig syntax.
---
Masami Hiramatsu (Google) (2):
Documentation: bootconfig: Add EBNF definiton of bootconfig
bootconfig: Add more test samples
Documentation/admin-guide/bootconfig.rst | 15 +++++++++++++++ .../samples/bad-array-comment-delimiter.bconf | 2 ++ tools/bootconfig/samples/bad-dot-middle.bconf | 1 + .../bootconfig/samples/bad-invalid-operator.bconf | 1 + tools/bootconfig/samples/bad-key-dot-end.bconf | 1 + tools/bootconfig/samples/bad-unclosed-quote.bconf | 1 + .../samples/bad-unexpected-close-brace.bconf | 4 ++++ .../samples/exp-good-dot-with-block.bconf | 1 + .../bootconfig/samples/exp-good-empty-block.bconf | 1 + .../samples/exp-good-empty-value-sep.bconf | 3 +++ .../samples/exp-good-quoted-newline.bconf | 2 ++ tools/bootconfig/samples/good-dot-with-block.bconf | 3 +++ tools/bootconfig/samples/good-empty-block.bconf | 1 + .../bootconfig/samples/good-empty-value-sep.bconf | 3 +++ tools/bootconfig/samples/good-quoted-newline.bconf | 2 ++ 15 files changed, 41 insertions(+) create mode 100644 tools/bootconfig/samples/bad-array-comment-delimiter.bconf create mode 100644 tools/bootconfig/samples/bad-dot-middle.bconf create mode 100644 tools/bootconfig/samples/bad-invalid-operator.bconf create mode 100644 tools/bootconfig/samples/bad-key-dot-end.bconf create mode 100644 tools/bootconfig/samples/bad-unclosed-quote.bconf create mode 100644 tools/bootconfig/samples/bad-unexpected-close-brace.bconf create mode 100644 tools/bootconfig/samples/exp-good-dot-with-block.bconf create mode 100644 tools/bootconfig/samples/exp-good-empty-block.bconf create mode 100644 tools/bootconfig/samples/exp-good-empty-value-sep.bconf create mode 100644 tools/bootconfig/samples/exp-good-quoted-newline.bconf create mode 100644 tools/bootconfig/samples/good-dot-with-block.bconf create mode 100644 tools/bootconfig/samples/good-empty-block.bconf create mode 100644 tools/bootconfig/samples/good-empty-value-sep.bconf create mode 100644 tools/bootconfig/samples/good-quoted-newline.bconf
--
Masami Hiramatsu (Google) <[email protected]>
Masami Hiramatsu (Google)
maintainerPATCH 1/2 Documentation: bootconfig: Add EBNF definiton of bootconfig
From: Masami Hiramatsu (Google) <[email protected]>
Add the EBNF definition to Documentation/admin-guide/bootconfig.rst to formally define the bootconfig syntax.
--- Documentation/admin-guide/bootconfig.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Documentation/admin-guide/bootconfig.rst +15 -0
@@ -22,6 +22,21 @@ The boot config syntax is a simple structured key-value. Each key consists of dot-connected-words, and key and value are connected by ``=``. The value string has to be terminated by the following delimiters described below. +The syntax is defined in EBNF as follows:: + + Config = { Statement } + Statement = [ Key [ Assignment | Block ] | Comment ] ( "\n" | ";" ) + Assignment = ( "=" | "+=" | ":=" ) ValueList + ValueList = [ Value { "," [ { ( Comment | "\n" ) } ] Value } ] + Block = "{" { Statement } "}" + Key = Word { "." Word } + Word = [a-zA-Z0-9_-]+ + Value = QuotedValue | UnquotedValue + QuotedValue = "\"" { any_character_except_double_quote } "\"" + | "'" { any_character_except_single_quote } "'" + UnquotedValue = { any_printable_character_except_delimiters } + Comment = "#" { any_character_except_newline } + Each key word must contain only alphabets, numbers, dash (``-``) or underscore (``_``). And each value only contains printable characters or spaces except for delimiters such as semi-colon (``;``), new-line (``\n``), comma (``,``),
Masami Hiramatsu (Google)
maintainerPATCH 2/2 bootconfig: Add more test samples
In reply to Masami Hiramatsu (Google)From: Masami Hiramatsu (Google) <[email protected]>
Add more test samples for edge cases (empty block, quoted newline, various error cases) to tools/bootconfig/samples/.
--- .../samples/bad-array-comment-delimiter.bconf | 2 ++ tools/bootconfig/samples/bad-dot-middle.bconf | 1 + .../bootconfig/samples/bad-invalid-operator.bconf | 1 + tools/bootconfig/samples/bad-key-dot-end.bconf | 1 + tools/bootconfig/samples/bad-unclosed-quote.bconf | 1 + .../samples/bad-unexpected-close-brace.bconf | 4 ++++ .../samples/exp-good-dot-with-block.bconf | 1 + .../bootconfig/samples/exp-good-empty-block.bconf | 1 + .../samples/exp-good-empty-value-sep.bconf | 3 +++ .../samples/exp-good-quoted-newline.bconf | 2 ++ tools/bootconfig/samples/good-dot-with-block.bconf | 3 +++ tools/bootconfig/samples/good-empty-block.bconf | 1 + .../bootconfig/samples/good-empty-value-sep.bconf | 3 +++ tools/bootconfig/samples/good-quoted-newline.bconf | 2 ++ 14 files changed, 26 insertions(+) create mode 100644 tools/bootconfig/samples/bad-array-comment-delimiter.bconf create mode 100644 tools/bootconfig/samples/bad-dot-middle.bconf create mode 100644 tools/bootconfig/samples/bad-invalid-operator.bconf create mode 100644 tools/bootconfig/samples/bad-key-dot-end.bconf create mode 100644 tools/bootconfig/samples/bad-unclosed-quote.bconf create mode 100644 tools/bootconfig/samples/bad-unexpected-close-brace.bconf create mode 100644 tools/bootconfig/samples/exp-good-dot-with-block.bconf create mode 100644 tools/bootconfig/samples/exp-good-empty-block.bconf create mode 100644 tools/bootconfig/samples/exp-good-empty-value-sep.bconf create mode 100644 tools/bootconfig/samples/exp-good-quoted-newline.bconf create mode 100644 tools/bootconfig/samples/good-dot-with-block.bconf create mode 100644 tools/bootconfig/samples/good-empty-block.bconf create mode 100644 tools/bootconfig/samples/good-empty-value-sep.bconf create mode 100644 tools/bootconfig/samples/good-quoted-newline.bconf
tools/bootconfig/samples/bad-array-comment-delimiter.bconf new file +2 -0
@@ -0,0 +1,2 @@ +key = 1 # comment + , 2 # Error: comment between value and its comma delimiter
tools/bootconfig/samples/bad-dot-middle.bconf new file +1 -0
@@ -0,0 +1 @@ +key..word = value # Double dots are not allowed
tools/bootconfig/samples/bad-invalid-operator.bconf new file +1 -0
@@ -0,0 +1 @@ +key ?= value # Unsupported operator
tools/bootconfig/samples/bad-key-dot-end.bconf new file +1 -0
@@ -0,0 +1 @@ +key. = value # Key cannot end with a dot
tools/bootconfig/samples/bad-unclosed-quote.bconf new file +1 -0
@@ -0,0 +1 @@ +key = "unclosed quote
tools/bootconfig/samples/bad-unexpected-close-brace.bconf new file +4 -0
@@ -0,0 +1,4 @@ +key { + subkey = value +} +} # Extra closing brace
tools/bootconfig/samples/exp-good-dot-with-block.bconf new file +1 -0
@@ -0,0 +1 @@ +key.subkey.subsubkey = "value";
tools/bootconfig/samples/exp-good-empty-block.bconf new file +1 -0
@@ -0,0 +1 @@ +key;
tools/bootconfig/samples/exp-good-empty-value-sep.bconf new file +3 -0
@@ -0,0 +1,3 @@ +key1 = ""; +key2 = ""; +key3 = "";
tools/bootconfig/samples/exp-good-quoted-newline.bconf new file +2 -0
@@ -0,0 +1,2 @@ +key = "value +that spans multiple lines";
tools/bootconfig/samples/good-dot-with-block.bconf new file +3 -0
@@ -0,0 +1,3 @@ +key.subkey { + subsubkey = value +} # Combination of dot-notation and block syntax
tools/bootconfig/samples/good-empty-block.bconf new file +1 -0
@@ -0,0 +1 @@ +key { } # Empty block should be allowed and ignored
tools/bootconfig/samples/good-empty-value-sep.bconf new file +3 -0
@@ -0,0 +1,3 @@ +key1 = ; +key2 = +key3 = # comment
tools/bootconfig/samples/good-quoted-newline.bconf new file +2 -0
@@ -0,0 +1,2 @@ +key = "value +that spans multiple lines" # Quoted values can contain newlines
Masami Hiramatsu (Google)
maintainerRe: [PATCH 1/2] Documentation: bootconfig: Add EBNF definiton of bootconfig
In reply to Masami Hiramatsu (Google)Quoted 5 lines · On Sat, 14 Mar 2026 18:06:40 +0900 "Masami Hiramatsu (Google)"…
From: Masami Hiramatsu (Google) <[email protected]>
Add the EBNF definition to
Documentation/admin-guide/bootconfig.rstto formally define the bootconfig syntax.
Wait, I rethink it may be better to be a separated section so that it can be referred easily.
Let me update it.
Thanks,
Quoted 32 lines
Signed-off-by Masami Hiramatsu (Google) <[email protected]>--- Documentation/admin-guide/bootconfig.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+)Documentation/admin-guide/bootconfig.rst +15
-0@@ -22,6 +22,21 @@ The boot config syntax is a simple structured key-value. Each key consists of dot-connected-words, and key and value are connected by ``=``. The value string has to be terminated by the following delimiters described below. +The syntax is defined in EBNF as follows:: + + Config = { Statement } + Statement = [ Key [ Assignment | Block ] | Comment ] ( "\n" | ";" ) + Assignment = ( "=" | "+=" | ":=" ) ValueList + ValueList = [ Value { "," [ { ( Comment | "\n" ) } ] Value } ] + Block = "{" { Statement } "}" + Key = Word { "." Word } + Word = [a-zA-Z0-9_-]+ + Value = QuotedValue | UnquotedValue + QuotedValue = "\"" { any_character_except_double_quote } "\"" + | "'" { any_character_except_single_quote } "'" + UnquotedValue = { any_printable_character_except_delimiters } + Comment = "#" { any_character_except_newline } + Each key word must contain only alphabets, numbers, dash (``-``) or underscore (``_``). And each value only contains printable characters or spaces except for delimiters such as semi-colon (``;``), new-line (``\n``), comma (``,``),
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>