-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbconf.y
More file actions
47 lines (36 loc) · 813 Bytes
/
bconf.y
File metadata and controls
47 lines (36 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* SPDX-License-Identifier: BSD-3-Clause */
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <err.h>
#include "mkconf.h"
int yylex(void);
void yyerror(struct mkconf *, const char *);
%}
%union{
struct mkconf_feature *feature;
char *string;
}
%parse-param {struct mkconf *mkconf}
%token T_CONFIG T_DEFAULTS
%token <string> T_NAME T_STRING
%type <feature> feature features
%type <string> defaults
%%
toplevel: features { mkconf->features = $1; } ;
features: { $$ = NULL; }
| feature features { $$ = $1; $$->next = $2; } ;
feature: T_CONFIG T_NAME T_STRING defaults {
$$ = malloc(sizeof *$$);
#ifdef YYNOMEM
if ($$ == NULL)
YYNOMEM;
#endif
$$->name = $2;
$$->description = $3;
$$->defaults = $4;
} ;
defaults: { $$ = NULL; }
| T_DEFAULTS T_STRING { $$ = $2; } ;
%%