line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/** |
2
|
|
|
|
|
|
|
* oconfig - src/parser.y |
3
|
|
|
|
|
|
|
* Copyright (C) 2007,2008 Florian octo Forster |
4
|
|
|
|
|
|
|
* |
5
|
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it |
6
|
|
|
|
|
|
|
* under the terms of the GNU General Public License as published by the |
7
|
|
|
|
|
|
|
* Free Software Foundation; only version 2 of the License is applicable. |
8
|
|
|
|
|
|
|
* |
9
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
10
|
|
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11
|
|
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
12
|
|
|
|
|
|
|
* more details. |
13
|
|
|
|
|
|
|
* |
14
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License along with |
15
|
|
|
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., |
16
|
|
|
|
|
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17
|
|
|
|
|
|
|
*/ |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
%{ |
20
|
|
|
|
|
|
|
sub YYERROR { |
21
|
0
|
|
|
0
|
0
|
0
|
join " ", @_; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
%} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
%start entire_file |
26
|
4
|
|
|
4
|
0
|
14
|
|
27
|
4
|
50
|
|
|
|
20
|
%union { |
28
|
|
|
|
|
|
|
double number; |
29
|
|
|
|
|
|
|
int boolean; |
30
|
|
|
|
|
|
|
char *string; |
31
|
|
|
|
|
|
|
oconfig_value_t cv; |
32
|
|
|
|
|
|
|
oconfig_item_t ci; |
33
|
|
|
|
|
|
|
argument_list_t al; |
34
|
|
|
|
|
|
|
statement_list_t sl; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
%token NUMBER |
38
|
|
|
|
|
|
|
%token BTRUE BFALSE |
39
|
|
|
|
|
|
|
%token QUOTED_STRING UNQUOTED_STRING |
40
|
|
|
|
|
|
|
%token SLASH OPENBRAC CLOSEBRAC EOL |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
%type string |
43
|
|
|
|
|
|
|
%type identifier |
44
|
|
|
|
|
|
|
/* arguments */ |
45
|
|
|
|
|
|
|
%type argument |
46
|
|
|
|
|
|
|
%type argument_list |
47
|
|
|
|
|
|
|
/* blocks */ |
48
|
|
|
|
|
|
|
%type block_begin |
49
|
|
|
|
|
|
|
%type block |
50
|
|
|
|
|
|
|
%type block_end |
51
|
|
|
|
|
|
|
/* statements */ |
52
|
|
|
|
|
|
|
%type option |
53
|
|
|
|
|
|
|
%type statement |
54
|
|
|
|
|
|
|
%type statement_list |
55
|
|
|
|
|
|
|
%type entire_file |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
/* pass an verbose, specific error message to yyerror() */ |
58
|
|
|
|
|
|
|
/* this is bison only jargon %error-verbose */ |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
%% |
61
|
|
|
|
|
|
|
string: |
62
|
13
|
|
|
13
|
|
37
|
QUOTED_STRING { unquote ($_[1]);} |
63
|
15
|
|
|
15
|
|
39
|
| UNQUOTED_STRING {$_[1];} |
64
|
10
|
|
|
10
|
|
29
|
; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
argument: |
67
|
|
|
|
|
|
|
NUMBER {$_[1]} |
68
|
0
|
|
|
0
|
|
0
|
| BTRUE {1} |
69
|
0
|
|
|
0
|
|
0
|
| BFALSE {0} |
70
|
28
|
|
|
28
|
|
69
|
| string {$_[1]} |
71
|
|
|
|
|
|
|
; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
argument_list: |
74
|
|
|
|
|
|
|
argument_list argument |
75
|
|
|
|
|
|
|
{ |
76
|
13
|
|
|
13
|
|
25
|
my $argument_list = $_[1]; |
77
|
13
|
|
|
|
|
16
|
push @{ $argument_list->{values} }, $_[2]; |
|
13
|
|
|
|
|
42
|
|
78
|
13
|
|
|
|
|
37
|
return $argument_list; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
| argument |
81
|
|
|
|
|
|
|
{ |
82
|
25
|
|
|
25
|
|
100
|
{ values => [ $_[1] ] }; |
83
|
|
|
|
|
|
|
} |
84
|
38
|
|
|
38
|
|
89
|
; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
identifier: |
87
|
|
|
|
|
|
|
UNQUOTED_STRING {$_[1]} |
88
|
|
|
|
|
|
|
; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
option: |
91
|
|
|
|
|
|
|
identifier argument_list EOL |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
{ |
94
|
20
|
|
|
|
|
143
|
children => [], |
95
|
|
|
|
|
|
|
key => $_[1], |
96
|
20
|
|
|
20
|
|
45
|
%{$_[2]}, |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
block_begin: |
102
|
|
|
|
|
|
|
OPENBRAC identifier CLOSEBRAC EOL |
103
|
|
|
|
|
|
|
{ |
104
|
4
|
|
|
4
|
|
16
|
{key => $_[2], values => []}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
| |
107
|
|
|
|
|
|
|
OPENBRAC identifier argument_list CLOSEBRAC EOL |
108
|
|
|
|
|
|
|
{ |
109
|
5
|
|
|
5
|
|
8
|
{key => $_[2], %{$_[3]}}; |
|
5
|
|
|
|
|
31
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
block_end: |
114
|
|
|
|
|
|
|
OPENBRAC SLASH identifier CLOSEBRAC EOL |
115
|
|
|
|
|
|
|
{ |
116
|
9
|
|
|
9
|
|
25
|
$_[3]; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
block: |
121
|
|
|
|
|
|
|
block_begin statement_list block_end |
122
|
|
|
|
|
|
|
{ |
123
|
9
|
50
|
|
9
|
|
35
|
if ($_[1]->{key} ne $_[3]) |
124
|
|
|
|
|
|
|
{ |
125
|
0
|
|
|
|
|
0
|
printf ("block_begin = %s; block_end = %s;\n", $_[1]->{key}, $_[3]); |
126
|
0
|
|
|
|
|
0
|
YYERROR ("Block not closed..\n"); |
127
|
0
|
|
|
|
|
0
|
die; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
return { |
130
|
9
|
|
|
|
|
52
|
%{$_[1]}, |
|
9
|
|
|
|
|
51
|
|
131
|
|
|
|
|
|
|
children => $_[2], |
132
|
|
|
|
|
|
|
}; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
statement: |
137
|
20
|
|
|
20
|
|
45
|
option { $_[1] } |
138
|
9
|
|
|
9
|
|
22
|
| block { $_[1] } |
139
|
38
|
|
|
38
|
|
74
|
| EOL { return } |
140
|
|
|
|
|
|
|
; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
statement_list: |
143
|
|
|
|
|
|
|
statement_list statement |
144
|
|
|
|
|
|
|
{ |
145
|
54
|
|
|
54
|
|
66
|
my $statement_list = $_[1]; |
146
|
54
|
100
|
|
|
|
106
|
push @{ $statement_list }, $_[2] if defined $_[2]; |
|
17
|
|
|
|
|
31
|
|
147
|
54
|
|
|
|
|
119
|
return $statement_list; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
| statement |
150
|
|
|
|
|
|
|
{ |
151
|
13
|
100
|
|
13
|
|
33
|
if (defined $_[1]) { |
152
|
12
|
|
|
|
|
37
|
return [ $_[1] ]; |
153
|
|
|
|
|
|
|
} else { |
154
|
1
|
|
|
|
|
3
|
return; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
entire_file: |
160
|
|
|
|
|
|
|
statement_list |
161
|
|
|
|
|
|
|
{ |
162
|
4
|
|
|
4
|
|
16
|
$_[1]->[0]; |
163
|
|
|
|
|
|
|
} |
164
|
4
|
|
|
|
|
558
|
; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
%% |
167
|
4
|
|
|
|
|
35
|
sub unquote ($) { |
168
|
13
|
|
|
13
|
0
|
78
|
(my $string = shift) =~ s/(?
|
169
|
13
|
|
|
|
|
36
|
return $string; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|