Re-designing the config parsers

Daniil Baturin daniil at baturin.org
Fri Sep 12 14:16:28 UTC 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/12/2014 08:44 PM, Marcin Siodelski wrote:
>
>
> On 12/09/14 12:44, Francis Dupont wrote:
>> Tomek Mrugalski writes:
>>> On 11.09.2014 18:01, Francis Dupont wrote:
>>>> Marcin Siodelski writes:
>>>>> I should also explain that we discussed with Tomek a use of Bison
>>>>> framework (http://www.gnu.org/software/bison/) in Kea.
>>>>
>>>> => I heavily used bison (and other LALR(1) parsers) in the past...
>>>> BTW if you want to provide a parser style config, IMHO the best
>>>> available is JunOS from Juniper (far better than the Cisco config).
>>> No, we don't want to change the format. It will stay as it is.
>>> The plan is to refactor/redo the code that parses that input.
>>
>> => so you have bison and equivalent, and for hand written parsers
>> top down vs bottom up.
>>
>
>
> So, a statetement about bottom-up vs top-down doesn't tell me much if I
> can make Bison parse the elements of the configuration in a desired
> order. So for example, the simplified configuration file:
>
> ----
> dhcp-option-fqdn = "foo.marcin.com"
> dhcp-option-fqdn has type FQDN
> ----
>
> defines a value for the new option called "dhcp-option-fqdn" in the
> first line and the option format in the second line.
>
> So, I want the parser to read the format of the option (second line)
> before reading the option data "foo.marcin.com" and I want to report a
> parser error if the "foo.marcin.com" is not a legal fqdn.
>
> Is this configurable?
>
> Marcin
>
> _______________________________________________
> kea-dev mailing list
> kea-dev at lists.isc.org
> https://lists.isc.org/mailman/listinfo/kea-dev
Checking the format and determining the type of tokens is the job of a
lexer, not a parser.
Also, said grammar is not just LALR(1)-unfriendly, it's not even
context-free.

Also #2, top-down and bottom-up are not about the direction the file is
read. :)
They are about building the syntax tree from the top (picking the most
general rule, such as "config ::= expressions" and checking is a
sequence of tokens is compatible with its structure) or from the bottom
(finding token sequences that match more specific rules, such as "option
::= identifier = value" and checking which more general rule it can be a
part of).

- -- 
#!/usr/bin/env perl
@a=split(//, "daniil @ baturin  .  org" );# Daniil Baturin
@b=split(//,q/Px%!+o0Q6lh*7dp$. at 8#%|y{/);while($i<24){$_.=
chr((ord(@b[$i])-ord(@a[$i])+62)%94+32);$i++};print"$_\n"#
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUEwA8AAoJEEcm35UR4K8fyloQAOoKpVXeHQbUF/TEyX5M96vL
jxq9aWZFr26MyctPIVg945bUnAqooVhbe9f1SPwUrIkGmWXEOmpG7s/HNweJWITx
ahNqs3fRTS5L77u0qdDlqGdOPz9q+oi6QLxTaFhlOhf6YOmqqfEx+4CNuNnG75Me
IguN72wWZprCxFPAwyeR0PTgFSMx8Kw7hFr1F3MihVO5AEDacjp74HHcUNj4fNyM
LvgledcKWZfNd2rrhFJFPKG/jOl3u8zpe6fVGgwueRKlOSR4PIdzwjSGXsLh2zjq
1oJe3cR6i42baDKwRzXuzRJFM4js2GAOZsKDWn3BGTHFI8dLt9VhXLJo5QyUMYfj
IUmU6rKt5hxXWdeOGVhZO8v/k7aWh56ZeR58xABjgli8K2Ku+4srIslczZfA98yN
JZ78/gLiC+SKSGxXDXlJVJfpj/VRnOjYzT3oWFiyx4Ss5ed9que6YxwyLdotyPyh
ZAs53ldGAgJfiSd2EWxw7iWlGwQwQ3zk0UD+Lc4AYJJEcYIxH242C02MNOFIaOdV
hQwUh3lwnq8WldLSf9WEP2QdBLDH2Kn2HQNznv2Dl6JcIU9zFQk+PLZEUDB1kBUB
vpj7YaHE3rgqgaaE3Dx3TDLAPFNRiaD+aL3sHo91MlFdrOlVHPfHEf+LBwQrb3W/
OEVrxV+yfpLbXG17xsG7
=eFyl
-----END PGP SIGNATURE-----




More information about the kea-dev mailing list