From 488e144d02946974f585ec05a77057c35a6e65ba Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 21 May 2025 17:02:28 +0200 Subject: [PATCH] Conf: Silence grammar conflict warning There is one harmless grammar ambiquity that is hard to avoid, so let just document it and silence it. --- conf/confbase.Y | 3 +++ filter/config.Y | 7 ++++++- nest/config.Y | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/conf/confbase.Y b/conf/confbase.Y index c7649c3e7..b2ba3cafb 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -165,6 +165,9 @@ CF_DECLS %start config +/* See r_args */ +%expect 2 + CF_KEYWORDS(DEFINE, ON, OFF, YES, NO, S, MS, US, PORT, VPN, MPLS, FROM, MAX, AS) CF_GRAMMAR diff --git a/filter/config.Y b/filter/config.Y index 3a9af0586..562530e2d 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -622,7 +622,12 @@ cmds_int: cmd_prep ; /* - * Complex types, their bison value is struct f_val + * IP prefixes, their value is struct f_val + * + * Note that there is an ambiquity as 192.0.2.0/24 can be parsed either as an IP + * prefix (net_ip4_), or as an IP address divided by a number (term). We force + * the first interpretation by setting IP4 -> fipa reduction as lower priority + * than the token '/' (in net_ip4_). */ fipa: IP4 %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.ip = ipa_from_ip4($1); } diff --git a/nest/config.Y b/nest/config.Y index aa1d7c393..4a3b45b50 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -652,6 +652,20 @@ CF_CLI_OPT(SHOW ROUTE PROTOCOL,

) CF_CLI_OPT(SHOW ROUTE STATS) CF_CLI_OPT(SHOW ROUTE COUNT) +/* + * Note that there is an ambiguity in show route grammar, as: + * show route where xyz = 10:10 192.0.2.0/24 + * can be parsed in these two ways: + * show route where xyz = (10:10 192.0.2.0/24) + * show route where (xyz = 10:10) 192.0.2.0/24 + * The parser defaults to the first way. + * + * We cannot really do much with this (outside of changing the grammar) as Bison + * precendence mechanisms that would require to define global precedence of IP4 + * / IP6 terminals, which could have plenty of unexpected effects, including + * masking of other grammar ambiquities. So we just silence it with %expect. + */ + r_args: /* empty */ { $$ = cfg_allocz(sizeof(struct rt_show_data)); -- 2.47.2