1 ####################################################################
3 # This file was generated using Parse::Yapp version 1.05.
5 # Don't edit this file, use source file instead.
7 # ANY CHANGE MADE HERE WILL BE LOST !
9 ####################################################################
10 package Parse::Pidl::IDL;
14 @ISA= qw ( Parse::Yapp::Driver );
15 use Parse::Yapp::Driver;
22 and $class=ref($class);
24 my($self)=$class->SUPER::new( yyversion => '1.05',
200 'base_interface' => 38
233 'interface_names' => 42
273 'commalisttext' => 49
297 'property_list' => 60,
353 'optional_semicolon' => 85
388 'property_list' => 60,
417 'existingtype' => 99,
421 'property_list' => 94,
552 'commalisttext' => 113
609 'commalisttext' => 117
702 'optional_semicolon' => 124
720 'existingtype' => 99,
724 'property_list' => 94,
739 'optional_identifier' => 127
775 'optional_identifier' => 129
790 'optional_identifier' => 130
799 'optional_identifier' => 131
811 'existingtype' => 99,
815 'property_list' => 94,
1084 'union_body' => 140,
1085 'opt_union_body' => 138
1097 'struct_body' => 141,
1098 'opt_struct_body' => 143
1107 'opt_enum_body' => 146,
1117 'bitmap_body' => 149,
1118 'opt_bitmap_body' => 147
1181 'union_elements' => 157
1193 'element_list1' => 158
1204 'identifier' => 159,
1205 'enum_element' => 160,
1206 'enum_elements' => 161
1224 'identifier' => 164,
1225 'bitmap_element' => 163,
1226 'bitmap_elements' => 162,
1227 'opt_bitmap_elements' => 165
1242 'optional_const' => 166,
1243 'element_list2' => 168
1315 'optional_base_element' => 177,
1316 'property_list' => 176
1325 'base_element' => 179,
1326 'property_list' => 180
1366 'base_element' => 187,
1367 'property_list' => 180
1442 'base_or_empty' => 194,
1443 'base_element' => 195,
1444 'empty_element' => 196,
1445 'property_list' => 197
1469 'existingtype' => 99,
1473 'property_list' => 94,
1504 'identifier' => 159,
1505 'enum_element' => 201
1513 'identifier' => 164,
1514 'bitmap_element' => 202
1543 'optional_const' => 204
1619 'existingtype' => 99,
1623 'property_list' => 94,
1690 'base_element' => 212,
1691 'property_list' => 180
1768 #line 20 "./../pidl/idl.yp"
1769 { push(@{$_[1]}, $_[2]); $_[1] }
1774 #line 22 "./../pidl/idl.yp"
1775 { push(@{$_[1]}, $_[2]); $_[1] }
1780 #line 24 "./../pidl/idl.yp"
1781 { push(@{$_[1]}, $_[2]); $_[1] }
1786 #line 26 "./../pidl/idl.yp"
1787 { push(@{$_[1]}, $_[2]); $_[1] }
1792 #line 28 "./../pidl/idl.yp"
1793 { push(@{$_[1]}, $_[2]); $_[1] }
1798 #line 30 "./../pidl/idl.yp"
1799 { push(@{$_[1]}, $_[2]); $_[1] }
1804 #line 35 "./../pidl/idl.yp"
1808 "FILE" => $_[0]->YYData->{FILE},
1809 "LINE" => $_[0]->YYData->{LINE},
1815 #line 45 "./../pidl/idl.yp"
1817 "TYPE" => "INCLUDE",
1819 "FILE" => $_[0]->YYData->{FILE},
1820 "LINE" => $_[0]->YYData->{LINE},
1826 #line 55 "./../pidl/idl.yp"
1828 "TYPE" => "IMPORTLIB",
1830 "FILE" => $_[0]->YYData->{FILE},
1831 "LINE" => $_[0]->YYData->{LINE},
1837 #line 64 "./../pidl/idl.yp"
1843 #line 66 "./../pidl/idl.yp"
1844 { push(@{$_[1]}, $_[3]); $_[1] }
1849 #line 71 "./../pidl/idl.yp"
1851 "TYPE" => "COCLASS",
1852 "PROPERTIES" => $_[1],
1855 "FILE" => $_[0]->YYData->{FILE},
1856 "LINE" => $_[0]->YYData->{LINE},
1860 'interface_names', 0, undef
1863 'interface_names', 4,
1865 #line 84 "./../pidl/idl.yp"
1866 { push(@{$_[1]}, $_[2]); $_[1] }
1871 #line 89 "./../pidl/idl.yp"
1873 "TYPE" => "INTERFACE",
1874 "PROPERTIES" => $_[1],
1878 "FILE" => $_[0]->YYData->{FILE},
1879 "LINE" => $_[0]->YYData->{LINE},
1883 'base_interface', 0, undef
1886 'base_interface', 2,
1888 #line 103 "./../pidl/idl.yp"
1894 #line 109 "./../pidl/idl.yp"
1896 "TYPE" => "CPP_QUOTE",
1898 "FILE" => $_[0]->YYData->{FILE},
1899 "LINE" => $_[0]->YYData->{LINE},
1905 #line 118 "./../pidl/idl.yp"
1911 #line 120 "./../pidl/idl.yp"
1912 { push(@{$_[1]}, $_[2]); $_[1] }
1915 'definition', 1, undef
1918 'definition', 1, undef
1921 'definition', 1, undef
1924 'definition', 1, undef
1929 #line 135 "./../pidl/idl.yp"
1933 "POINTERS" => $_[3],
1936 "FILE" => $_[0]->YYData->{FILE},
1937 "LINE" => $_[0]->YYData->{LINE},
1943 #line 146 "./../pidl/idl.yp"
1947 "POINTERS" => $_[3],
1949 "ARRAY_LEN" => $_[5],
1951 "FILE" => $_[0]->YYData->{FILE},
1952 "LINE" => $_[0]->YYData->{LINE},
1958 #line 160 "./../pidl/idl.yp"
1960 "TYPE" => "FUNCTION",
1962 "RETURN_TYPE" => $_[2],
1963 "PROPERTIES" => $_[1],
1964 "ELEMENTS" => $_[5],
1965 "FILE" => $_[0]->YYData->{FILE},
1966 "LINE" => $_[0]->YYData->{LINE},
1972 #line 173 "./../pidl/idl.yp"
1974 "TYPE" => "TYPEDEF",
1975 "PROPERTIES" => $_[1],
1978 "ARRAY_LEN" => $_[5],
1979 "FILE" => $_[0]->YYData->{FILE},
1980 "LINE" => $_[0]->YYData->{LINE},
1984 'usertype', 1, undef
1987 'usertype', 1, undef
1990 'usertype', 1, undef
1993 'usertype', 1, undef
1996 'usertype', 1, undef
2001 #line 197 "./../pidl/idl.yp"
2013 #line 207 "./../pidl/idl.yp"
2014 { ($_[1]?$_[1]:"signed") ." $_[2]" }
2017 'existingtype', 1, undef
2028 #line 217 "./../pidl/idl.yp"
2034 #line 221 "./../pidl/idl.yp"
2038 'opt_enum_body', 0, undef
2041 'opt_enum_body', 1, undef
2046 #line 232 "./../pidl/idl.yp"
2049 "PROPERTIES" => $_[1],
2051 "ELEMENTS" => $_[4],
2052 "FILE" => $_[0]->YYData->{FILE},
2053 "LINE" => $_[0]->YYData->{LINE},
2059 #line 243 "./../pidl/idl.yp"
2065 #line 245 "./../pidl/idl.yp"
2066 { push(@{$_[1]}, $_[3]); $_[1] }
2069 'enum_element', 1, undef
2074 #line 251 "./../pidl/idl.yp"
2075 { "$_[1]$_[2]$_[3]" }
2080 #line 255 "./../pidl/idl.yp"
2084 'opt_bitmap_body', 0, undef
2087 'opt_bitmap_body', 1, undef
2092 #line 266 "./../pidl/idl.yp"
2095 "PROPERTIES" => $_[1],
2097 "ELEMENTS" => $_[4],
2098 "FILE" => $_[0]->YYData->{FILE},
2099 "LINE" => $_[0]->YYData->{LINE},
2103 'bitmap_elements', 1,
2105 #line 277 "./../pidl/idl.yp"
2109 'bitmap_elements', 3,
2111 #line 279 "./../pidl/idl.yp"
2112 { push(@{$_[1]}, $_[3]); $_[1] }
2115 'opt_bitmap_elements', 0, undef
2118 'opt_bitmap_elements', 1, undef
2121 'bitmap_element', 3,
2123 #line 289 "./../pidl/idl.yp"
2124 { "$_[1] ( $_[3] )" }
2129 #line 293 "./../pidl/idl.yp"
2133 'opt_struct_body', 0, undef
2136 'opt_struct_body', 1, undef
2141 #line 304 "./../pidl/idl.yp"
2144 "PROPERTIES" => $_[1],
2146 "ELEMENTS" => $_[4],
2147 "FILE" => $_[0]->YYData->{FILE},
2148 "LINE" => $_[0]->YYData->{LINE},
2154 #line 316 "./../pidl/idl.yp"
2158 "PROPERTIES" => $_[1],
2161 "FILE" => $_[0]->YYData->{FILE},
2162 "LINE" => $_[0]->YYData->{LINE},
2166 'base_or_empty', 2, undef
2169 'base_or_empty', 1, undef
2172 'optional_base_element', 2,
2174 #line 333 "./../pidl/idl.yp"
2175 { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2178 'union_elements', 0, undef
2181 'union_elements', 2,
2183 #line 339 "./../pidl/idl.yp"
2184 { push(@{$_[1]}, $_[2]); $_[1] }
2189 #line 343 "./../pidl/idl.yp"
2193 'opt_union_body', 0, undef
2196 'opt_union_body', 1, undef
2201 #line 354 "./../pidl/idl.yp"
2204 "PROPERTIES" => $_[1],
2206 "ELEMENTS" => $_[4],
2207 "FILE" => $_[0]->YYData->{FILE},
2208 "LINE" => $_[0]->YYData->{LINE},
2214 #line 366 "./../pidl/idl.yp"
2218 "PROPERTIES" => $_[1],
2219 "POINTERS" => $_[3],
2220 "ARRAY_LEN" => $_[5],
2221 "FILE" => $_[0]->YYData->{FILE},
2222 "LINE" => $_[0]->YYData->{LINE},
2228 #line 379 "./../pidl/idl.yp"
2234 #line 381 "./../pidl/idl.yp"
2240 #line 386 "./../pidl/idl.yp"
2243 "PROPERTIES" => $_[1],
2246 "FILE" => $_[0]->YYData->{FILE},
2247 "LINE" => $_[0]->YYData->{LINE},
2253 #line 398 "./../pidl/idl.yp"
2259 #line 400 "./../pidl/idl.yp"
2260 { push(@{$_[1]}, $_[2]); $_[1] }
2263 'optional_const', 0, undef
2266 'optional_const', 1, undef
2269 'element_list2', 0, undef
2272 'element_list2', 1, undef
2277 #line 414 "./../pidl/idl.yp"
2283 #line 416 "./../pidl/idl.yp"
2284 { push(@{$_[1]}, $_[4]); $_[1] }
2287 'array_len', 0, undef
2292 #line 422 "./../pidl/idl.yp"
2293 { push(@{$_[3]}, "*"); $_[3] }
2298 #line 424 "./../pidl/idl.yp"
2299 { push(@{$_[4]}, "$_[2]"); $_[4] }
2302 'property_list', 0, undef
2307 #line 430 "./../pidl/idl.yp"
2308 { FlattenHash([$_[1],$_[3]]); }
2313 #line 434 "./../pidl/idl.yp"
2319 #line 436 "./../pidl/idl.yp"
2320 { FlattenHash([$_[1], $_[3]]); }
2325 #line 440 "./../pidl/idl.yp"
2326 {{ "$_[1]" => "1" }}
2331 #line 442 "./../pidl/idl.yp"
2332 {{ "$_[1]" => "$_[3]" }}
2335 'commalisttext', 1, undef
2340 #line 448 "./../pidl/idl.yp"
2346 #line 453 "./../pidl/idl.yp"
2361 #line 461 "./../pidl/idl.yp"
2362 { "$_[1]$_[2]$_[3]" }
2367 #line 463 "./../pidl/idl.yp"
2368 { "$_[1]$_[2]$_[3]" }
2373 #line 465 "./../pidl/idl.yp"
2374 { "$_[1]$_[2]$_[3]" }
2379 #line 467 "./../pidl/idl.yp"
2380 { "$_[1]$_[2]$_[3]" }
2385 #line 469 "./../pidl/idl.yp"
2386 { "$_[1]$_[2]$_[3]" }
2391 #line 471 "./../pidl/idl.yp"
2392 { "$_[1]$_[2]$_[3]" }
2397 #line 473 "./../pidl/idl.yp"
2398 { "$_[1]$_[2]$_[3]" }
2403 #line 475 "./../pidl/idl.yp"
2404 { "$_[1]$_[2]$_[3]" }
2409 #line 477 "./../pidl/idl.yp"
2410 { "$_[1]$_[2]$_[3]" }
2415 #line 479 "./../pidl/idl.yp"
2416 { "$_[1]$_[2]$_[3]" }
2421 #line 481 "./../pidl/idl.yp"
2422 { "$_[1]$_[2]$_[3]" }
2427 #line 483 "./../pidl/idl.yp"
2428 { "$_[1]$_[2]$_[3]" }
2433 #line 485 "./../pidl/idl.yp"
2434 { "$_[1]$_[2]$_[3]" }
2439 #line 487 "./../pidl/idl.yp"
2440 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2445 #line 489 "./../pidl/idl.yp"
2446 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2449 'identifier', 1, undef
2452 'optional_identifier', 0, undef
2455 'optional_identifier', 1, undef
2458 'constant', 1, undef
2463 #line 507 "./../pidl/idl.yp"
2467 'optional_semicolon', 0, undef
2470 'optional_semicolon', 1, undef
2474 bless($self,$class);
2477 #line 519 "./../pidl/idl.yp"
2480 use Parse::Pidl qw(error);
2482 #####################################################################
2483 # flatten an array of hashes into a single hash
2489 for my $k (keys %{$d}) {
2496 #####################################################################
2497 # traverse a perl data structure removing any empty arrays or
2498 # hashes and any hash elements that map to undef
2504 return undef if (not defined($v));
2506 if (ref($v) eq "ARRAY") {
2507 foreach my $i (0 .. $#{$v}) {
2508 CleanData($v->[$i]);
2510 # this removes any undefined elements from the array
2511 @{$v} = grep { defined $_ } @{$v};
2512 } elsif (ref($v) eq "HASH") {
2513 foreach my $x (keys %{$v}) {
2514 CleanData($v->{$x});
2515 if (!defined $v->{$x}) {
2526 if (exists $_[0]->YYData->{ERRMSG}) {
2527 error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2528 delete $_[0]->YYData->{ERRMSG};
2532 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2534 error($_[0]->YYData, "Syntax error near '$last_token'");
2541 $parser->YYData->{INPUT} or return('',undef);
2544 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2546 for ($parser->YYData->{INPUT}) {
2548 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2549 $parser->YYData->{LINE} = $1-1;
2550 $parser->YYData->{FILE} = $2;
2553 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2554 $parser->YYData->{LINE} = $1-1;
2555 $parser->YYData->{FILE} = $2;
2558 if (s/^(\#.*)$//m) {
2563 $parser->YYData->{LINE}++;
2566 if (s/^\"(.*?)\"//) {
2567 $parser->YYData->{LAST_TOKEN} = $1;
2570 if (s/^(\d+)(\W|$)/$2/) {
2571 $parser->YYData->{LAST_TOKEN} = $1;
2572 return('CONSTANT',$1);
2574 if (s/^([\w_]+)//) {
2575 $parser->YYData->{LAST_TOKEN} = $1;
2577 /^(coclass|interface|import|importlib
2578 |include|cpp_quote|typedef
2579 |union|struct|enum|bitmap|pipe
2580 |void|const|unsigned|signed)$/x) {
2583 return('IDENTIFIER',$1);
2586 $parser->YYData->{LAST_TOKEN} = $1;
2594 my ($data,$filename) = @_;
2596 my $self = new Parse::Pidl::IDL;
2598 $self->YYData->{FILE} = $filename;
2599 $self->YYData->{INPUT} = $data;
2600 $self->YYData->{LINE} = 0;
2601 $self->YYData->{LAST_TOKEN} = "NONE";
2603 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2605 return CleanData($idl);
2610 my ($filename,$incdirs) = @_;
2612 my $saved_delim = $/;
2614 my $cpp = $ENV{CPP};
2615 if (! defined $cpp) {
2618 my $includes = join('',map { " -I$_" } @$incdirs);
2619 my $data = `$cpp -D__PIDL__$includes -xc $filename`;
2622 return parse_string($data, $filename);