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
|
7
|
|
|
7
|
0
|
13
|
|
27
|
7
|
50
|
|
|
|
21
|
%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
|
19
|
|
|
19
|
|
37
|
QUOTED_STRING { unquote ($_[1]);} |
63
|
15
|
|
|
15
|
|
19
|
| UNQUOTED_STRING {$_[1];} |
64
|
16
|
|
|
16
|
|
21
|
; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
argument: |
67
|
|
|
|
|
|
|
NUMBER {$_[1]} |
68
|
0
|
|
|
0
|
|
0
|
| BTRUE {1} |
69
|
0
|
|
|
0
|
|
0
|
| BFALSE {0} |
70
|
34
|
|
|
34
|
|
44
|
| string {$_[1]} |
71
|
|
|
|
|
|
|
; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
argument_list: |
74
|
|
|
|
|
|
|
argument_list argument |
75
|
|
|
|
|
|
|
{ |
76
|
19
|
|
|
19
|
|
21
|
my $argument_list = $_[1]; |
77
|
19
|
|
|
|
|
15
|
push @{ $argument_list->{values} }, $_[2]; |
|
19
|
|
|
|
|
36
|
|
78
|
19
|
|
|
|
|
25
|
return $argument_list; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
| argument |
81
|
|
|
|
|
|
|
{ |
82
|
31
|
|
|
31
|
|
77
|
{ values => [ $_[1] ] }; |
83
|
|
|
|
|
|
|
} |
84
|
47
|
|
|
47
|
|
58
|
; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
identifier: |
87
|
|
|
|
|
|
|
UNQUOTED_STRING {$_[1]} |
88
|
|
|
|
|
|
|
; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
option: |
91
|
|
|
|
|
|
|
identifier argument_list EOL |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
{ |
94
|
23
|
|
|
|
|
95
|
children => [], |
95
|
|
|
|
|
|
|
key => $_[1], |
96
|
23
|
|
|
23
|
|
36
|
%{$_[2]}, |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
block_begin: |
102
|
|
|
|
|
|
|
OPENBRAC identifier CLOSEBRAC EOL |
103
|
|
|
|
|
|
|
{ |
104
|
4
|
|
|
4
|
|
12
|
{key => $_[2], values => []}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
| |
107
|
|
|
|
|
|
|
OPENBRAC identifier argument_list CLOSEBRAC EOL |
108
|
|
|
|
|
|
|
{ |
109
|
8
|
|
|
8
|
|
12
|
{key => $_[2], %{$_[3]}}; |
|
8
|
|
|
|
|
31
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
block_end: |
114
|
|
|
|
|
|
|
OPENBRAC SLASH identifier CLOSEBRAC EOL |
115
|
|
|
|
|
|
|
{ |
116
|
12
|
|
|
12
|
|
20
|
$_[3]; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
block: |
121
|
|
|
|
|
|
|
block_begin statement_list block_end |
122
|
|
|
|
|
|
|
{ |
123
|
12
|
50
|
|
12
|
|
33
|
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
|
12
|
|
|
|
|
35
|
%{$_[1]}, |
|
12
|
|
|
|
|
47
|
|
131
|
|
|
|
|
|
|
children => $_[2], |
132
|
|
|
|
|
|
|
}; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
statement: |
137
|
23
|
|
|
23
|
|
31
|
option { $_[1] } |
138
|
12
|
|
|
12
|
|
16
|
| block { $_[1] } |
139
|
47
|
|
|
47
|
|
58
|
| EOL { return } |
140
|
|
|
|
|
|
|
; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
statement_list: |
143
|
|
|
|
|
|
|
statement_list statement |
144
|
|
|
|
|
|
|
{ |
145
|
63
|
|
|
63
|
|
38
|
my $statement_list = $_[1]; |
146
|
63
|
100
|
|
|
|
87
|
push @{ $statement_list }, $_[2] if defined $_[2]; |
|
17
|
|
|
|
|
18
|
|
147
|
63
|
|
|
|
|
79
|
return $statement_list; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
| statement |
150
|
|
|
|
|
|
|
{ |
151
|
19
|
100
|
|
19
|
|
32
|
if (defined $_[1]) { |
152
|
18
|
|
|
|
|
35
|
return [ $_[1] ]; |
153
|
|
|
|
|
|
|
} else { |
154
|
1
|
|
|
|
|
1
|
return; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
entire_file: |
160
|
|
|
|
|
|
|
statement_list |
161
|
|
|
|
|
|
|
{ |
162
|
7
|
|
|
7
|
|
16
|
$_[1]->[0]; |
163
|
|
|
|
|
|
|
} |
164
|
7
|
|
|
|
|
598
|
; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
%% |
167
|
7
|
|
|
|
|
29
|
sub unquote ($) { |
168
|
19
|
|
|
19
|
0
|
73
|
(my $string = shift) =~ s/(?
|
169
|
19
|
|
|
|
|
30
|
return $string; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|