summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/confbase.Y3
-rw-r--r--conf/gen_keywords.m41
-rw-r--r--conf/gen_parser.m412
-rw-r--r--filter/config.Y3
-rw-r--r--nest/config.Y4
-rw-r--r--proto/bgp/config.Y3
-rw-r--r--proto/ospf/config.Y3
-rw-r--r--proto/radv/config.Y2
-rw-r--r--proto/rip/config.Y3
9 files changed, 20 insertions, 14 deletions
diff --git a/conf/confbase.Y b/conf/confbase.Y
index a6b4b1ee..a43a8cca 100644
--- a/conf/confbase.Y
+++ b/conf/confbase.Y
@@ -119,7 +119,6 @@ CF_DECLS
%type <t> text opttext
%type <bs> bytestring
%type <s> symbol
-%type <kw> kw_sym
%type <v> bytestring_text text_or_ipa
%type <x> bytestring_expr
@@ -178,7 +177,7 @@ expr_us:
| expr US { $$ = $1 US_; }
;
-symbol: CF_SYM_UNDEFINED | CF_SYM_KNOWN | kw_sym { $$ = cf_symbol_from_keyword($1); } ;
+symbol: CF_SYM_UNDEFINED | CF_SYM_KNOWN | KEYWORD { $$ = cf_symbol_from_keyword($1); } ;
/* Switches */
diff --git a/conf/gen_keywords.m4 b/conf/gen_keywords.m4
index 0c1dc545..3206c186 100644
--- a/conf/gen_keywords.m4
+++ b/conf/gen_keywords.m4
@@ -28,6 +28,7 @@ m4_divert(-1)')
m4_define(CF_keywd, `m4_ifdef([[CF_tok_$1]],,[[m4_define([[CF_tok_$1]],1)CF_handle_kw($1)]])')
m4_define(CF_KEYWORDS, `m4_define([[CF_toks]],[[]])CF_iterate([[CF_keywd]], [[$@]])m4_ifelse(CF_toks,,,%token[[]]CF_toks
)DNL')
+m4_define(CF_KEYWORDS_EXCLUSIVE, `CF_KEYWORDS($@)')
# CLI commands generate keywords as well
m4_define(CF_CLI, `CF_KEYWORDS(m4_translit($1, [[ ]], [[,]]))
diff --git a/conf/gen_parser.m4 b/conf/gen_parser.m4
index 7a2a9de4..a26af851 100644
--- a/conf/gen_parser.m4
+++ b/conf/gen_parser.m4
@@ -29,11 +29,17 @@ m4_define(CF_END, `m4_divert(-1)')
m4_define(CF_itera, `m4_ifelse($#, 1, [[CF_iter($1)]], [[CF_iter($1)[[]]CF_itera(m4_shift($@))]])')
m4_define(CF_iterate, `m4_define([[CF_iter]], m4_defn([[$1]]))CF_itera($2)')
+m4_define(CF_append, `m4_define([[$1]], m4_ifdef([[$1]], m4_defn([[$1]])[[$3]])[[$2]])')
+
# Keywords act as %token<kw>
-m4_define(CF_keywd, `m4_ifdef([[CF_tok_$1]],,[[m4_define([[CF_tok_$1]],1)m4_define([[CF_toks]],CF_toks $1)]])')
+m4_define(CF_keywd, `m4_ifdef([[CF_tok_$1]],,[[m4_define([[CF_tok_$1]],1)CF_append([[CF_kw_rule]],$1,[[ | ]])m4_define([[CF_toks]],CF_toks $1)]])')
m4_define(CF_KEYWORDS, `m4_define([[CF_toks]],[[]])CF_iterate([[CF_keywd]], [[$@]])m4_ifelse(CF_toks,,,%token<kw>[[]]CF_toks
)DNL')
+m4_define(CF_keywd2, `m4_ifdef([[CF_tok_$1]],,[[m4_define([[CF_tok_$1]],1)m4_define([[CF_toks]],CF_toks $1)]])')
+m4_define(CF_KEYWORDS_EXCLUSIVE, `m4_define([[CF_toks]],[[]])CF_iterate([[CF_keywd2]], [[$@]])m4_ifelse(CF_toks,,,%token<kw>[[]]CF_toks
+)DNL')
+
# CLI commands
m4_define(CF_CLI, `m4_define([[CF_cmd]], cmd_[[]]m4_translit($1, [[ ]], _))DNL
m4_divert(2)CF_KEYWORDS(m4_translit($1, [[ ]], [[,]]))
@@ -55,7 +61,11 @@ m4_undivert(1)DNL
m4_undivert(2)DNL
+%type <kw> KEYWORD
+
%%
+KEYWORD: CF_kw_rule;
+
m4_undivert(3)DNL
%%
diff --git a/filter/config.Y b/filter/config.Y
index e02af182..3bf3a2b6 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -298,12 +298,13 @@ assert_assign(struct f_lval *lval, struct f_inst *expr, const char *start, const
CF_DECLS
+CF_KEYWORDS_EXCLUSIVE(IN)
CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
ACCEPT, REJECT, ERROR,
INT, BOOL, IP, TYPE, PREFIX, RD, PAIR, QUAD, EC, LC,
SET, STRING, BYTESTRING, BGPMASK, BGPPATH, CLIST, ECLIST, LCLIST,
IF, THEN, ELSE, CASE,
- FOR, IN, DO,
+ FOR, DO,
TRUE, FALSE, RT, RO, UNKNOWN, GENERIC,
FROM, GW, NET, MASK, PROTO, SOURCE, SCOPE, DEST, IFNAME, IFINDEX, WEIGHT, GW_MPLS, ONLINK,
PREFERENCE,
diff --git a/nest/config.Y b/nest/config.Y
index ce45d98d..c583dc7f 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -154,8 +154,6 @@ CF_ENUM_PX(T_ENUM_AF, AF_, AFI_, IPV4, IPV6)
CF_GRAMMAR
-kw_sym: MIN | MAX ;
-
/* Setting of router ID */
conf: rtrid ;
@@ -842,7 +840,7 @@ sym_args:
| sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; }
| sym_args PROTOCOL { $$ = $1; $$->type = SYM_PROTO; }
| sym_args TEMPLATE { $$ = $1; $$->type = SYM_TEMPLATE; }
- | sym_args symbol { $$ = $1; $$->sym = $2; }
+ | sym_args CF_SYM_KNOWN { $$ = $1; $$->sym = $2; }
;
diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y
index 218e0d04..ba50446a 100644
--- a/proto/bgp/config.Y
+++ b/proto/bgp/config.Y
@@ -45,9 +45,6 @@ CF_KEYWORDS(CEASE, PREFIX, LIMIT, HIT, ADMINISTRATIVE, SHUTDOWN, RESET, PEER,
CF_GRAMMAR
-/* Workaround for collisions between keywords and symbols */
-kw_sym: ROLE | PEER | PROVIDER | CUSTOMER | RS_SERVER | RS_CLIENT ;
-
proto: bgp_proto '}' ;
bgp_proto_start: proto_start BGP {
diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y
index 4b7d5a36..cfde3a5d 100644
--- a/proto/ospf/config.Y
+++ b/proto/ospf/config.Y
@@ -190,7 +190,8 @@ ospf_check_auth(void)
CF_DECLS
-CF_KEYWORDS(OSPF, V2, V3, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, OSPF_ROUTER_ID)
+CF_KEYWORDS_EXCLUSIVE(V2, V3)
+CF_KEYWORDS(OSPF, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, OSPF_ROUTER_ID)
CF_KEYWORDS(AREA, NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, COST2, RETRANSMIT)
CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, TYPE, BROADCAST, BCAST, DEFAULT)
CF_KEYWORDS(NONBROADCAST, NBMA, POINTOPOINT, PTP, POINTOMULTIPOINT, PTMP)
diff --git a/proto/radv/config.Y b/proto/radv/config.Y
index 9c5e1761..c57752d9 100644
--- a/proto/radv/config.Y
+++ b/proto/radv/config.Y
@@ -50,8 +50,6 @@ CF_ENUM(T_ENUM_RA_PREFERENCE, RA_PREF_, LOW, MEDIUM, HIGH)
CF_GRAMMAR
-kw_sym: CUSTOM | OPTION | VALUE ;
-
proto: radv_proto ;
radv_proto_start: proto_start RADV
diff --git a/proto/rip/config.Y b/proto/rip/config.Y
index 28ee9609..1fab4527 100644
--- a/proto/rip/config.Y
+++ b/proto/rip/config.Y
@@ -32,7 +32,8 @@ rip_check_auth(void)
CF_DECLS
-CF_KEYWORDS(RIP, NG, ECMP, LIMIT, WEIGHT, INFINITY, METRIC, UPDATE, TIMEOUT,
+CF_KEYWORDS_EXCLUSIVE(NG)
+CF_KEYWORDS(RIP, ECMP, LIMIT, WEIGHT, INFINITY, METRIC, UPDATE, TIMEOUT,
GARBAGE, RETRANSMIT, PORT, ADDRESS, MODE, BROADCAST, MULTICAST,
PASSIVE, VERSION, SPLIT, HORIZON, POISON, REVERSE, CHECK, ZERO,
TIME, BFD, AUTHENTICATION, NONE, PLAINTEXT, CRYPTOGRAPHIC, MD5,