summaryrefslogtreecommitdiff
path: root/usr.sbin/ifstated/parse.y
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2005-02-03 17:51:13 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2005-02-03 17:51:13 +0000
commitde5dcfbcc9ef1f839679646c838677f7e882f3ed (patch)
treece53bdcd055772dd225825bb5f4c41466501636f /usr.sbin/ifstated/parse.y
parent0a13b4121a45b492c104e476ae5bac68dea0cce4 (diff)
Simplify the ifstated syntax:
"carp0 link up" => carp0.link.up "and" => && "or" => || * Allow one line actions after if statements without braces. * Remove unecessary parentheses in the example config. ok mcbride@
Diffstat (limited to 'usr.sbin/ifstated/parse.y')
-rw-r--r--usr.sbin/ifstated/parse.y24
1 files changed, 14 insertions, 10 deletions
diff --git a/usr.sbin/ifstated/parse.y b/usr.sbin/ifstated/parse.y
index 722dfd062f0..76f65bebdf8 100644
--- a/usr.sbin/ifstated/parse.y
+++ b/usr.sbin/ifstated/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.7 2004/04/28 01:00:50 deraadt Exp $ */
+/* $OpenBSD: parse.y,v 1.8 2005/02/03 17:51:12 mpf Exp $ */
/*
* Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org>
@@ -232,12 +232,16 @@ action : RUN STRING {
action, entries);
action->parent = curaction;
curaction = action;
- } expr optnl '{' optnl action_l '}' {
+ } expr action_block {
set_expression_depth(curaction->act.c.expression, 0);
curaction = curaction->parent;
}
;
+action_block : optnl '{' optnl action_l '}'
+ | optnl action
+ ;
+
action_l : action_l action nl
| action nl
;
@@ -255,13 +259,13 @@ init : INIT {
}
;
-if_test : interface LINK UP {
+if_test : interface '.' LINK '.' UP {
$$ = new_ifstate($1, IFSD_LINKUP);
}
- | interface LINK DOWN {
+ | interface '.' LINK '.' DOWN {
$$ = new_ifstate($1, IFSD_LINKDOWN);
}
- | interface LINK UNKNOWN {
+ | interface '.' LINK '.' UNKNOWN {
$$ = new_ifstate($1, IFSD_LINKUNKNOWN);
}
;
@@ -386,8 +390,8 @@ lookup(char *s)
{
/* this has to be sorted always */
static const struct keywords keywords[] = {
+ { "&&", AND},
{ "added", ADDED},
- { "and", AND},
{ "down", DOWN},
{ "every", EVERY},
{ "if", IF},
@@ -395,13 +399,13 @@ lookup(char *s)
{ "init-state", INITSTATE},
{ "link", LINK},
{ "loglevel", LOGLEVEL},
- { "or", OR},
{ "removed", REMOVED},
{ "run", RUN},
{ "set-state", SETSTATE},
{ "state", STATE},
{ "unknown", UNKNOWN},
- { "up", UP}
+ { "up", UP},
+ { "||", OR}
};
const struct keywords *p;
@@ -580,9 +584,9 @@ top:
(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
x != '{' && x != '}' && \
x != '!' && x != '=' && x != '#' && \
- x != ','))
+ x != ',' && x != '.'))
- if (isalnum(c) || c == ':' || c == '_') {
+ if (isalnum(c) || c == ':' || c == '_' || c == '&' || c == '|') {
do {
*p++ = c;
if ((unsigned)(p-buf) >= sizeof(buf)) {