sbin/hammer: Fix whitespace alignment changed by e0d7dd09
[dragonfly.git] / libexec / dma / aliases_parse.y
bloba5a9e7b32f071aa0ca3026938296dea8f8847ef8
1 %{
3 #include <err.h>
4 #include <string.h>
5 #include <syslog.h>
6 #include "dma.h"
8 extern int yylineno;
9 static void yyerror(const char *);
10 int yywrap(void);
11 int yylex(void);
13 static void
14 yyerror(const char *msg)
16 /**
17 * Because we do error '\n' below, we need to report the error
18 * one line above of what yylineno points to.
20 syslog(LOG_CRIT, "aliases line %d: %s", yylineno - 1, msg);
21 fprintf(stderr, "aliases line %d: %s\n", yylineno - 1, msg);
24 int
25 yywrap(void)
27 return (1);
32 %union {
33 char *ident;
34 struct stritem *strit;
35 struct alias *alias;
38 %token <ident> T_IDENT
39 %token T_ERROR
40 %token T_EOF 0
42 %type <strit> dests
43 %type <alias> alias aliases
47 start : aliases T_EOF
49 LIST_FIRST(&aliases) = $1;
52 aliases : /* EMPTY */
54 $$ = NULL;
56 | alias aliases
58 if ($2 != NULL && $1 != NULL)
59 LIST_INSERT_AFTER($2, $1, next);
60 else if ($2 == NULL)
61 $2 = $1;
62 $$ = $2;
66 alias : T_IDENT ':' dests '\n'
68 struct alias *al;
70 if ($1 == NULL)
71 YYABORT;
72 al = calloc(1, sizeof(*al));
73 if (al == NULL)
74 YYABORT;
75 al->alias = $1;
76 SLIST_FIRST(&al->dests) = $3;
77 $$ = al;
79 | error '\n'
81 YYABORT;
85 dests : T_IDENT
87 struct stritem *it;
89 if ($1 == NULL)
90 YYABORT;
91 it = calloc(1, sizeof(*it));
92 if (it == NULL)
93 YYABORT;
94 it->str = $1;
95 $$ = it;
97 | T_IDENT ',' dests
99 struct stritem *it;
101 if ($1 == NULL)
102 YYABORT;
103 it = calloc(1, sizeof(*it));
104 if (it == NULL)
105 YYABORT;
106 it->str = $1;
107 SLIST_NEXT(it, next) = $3;
108 $$ = it;