summaryrefslogtreecommitdiff
path: root/lib/command_parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'lib/command_parse.y')
-rw-r--r--lib/command_parse.y30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/command_parse.y b/lib/command_parse.y
index f5e42cc304..35c119691b 100644
--- a/lib/command_parse.y
+++ b/lib/command_parse.y
@@ -105,6 +105,9 @@
%token <string> MAC
%token <string> MAC_PREFIX
+/* special syntax, value is irrelevant */
+%token <string> EXCL_BRACKET
+
/* union types for parsed rules */
%type <node> start
%type <node> literal_token
@@ -214,10 +217,12 @@ cmd_token:
{
if ((ctx->currnode = graph_add_edge (ctx->currnode, $1)) != $1)
graph_delete_node (ctx->graph, $1);
+ cmd_token_varname_seqappend($1);
}
| selector
{
graph_add_edge (ctx->currnode, $1.start);
+ cmd_token_varname_seqappend($1.start);
ctx->currnode = $1.end;
}
;
@@ -292,9 +297,8 @@ placeholder_token_real:
placeholder_token:
placeholder_token_real varname_token
{
- struct cmd_token *token = $$->data;
$$ = $1;
- cmd_token_varname_set (token, $2);
+ cmd_token_varname_set ($$->data, $2);
XFREE (MTYPE_LEX, $2);
};
@@ -303,7 +307,7 @@ placeholder_token:
selector: '<' selector_seq_seq '>' varname_token
{
$$ = $2;
- cmd_token_varname_set ($2.end->data, $4);
+ cmd_token_varname_join ($2.end, $4);
XFREE (MTYPE_LEX, $4);
};
@@ -335,11 +339,11 @@ selector: '{' selector_seq_seq '}' varname_token
* 1) this allows "at least 1 of" semantics, which are otherwise impossible
* 2) this would add a start->end->start loop in the graph that the current
* loop-avoidal fails to handle
- * just use [{a|b}] if neccessary, that will work perfectly fine, and reason
+ * just use [{a|b}] if necessary, that will work perfectly fine, and reason
* #1 is good enough to keep it this way. */
loopcheck(ctx, &$$);
- cmd_token_varname_set ($2.end->data, $4);
+ cmd_token_varname_join ($2.end, $4);
XFREE (MTYPE_LEX, $4);
};
@@ -356,6 +360,7 @@ selector_token_seq:
selector_token_seq selector_token
{
graph_add_edge ($1.end, $2.start);
+ cmd_token_varname_seqappend($2.start);
$$.start = $1.start;
$$.end = $2.end;
}
@@ -367,7 +372,20 @@ selector: '[' selector_seq_seq ']' varname_token
{
$$ = $2;
graph_add_edge ($$.start, $$.end);
- cmd_token_varname_set ($2.end->data, $4);
+ cmd_token_varname_join ($2.end, $4);
+ XFREE (MTYPE_LEX, $4);
+}
+;
+
+/* ![option] productions */
+selector: EXCL_BRACKET selector_seq_seq ']' varname_token
+{
+ struct graph_node *neg_only = new_token_node (ctx, NEG_ONLY_TKN, NULL, NULL);
+
+ $$ = $2;
+ graph_add_edge ($$.start, neg_only);
+ graph_add_edge (neg_only, $$.end);
+ cmd_token_varname_join ($2.end, $4);
XFREE (MTYPE_LEX, $4);
}
;