%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
;
/*
- * 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); }
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));