From gregor.kling at its.thm.de Tue Jun 3 06:52:48 2025 From: gregor.kling at its.thm.de (Gregor Kling) Date: Tue, 3 Jun 2025 08:52:48 +0200 Subject: [kea-dev] trailing commas and unknown_map_entry Message-ID: Hello, I am studying the grammar for dhcp4. 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? 2) unknown_map_entry ::= STRING ":" strikes me a little odd. It is allowed to have - "something":? - with no value part? gg -- Gregor Kling Abteilung ITS, Sachgebiet ITS-N Technische Hochschule Mittelhessen University of Applied Sciences Tel: 0641/309-1292 E-Mail: gregor.kling at its.thm.de From fdupont at isc.org Tue Jun 3 10:36:02 2025 From: fdupont at isc.org (Francis Dupont) Date: Tue, 03 Jun 2025 10:36:02 +0000 Subject: [kea-dev] trailing commas and unknown_map_entry In-Reply-To: References: Message-ID: <20250603103602.086E599A97@bikeshed.isc.org> 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