]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Conf: Silence grammar conflict warning
authorOndrej Zajicek <santiago@crfreenet.org>
Wed, 21 May 2025 15:02:28 +0000 (17:02 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Wed, 21 May 2025 15:02:28 +0000 (17:02 +0200)
There is one harmless grammar ambiquity that is hard to avoid, so let
just document it and silence it.

conf/confbase.Y
filter/config.Y
nest/config.Y

index c7649c3e7515559e4b9b9640a3a3f35cf6aca811..b2ba3cafbfbb65a79727bfb2643c9a3536899fbe 100644 (file)
@@ -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
index 3a9af0586f6c071451a2c090287fde5918364796..562530e2d154e84db07f88ecedc7b0a80185e484 100644 (file)
@@ -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); }
index aa1d7c393e053db226f87247318a02d3df527e25..4a3b45b507c60dbdcfe868a358a768187f17ded1 100644 (file)
@@ -652,6 +652,20 @@ CF_CLI_OPT(SHOW ROUTE PROTOCOL, <p>)
 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));