Re: [RFC PATCH v2 01/74] dtc-parser.y: Avoid an empty proplist

From: David Gibson

Date: Wed Oct 14 2026 - 09:06:14 EST


On Wed, Aug 26, 2026 at 11:48:30AM +0200, Herve Codina wrote:
> In the dts parser grammar, a nodedef is defined by
> '{' proplist subnodes '}' ';'
> with both proplist and subnodes that can be empty lists.
>
> Having multiple possible empty list can lead to Bison warnings such as
> warning: 4 shift/reduce conflicts [-Wconflicts-sr]
> warning: 1 reduce/reduce conflict [-Wconflicts-rr]
>
> This will happen as soon as a new list (which also could be empty) is
> added in the nodedef definition.
>
> The simpler way to remove those warning and thus have a robust parsing
> is to avoid multiple empty lists.
>
> Update the proplist definition and nodedef definition to avoid those
> multiple empty lists. Instead of allowing a proplist to be an empty
> list, force the list to be a non empty one and update the nodedef to
> handle explicitly the absence of the proplist to support the case where
> no properties are available, i.e. the case of a node composed only of
> sub-nodes.
>
> This doesn't change the functional behavior.
>
> Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>

This seems a reasonable change in isolation from the rest of the
series. Applied.

Note, that if it comes to it, I'm not necessarily opposed to adding
the %glr-parser option to Bison. We used to use it in the past, until
we figured out an easy way to avoid it in 7b3fb789d2cd ("DTC: Remove
the need for the GLR Parser."). The Tomita GLR algorithm is well
established and the computational cost is pretty much irrelevant in
context, so I'd generally prioritise keeping the grammar simple to
read for a human and convenient for the rest of the code over making
sure it's stricly LALR(1).

> ---
> dtc-parser.y | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/dtc-parser.y b/dtc-parser.y
> index 4d5eece5..e47f80d4 100644
> --- a/dtc-parser.y
> +++ b/dtc-parser.y
> @@ -267,12 +267,16 @@ nodedef:
> {
> $$ = build_node($2, $3, &@$);
> }
> + | '{' subnodes '}' ';'
> + {
> + $$ = build_node(NULL, $2, &@$);
> + }
> ;
>
> proplist:
> - /* empty */
> + propdef
> {
> - $$ = NULL;
> + $$ = chain_property($1, NULL);
> }
> | proplist propdef
> {
> --
> 2.55.0
>
>

--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature