[kea-dev] trailing commas and unknown_map_entry

Francis Dupont fdupont at isc.org
Tue Jun 3 10:36:02 UTC 2025


Gregor Kling writes:

> 1) Just to be sure rules like that:
> 
> global_params ::= global_param
>                 | global_params "," global_param
>                 | global_params ","
>
> specifically: | global_params "," deals with the kea json format which 
> can do trailing commas,
>
> which standard json can not?

=> yes, trailing commas are forbidden by the JSON standard but we decided
to relax this rule in (quoting ChangeLog):
1972.   [func]          andrei
        Kea servers now can accept trailing commas in file
        configurations. While parsing, a warning is printed with the
        location of the comma to give the user the ability to correct
        a mistake.
        (Gitlab #2084)

> 2) unknown_map_entry ::= STRING ":" strikes me a little odd.
> 
> It is allowed to have - "something":  - with no value part?

=> unknown_map_entry catches map entries with an unknown keyword.
Of course - "something": - with no value part is wrong in two different
ways (unknown keyword and no required value part) so the choice of
the error can be considered as arbitrary (in fact not so arbitrary because
the parser is a LALR(1) and error rules can easily trigger conflicts...).

I recommend to look at the full grammar with actions
(src/bin/dhcp4/dhcp4_parser.yy) where error rules are more easy to
distinguish from regular rules. And you can also see extra features
as contexts and types. Bison documentation is useful too because
it provides its own error stuff (for instance the unknown_map_entry
is used to bypass the bison error and emit a more user friendly message).

Regards

Francis Dupont <fdupont at isc.org>


More information about the kea-dev mailing list