-
Notifications
You must be signed in to change notification settings - Fork 7
/
boa_grammar.y
127 lines (100 loc) · 2.41 KB
/
boa_grammar.y
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
%{
/*
* Boa, an http server
* Copyright (C) 1995 Paul Phillips <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/* $Id: boa_grammar.y,v 1.14 1999/10/12 14:49:07 jon Exp $*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/* #include "boa.h" */
#include "parse.h"
int yyerror(char * msg);
/* yydebug = 1; */
#ifdef DEBUG
#define DBG(x) x
#else
#define DBG(x)
#endif
char *arg1hold;
char mime_type[256]; /* global to inherit */
%}
%union {
char * sval;
int ival;
struct ccommand * cval;
};
/* boa.conf tokens */
%token <cval> STMT_NO_ARGS STMT_ONE_ARG STMT_TWO_ARGS
/* mime.type tokens */
%token <sval> MIMETYPE
%token <sval> STRING
%token <ival> INTEGER
%start ConfigFiles
%%
ConfigFiles: BoaConfigStmts MimeTypeStmts
;
BoaConfigStmts: BoaConfigStmts BoaConfigStmt
| /* empty */
;
BoaConfigStmt:
StmtNoArgs
| StmtOneArg
| StmtTwoArgs
;
StmtNoArgs: STMT_NO_ARGS
{ if ($1->action) {
DBG(printf("StmtNoArgs: %s\n",$1->name);)
$1->action(NULL,NULL,$1->object);
}
}
;
StmtOneArg: STMT_ONE_ARG STRING
{ if ($1->action) {
DBG(printf("StmtOneArg: %s %s\n",$1->name,$2);)
$1->action($2,NULL,$1->object);
}
}
;
StmtTwoArgs: STMT_TWO_ARGS STRING
{ arg1hold = strdup($2); }
STRING
{ if ($1->action) {
DBG(printf("StmtTwoArgs: '%s' '%s' '%s'\n",
$1->name,arg1hold,$4);)
$1->action($4,arg1hold,$1->object);
}
free(arg1hold);
}
;
/******************* mime.types **********************/
MimeTypeStmts: MimeTypeStmts MimeTypeStmt
| /* empty */
;
MimeTypeStmt: MIMETYPE
{ strcpy(mime_type, $1); }
ExtensionList
;
ExtensionList: ExtensionList Extension
| /* empty */
;
Extension: STRING
{ add_mime_type($1, mime_type); }
;
%%