line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
%% |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
input: |
4
|
0
|
|
|
0
|
|
|
TYPE EQUALS TypeDefn { $_[3] }; |
5
|
0
|
|
|
0
|
|
|
|
6
|
|
|
|
|
|
|
TypeDefn: |
7
|
|
|
|
|
|
|
BasicType ClassSpec |
8
|
|
|
|
|
|
|
{{ |
9
|
|
|
|
|
|
|
fullname => $_[1]->{fullname}, |
10
|
|
|
|
|
|
|
shortname => $_[1]->{shortname}, |
11
|
|
|
|
|
|
|
quotename => $_[1]->{quotename}, |
12
|
|
|
|
|
|
|
parent => $_[1]->{parent}, |
13
|
|
|
|
|
|
|
members => $_[2], |
14
|
|
|
|
|
|
|
}} |
15
|
|
|
|
|
|
|
| BasicType; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BasicType: |
18
|
0
|
|
|
0
|
|
|
TypePrefixes ClassPrefix SimpleType ClassSuffix TypeSuffix { BasicType(@_[1..$#_]) } |
19
|
0
|
|
|
0
|
|
|
| ClassPrefix SimpleType ClassSuffix TypeSuffix { BasicType("", @_[1..$#_]) } |
20
|
0
|
|
|
0
|
|
|
| TypePrefixes SimpleType ClassSuffix TypeSuffix { BasicType($_[1], "", @_[2..$#_]) } |
21
|
0
|
|
|
0
|
|
|
| SimpleType ClassSuffix TypeSuffix { BasicType("", "", @_[1..$#_]) }; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
TypePrefixes: |
24
|
|
|
|
|
|
|
TypePrefix |
25
|
|
|
|
|
|
|
| TypePrefixes TypePrefix |
26
|
0
|
|
|
0
|
|
|
{ trim(join(' ', @_[1..$#_])) }; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
TypePrefix: |
29
|
|
|
|
|
|
|
CONST |
30
|
|
|
|
|
|
|
| MUTABLE |
31
|
|
|
|
|
|
|
| STATIC |
32
|
|
|
|
|
|
|
| STAR |
33
|
|
|
|
|
|
|
| AMP; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
TypeSuffix: |
36
|
|
|
|
|
|
|
CONST TypeSuffix |
37
|
0
|
|
|
0
|
|
|
{ trim(join(' ', @_[1..$#_])) } |
38
|
|
|
|
|
|
|
| STAR TypeSuffix |
39
|
0
|
|
|
0
|
|
|
{ trim(join(' ', @_[1..$#_])) } |
40
|
|
|
|
|
|
|
| AMP TypeSuffix |
41
|
0
|
|
|
0
|
|
|
{ trim(join(' ', @_[1..$#_])) } |
42
|
|
|
|
|
|
|
| OPENBRACKET NUMBER CLOSEBRACKET TypeSuffix |
43
|
0
|
|
|
0
|
|
|
{ trim(join(' ', @_[1..$#_])) } |
44
|
|
|
|
|
|
|
| /* empty */ |
45
|
0
|
|
|
0
|
|
|
{ trim(join(' ', @_[1..$#_])) }; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
ClassPrefix: |
48
|
|
|
|
|
|
|
CLASS | STRUCT | UNION; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
ClassSuffix: |
51
|
0
|
|
|
0
|
|
|
COLON ClassAccess ClassPrefix SimpleType { $_[4] } |
52
|
0
|
|
|
0
|
|
|
| COLON ClassPrefix SimpleType { $_[3] } |
53
|
0
|
|
|
0
|
|
|
| COLON ClassAccess SimpleType { $_[3] } |
54
|
0
|
|
|
0
|
|
|
| COLON SimpleType { $_[3] } |
55
|
0
|
|
|
0
|
|
|
| /* empty */ { undef }; |
56
|
0
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
ClassAccess: |
58
|
|
|
|
|
|
|
PUBLIC |
59
|
|
|
|
|
|
|
| PRIVATE |
60
|
|
|
|
|
|
|
| PROTECTED; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
TemplatedIdentifier: |
63
|
|
|
|
|
|
|
IDENTIFIER TemplateSpec |
64
|
|
|
|
|
|
|
{{ |
65
|
0
|
|
|
0
|
|
|
fullname => join('', $_[1], '< ', join(',', @{$_[2]}), ' >'), |
66
|
|
|
|
|
|
|
shortname => $_[1], |
67
|
|
|
|
|
|
|
template => $_[2] |
68
|
|
|
|
|
|
|
}} |
69
|
0
|
|
|
0
|
|
|
| IDENTIFIER |
70
|
|
|
|
|
|
|
{{ |
71
|
|
|
|
|
|
|
fullname => join(' ', @_[1..$#_]), |
72
|
|
|
|
|
|
|
shortname => $_[1], |
73
|
|
|
|
|
|
|
}}; |
74
|
0
|
|
|
0
|
|
|
|
75
|
|
|
|
|
|
|
SimpleType: |
76
|
|
|
|
|
|
|
Namespace TemplatedIdentifier |
77
|
|
|
|
|
|
|
{{ |
78
|
|
|
|
|
|
|
fullname => join('', $_[1], $_[2]->{fullname}), |
79
|
|
|
|
|
|
|
shortname => $_[2]->{shortname}, |
80
|
|
|
|
|
|
|
template => $_[2]->{template}, |
81
|
|
|
|
|
|
|
}} |
82
|
0
|
|
|
0
|
|
|
| TemplatedIdentifier |
83
|
|
|
|
|
|
|
| BuiltinType |
84
|
|
|
|
|
|
|
{{ |
85
|
|
|
|
|
|
|
fullname => $_[1], |
86
|
|
|
|
|
|
|
shortname => $_[1], |
87
|
|
|
|
|
|
|
}}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Namespace: |
90
|
|
|
|
|
|
|
Namespace TemplatedIdentifier DOUBLE_COLON |
91
|
0
|
|
|
0
|
|
|
{ join('', $_[1], $_[2]->{fullname}, $_[3]) } |
92
|
|
|
|
|
|
|
| TemplatedIdentifier DOUBLE_COLON |
93
|
0
|
|
|
0
|
|
|
{ join('', $_[1]->{fullname}, $_[2]) }; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
BasicTypeList: |
96
|
|
|
|
|
|
|
BasicTypeList_NonEmpty |
97
|
|
|
|
|
|
|
| /* empty */ |
98
|
0
|
|
|
0
|
|
|
{ [] }; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
BasicTypeList_NonEmpty: |
101
|
|
|
|
|
|
|
BasicType |
102
|
0
|
|
|
0
|
|
|
{ [$_[1]->{fullname}] } |
103
|
|
|
|
|
|
|
| BasicType COMMA BasicTypeList |
104
|
0
|
|
|
0
|
|
|
{ [$_[1]->{fullname}, @{$_[3]}] }; |
|
0
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
TemplateSpec: |
107
|
|
|
|
|
|
|
OPENANGLE BasicTypeList_NonEmpty CLOSEANGLE |
108
|
0
|
|
|
0
|
|
|
{ $_[2] }; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
ClassSpec: |
111
|
|
|
|
|
|
|
OPENBRACE ClassMembers CLOSEBRACE |
112
|
0
|
|
|
0
|
|
|
{ $_[2] }; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
ClassMembers: |
115
|
|
|
|
|
|
|
ClassMember ClassMembers |
116
|
0
|
0
|
|
0
|
|
|
{ defined($_[1]) ? [$_[1], @{$_[2]}] : $_[2] } |
|
0
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
| /* empty */ |
118
|
0
|
|
|
0
|
|
|
{ [] }; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
ClassMember: |
121
|
|
|
|
|
|
|
ClassAccess COLON |
122
|
0
|
|
|
0
|
|
|
{ undef } |
123
|
0
|
|
|
0
|
|
|
| FunctionDecl SEMICOLON |
124
|
|
|
|
|
|
|
| VarDecl SEMICOLON; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
/* Only destructors have a missing type; constructors are called 'void' */ |
127
|
|
|
|
|
|
|
FunctionDecl: |
128
|
|
|
|
|
|
|
BasicType IDENTIFIER TemplateSpec OPENPAREN BasicTypeList CLOSEPAREN TypeSuffix |
129
|
|
|
|
|
|
|
{{ |
130
|
|
|
|
|
|
|
function => $_[2], |
131
|
|
|
|
|
|
|
type => $_[1], |
132
|
|
|
|
|
|
|
params => $_[5], |
133
|
|
|
|
|
|
|
}} |
134
|
0
|
|
|
0
|
|
|
| BasicType IDENTIFIER OPENPAREN BasicTypeList CLOSEPAREN TypeSuffix |
135
|
|
|
|
|
|
|
{{ |
136
|
|
|
|
|
|
|
function => $_[2], |
137
|
|
|
|
|
|
|
type => $_[1], |
138
|
|
|
|
|
|
|
params => $_[4], |
139
|
|
|
|
|
|
|
}} |
140
|
0
|
|
|
0
|
|
|
| IDENTIFIER OPENPAREN BasicTypeList CLOSEPAREN TypeSuffix |
141
|
|
|
|
|
|
|
{{ |
142
|
|
|
|
|
|
|
function => $_[1] . $_[2], |
143
|
|
|
|
|
|
|
type => undef, |
144
|
|
|
|
|
|
|
params => $_[4], |
145
|
|
|
|
|
|
|
}}; |
146
|
0
|
|
|
0
|
|
|
|
147
|
|
|
|
|
|
|
VarDecl: |
148
|
|
|
|
|
|
|
BasicType IDENTIFIER TypeSuffix |
149
|
|
|
|
|
|
|
{{ |
150
|
|
|
|
|
|
|
variable => $_[2], |
151
|
|
|
|
|
|
|
type => $_[1], |
152
|
|
|
|
|
|
|
}}; |
153
|
0
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
BuiltinType: |
155
|
|
|
|
|
|
|
VOID |
156
|
|
|
|
|
|
|
| LONG INT |
157
|
|
|
|
|
|
|
| INT |
158
|
|
|
|
|
|
|
| LONG UNSIGNED INT |
159
|
|
|
|
|
|
|
| UNSIGNED INT |
160
|
|
|
|
|
|
|
| FLOAT |
161
|
|
|
|
|
|
|
| DOUBLE |
162
|
|
|
|
|
|
|
| CHAR |
163
|
|
|
|
|
|
|
| UNSIGNED CHAR |
164
|
|
|
|
|
|
|
| SIZE_T |
165
|
|
|
|
|
|
|
| SSIZE_T |
166
|
|
|
|
|
|
|
| UNSIGNED |
167
|
|
|
|
|
|
|
| LONG |
168
|
|
|
|
|
|
|
| LONG LONG |
169
|
|
|
|
|
|
|
| UNSIGNED LONG |
170
|
|
|
|
|
|
|
| LONG UNSIGNED; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
%% |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub BasicType |
175
|
|
|
|
|
|
|
{ |
176
|
0
|
|
|
0
|
0
|
|
unshift @_, undef; |
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
my $t = { |
179
|
|
|
|
|
|
|
fullname => trim(join(' ', $_[1], $_[2], $_[3]->{fullname}, $_[5])), |
180
|
|
|
|
|
|
|
shortname => trim($_[3]->{shortname}), |
181
|
|
|
|
|
|
|
quotename => trim(join(' ', $_[1], $_[2], q(').$_[3]->{fullname}.q('), $_[5])), |
182
|
|
|
|
|
|
|
template => $_[3]->{template}, |
183
|
|
|
|
|
|
|
}; |
184
|
|
|
|
|
|
|
|
185
|
0
|
0
|
|
|
|
|
if(defined $_[4]) |
186
|
|
|
|
|
|
|
{ |
187
|
0
|
|
|
|
|
|
$t->{parent} = |
188
|
|
|
|
|
|
|
{ |
189
|
|
|
|
|
|
|
fullname => $_[4]->{fullname}, |
190
|
|
|
|
|
|
|
shortname => $_[4]->{shortname}, |
191
|
|
|
|
|
|
|
quotename => q(').$_[4]->{fullname}.q('), |
192
|
|
|
|
|
|
|
}; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
$t; |
196
|
|
|
|
|
|
|
}; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub trim($) |
199
|
|
|
|
|
|
|
{ |
200
|
0
|
|
|
0
|
0
|
|
$_ = shift @_; |
201
|
0
|
|
|
|
|
|
s/^\s*//s; |
202
|
0
|
|
|
|
|
|
s/\s*$//s; |
203
|
0
|
|
|
|
|
|
return $_; |
204
|
0
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub _Lexer { |
207
|
0
|
|
|
0
|
|
|
my($parser)=shift; |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
$parser->YYData->{DATA} =~ s/^\s+//s; |
210
|
|
|
|
|
|
|
|
211
|
0
|
0
|
|
|
|
|
$parser->YYData->{DATA} |
212
|
|
|
|
|
|
|
or return('',undef); |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
for ($parser->YYData->{DATA}) { |
215
|
0
|
0
|
|
|
|
|
s/^(operator[<>\[\]=+!-]+)//s |
216
|
|
|
|
|
|
|
and return('IDENTIFIER', $1); |
217
|
0
|
0
|
|
|
|
|
s/^(==)//s |
218
|
|
|
|
|
|
|
and return('DOUBLE_EQUALS', $1); |
219
|
0
|
0
|
|
|
|
|
s/^(=)//s |
220
|
|
|
|
|
|
|
and return('EQUALS', $1); |
221
|
0
|
0
|
|
|
|
|
s/^(\*)//s |
222
|
|
|
|
|
|
|
and return('STAR', $1); |
223
|
0
|
0
|
|
|
|
|
s/^(&)//s |
224
|
|
|
|
|
|
|
and return('AMP', $1); |
225
|
0
|
0
|
|
|
|
|
s/^(\[)//s |
226
|
|
|
|
|
|
|
and return('OPENBRACKET', $1); |
227
|
0
|
0
|
|
|
|
|
s/^(\])//s |
228
|
|
|
|
|
|
|
and return('CLOSEBRACKET', $1); |
229
|
0
|
0
|
|
|
|
|
s/^(<)//s |
230
|
|
|
|
|
|
|
and return('OPENANGLE', $1); |
231
|
0
|
0
|
|
|
|
|
s/^(>)//s |
232
|
|
|
|
|
|
|
and return('CLOSEANGLE', $1); |
233
|
0
|
0
|
|
|
|
|
s/^(::)//s |
234
|
|
|
|
|
|
|
and return('DOUBLE_COLON', $1); |
235
|
|
0
|
|
|
|
|
s/^(,)//s |
236
|
|
|
|
|
|
|
and return('COMMA', $1); |
237
|
|
0
|
|
|
|
|
s/^(:)//s |
238
|
|
|
|
|
|
|
and return('COLON', $1); |
239
|
|
0
|
|
|
|
|
s/^(;)//s |
240
|
|
|
|
|
|
|
and return('SEMICOLON', $1); |
241
|
|
0
|
|
|
|
|
s/^({)//s |
242
|
|
|
|
|
|
|
and return('OPENBRACE', $1); |
243
|
|
0
|
|
|
|
|
s/^(})//s |
244
|
|
|
|
|
|
|
and return('CLOSEBRACE', $1); |
245
|
|
0
|
|
|
|
|
s/^(\()//s |
246
|
|
|
|
|
|
|
and return('OPENPAREN', $1); |
247
|
|
0
|
|
|
|
|
s/^(\))//s |
248
|
|
|
|
|
|
|
and return('CLOSEPAREN', $1); |
249
|
|
0
|
|
|
|
|
s/^(type\b)//s |
250
|
|
|
|
|
|
|
and return('TYPE', $1); |
251
|
|
0
|
|
|
|
|
s/^(void\b)//s |
252
|
|
|
|
|
|
|
and return('VOID', $1); |
253
|
|
0
|
|
|
|
|
s/^(int\b)//s |
254
|
|
|
|
|
|
|
and return('INT', $1); |
255
|
|
0
|
|
|
|
|
s/^(float\b)//s |
256
|
|
|
|
|
|
|
and return('FLOAT', $1); |
257
|
|
0
|
|
|
|
|
s/^(double\b)//s |
258
|
|
|
|
|
|
|
and return('DOUBLE', $1); |
259
|
|
0
|
|
|
|
|
s/^(char\b)//s |
260
|
|
|
|
|
|
|
and return('CHAR', $1); |
261
|
|
0
|
|
|
|
|
s/^(size_t\b)//s |
262
|
|
|
|
|
|
|
and return('SIZE_T', $1); |
263
|
|
0
|
|
|
|
|
s/^(ssize_t\b)//s |
264
|
|
|
|
|
|
|
and return('SSIZE_T', $1); |
265
|
|
0
|
|
|
|
|
s/^(unsigned\b)//s |
266
|
|
|
|
|
|
|
and return('UNSIGNED', $1); |
267
|
|
0
|
|
|
|
|
s/^(long\b)//s |
268
|
|
|
|
|
|
|
and return('LONG', $1); |
269
|
|
0
|
|
|
|
|
s/^(mutable\b)//s |
270
|
|
|
|
|
|
|
and return('MUTABLE', $1); |
271
|
|
0
|
|
|
|
|
s/^(const\b)//s |
272
|
|
|
|
|
|
|
and return('CONST', $1); |
273
|
|
0
|
|
|
|
|
s/^(static\b)//s |
274
|
|
|
|
|
|
|
and return('STATIC', $1); |
275
|
|
0
|
|
|
|
|
s/^(class\b)//s |
276
|
|
|
|
|
|
|
and return('CLASS', $1); |
277
|
|
0
|
|
|
|
|
s/^(struct\b)//s |
278
|
|
|
|
|
|
|
and return('STRUCT', $1); |
279
|
|
0
|
|
|
|
|
s/^(union\b)//s |
280
|
|
|
|
|
|
|
and return('UNION', $1); |
281
|
|
0
|
|
|
|
|
s/^(private\b)//s |
282
|
|
|
|
|
|
|
and return('PRIVATE', $1); |
283
|
|
0
|
|
|
|
|
s/^(protected\b)//s |
284
|
|
|
|
|
|
|
and return('PROTECTED', $1); |
285
|
|
0
|
|
|
|
|
s/^(public)//s |
286
|
|
|
|
|
|
|
and return('PUBLIC', $1); |
287
|
|
0
|
|
|
|
|
s/^([0-9]+)//s |
288
|
|
|
|
|
|
|
and return('NUMBER', $1); |
289
|
|
0
|
|
|
|
|
s/^([A-Za-z_~][A-Za-z0-9_~]*)//s |
290
|
|
|
|
|
|
|
and return('IDENTIFIER', $1); |
291
|
|
|
|
|
|
|
s/^(.)//s |
292
|
|
|
|
|
|
|
and return($1, $1); |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
sub parse($) |
297
|
|
|
|
|
|
|
{ |
298
|
|
|
|
0
|
0
|
|
my $self = shift; |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
$self->YYData->{DATA} = shift; |
301
|
|
|
|
0
|
|
|
my $result = $self->YYParse( yylex => \&_Lexer, yyerror => sub {} ); |
302
|
|
|
|
|
|
|
$self->YYData->{DATA} = undef; |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
return $result; |
305
|
|
|
|
|
|
|
} |