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
296 'property_list' => 59,
352 'optional_semicolon' => 84
383 'property_list' => 59,
411 'existingtype' => 99,
414 'property_list' => 93,
545 'commalisttext' => 111
602 'commalisttext' => 115
695 'optional_semicolon' => 122
713 'existingtype' => 99,
716 'property_list' => 93,
731 'optional_identifier' => 125
766 'optional_identifier' => 127
781 'optional_identifier' => 128
790 'optional_identifier' => 129
1053 'union_body' => 137,
1054 'opt_union_body' => 135
1066 'struct_body' => 138,
1067 'opt_struct_body' => 140
1076 'opt_enum_body' => 143,
1086 'bitmap_body' => 146,
1087 'opt_bitmap_body' => 144
1147 'union_elements' => 154
1159 'element_list1' => 155
1170 'identifier' => 156,
1171 'enum_element' => 157,
1172 'enum_elements' => 158
1190 'identifier' => 161,
1191 'bitmap_element' => 160,
1192 'bitmap_elements' => 159,
1193 'opt_bitmap_elements' => 162
1207 'base_element' => 163,
1208 'element_list2' => 165,
1209 'property_list' => 164
1281 'optional_base_element' => 174,
1282 'property_list' => 173
1291 'base_element' => 176,
1292 'property_list' => 164
1342 'existingtype' => 99,
1345 'property_list' => 93,
1423 'base_or_empty' => 190,
1424 'base_element' => 191,
1425 'empty_element' => 192,
1426 'property_list' => 193
1462 'identifier' => 156,
1463 'enum_element' => 196
1471 'identifier' => 161,
1472 'bitmap_element' => 197
1501 'base_element' => 200,
1502 'property_list' => 164
1578 'existingtype' => 99,
1581 'property_list' => 93,
1713 #line 19 "pidl/idl.yp"
1714 { push(@{$_[1]}, $_[2]); $_[1] }
1719 #line 20 "pidl/idl.yp"
1720 { push(@{$_[1]}, $_[2]); $_[1] }
1725 #line 21 "pidl/idl.yp"
1726 { push(@{$_[1]}, $_[2]); $_[1] }
1731 #line 22 "pidl/idl.yp"
1732 { push(@{$_[1]}, $_[2]); $_[1] }
1737 #line 23 "pidl/idl.yp"
1738 { push(@{$_[1]}, $_[2]); $_[1] }
1743 #line 24 "pidl/idl.yp"
1744 { push(@{$_[1]}, $_[2]); $_[1] }
1749 #line 27 "pidl/idl.yp"
1753 "FILE" => $_[0]->YYData->{FILE},
1754 "LINE" => $_[0]->YYData->{LINE}
1760 #line 34 "pidl/idl.yp"
1762 "TYPE" => "INCLUDE",
1764 "FILE" => $_[0]->YYData->{FILE},
1765 "LINE" => $_[0]->YYData->{LINE}
1771 #line 41 "pidl/idl.yp"
1773 "TYPE" => "IMPORTLIB",
1775 "FILE" => $_[0]->YYData->{FILE},
1776 "LINE" => $_[0]->YYData->{LINE}
1782 #line 50 "pidl/idl.yp"
1788 #line 51 "pidl/idl.yp"
1789 { push(@{$_[1]}, $_[3]); $_[1] }
1794 #line 55 "pidl/idl.yp"
1796 "TYPE" => "COCLASS",
1797 "PROPERTIES" => $_[1],
1800 "FILE" => $_[0]->YYData->{FILE},
1801 "LINE" => $_[0]->YYData->{LINE},
1805 'interface_names', 0, undef
1808 'interface_names', 4,
1810 #line 67 "pidl/idl.yp"
1811 { push(@{$_[1]}, $_[2]); $_[1] }
1816 #line 71 "pidl/idl.yp"
1818 "TYPE" => "INTERFACE",
1819 "PROPERTIES" => $_[1],
1823 "FILE" => $_[0]->YYData->{FILE},
1824 "LINE" => $_[0]->YYData->{LINE},
1828 'base_interface', 0, undef
1831 'base_interface', 2,
1833 #line 84 "pidl/idl.yp"
1839 #line 89 "pidl/idl.yp"
1841 "TYPE" => "CPP_QUOTE",
1842 "FILE" => $_[0]->YYData->{FILE},
1843 "LINE" => $_[0]->YYData->{LINE},
1850 #line 98 "pidl/idl.yp"
1856 #line 99 "pidl/idl.yp"
1857 { push(@{$_[1]}, $_[2]); $_[1] }
1860 'definition', 1, undef
1863 'definition', 1, undef
1866 'definition', 1, undef
1869 'definition', 1, undef
1874 #line 107 "pidl/idl.yp"
1878 "POINTERS" => $_[3],
1881 "FILE" => $_[0]->YYData->{FILE},
1882 "LINE" => $_[0]->YYData->{LINE},
1888 #line 117 "pidl/idl.yp"
1892 "POINTERS" => $_[3],
1894 "ARRAY_LEN" => $_[5],
1896 "FILE" => $_[0]->YYData->{FILE},
1897 "LINE" => $_[0]->YYData->{LINE},
1903 #line 131 "pidl/idl.yp"
1905 "TYPE" => "FUNCTION",
1907 "RETURN_TYPE" => $_[2],
1908 "PROPERTIES" => $_[1],
1909 "ELEMENTS" => $_[5],
1910 "FILE" => $_[0]->YYData->{FILE},
1911 "LINE" => $_[0]->YYData->{LINE},
1917 #line 143 "pidl/idl.yp"
1919 "TYPE" => "TYPEDEF",
1920 "PROPERTIES" => $_[1],
1923 "ARRAY_LEN" => $_[5],
1924 "FILE" => $_[0]->YYData->{FILE},
1925 "LINE" => $_[0]->YYData->{LINE},
1929 'usertype', 1, undef
1932 'usertype', 1, undef
1935 'usertype', 1, undef
1938 'usertype', 1, undef
1943 #line 156 "pidl/idl.yp"
1955 #line 161 "pidl/idl.yp"
1956 { ($_[1]?$_[1]:"signed") ." $_[2]" }
1959 'existingtype', 1, undef
1970 #line 165 "pidl/idl.yp"
1976 #line 167 "pidl/idl.yp"
1980 'opt_enum_body', 0, undef
1983 'opt_enum_body', 1, undef
1988 #line 170 "pidl/idl.yp"
1991 "PROPERTIES" => $_[1],
1999 #line 179 "pidl/idl.yp"
2005 #line 180 "pidl/idl.yp"
2006 { push(@{$_[1]}, $_[3]); $_[1] }
2009 'enum_element', 1, undef
2014 #line 184 "pidl/idl.yp"
2015 { "$_[1]$_[2]$_[3]" }
2020 #line 187 "pidl/idl.yp"
2024 'opt_bitmap_body', 0, undef
2027 'opt_bitmap_body', 1, undef
2032 #line 190 "pidl/idl.yp"
2035 "PROPERTIES" => $_[1],
2041 'bitmap_elements', 1,
2043 #line 199 "pidl/idl.yp"
2047 'bitmap_elements', 3,
2049 #line 200 "pidl/idl.yp"
2050 { push(@{$_[1]}, $_[3]); $_[1] }
2053 'opt_bitmap_elements', 0, undef
2056 'opt_bitmap_elements', 1, undef
2059 'bitmap_element', 3,
2061 #line 205 "pidl/idl.yp"
2062 { "$_[1] ( $_[3] )" }
2067 #line 208 "pidl/idl.yp"
2071 'opt_struct_body', 0, undef
2074 'opt_struct_body', 1, undef
2079 #line 212 "pidl/idl.yp"
2082 "PROPERTIES" => $_[1],
2090 #line 221 "pidl/idl.yp"
2094 "PROPERTIES" => $_[1],
2097 "FILE" => $_[0]->YYData->{FILE},
2098 "LINE" => $_[0]->YYData->{LINE},
2102 'base_or_empty', 2, undef
2105 'base_or_empty', 1, undef
2108 'optional_base_element', 2,
2110 #line 235 "pidl/idl.yp"
2111 { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2114 'union_elements', 0, undef
2117 'union_elements', 2,
2119 #line 240 "pidl/idl.yp"
2120 { push(@{$_[1]}, $_[2]); $_[1] }
2125 #line 243 "pidl/idl.yp"
2129 'opt_union_body', 0, undef
2132 'opt_union_body', 1, undef
2137 #line 247 "pidl/idl.yp"
2140 "PROPERTIES" => $_[1],
2148 #line 256 "pidl/idl.yp"
2152 "PROPERTIES" => $_[1],
2153 "POINTERS" => $_[3],
2154 "ARRAY_LEN" => $_[5],
2155 "FILE" => $_[0]->YYData->{FILE},
2156 "LINE" => $_[0]->YYData->{LINE},
2162 #line 270 "pidl/idl.yp"
2168 #line 271 "pidl/idl.yp"
2174 #line 275 "pidl/idl.yp"
2180 #line 276 "pidl/idl.yp"
2181 { push(@{$_[1]}, $_[2]); $_[1] }
2184 'element_list2', 0, undef
2187 'element_list2', 1, undef
2192 #line 282 "pidl/idl.yp"
2198 #line 283 "pidl/idl.yp"
2199 { push(@{$_[1]}, $_[3]); $_[1] }
2202 'array_len', 0, undef
2207 #line 288 "pidl/idl.yp"
2208 { push(@{$_[3]}, "*"); $_[3] }
2213 #line 289 "pidl/idl.yp"
2214 { push(@{$_[4]}, "$_[2]"); $_[4] }
2217 'property_list', 0, undef
2222 #line 295 "pidl/idl.yp"
2223 { FlattenHash([$_[1],$_[3]]); }
2228 #line 298 "pidl/idl.yp"
2234 #line 299 "pidl/idl.yp"
2235 { FlattenHash([$_[1], $_[3]]); }
2240 #line 302 "pidl/idl.yp"
2241 {{ "$_[1]" => "1" }}
2246 #line 303 "pidl/idl.yp"
2247 {{ "$_[1]" => "$_[3]" }}
2250 'commalisttext', 1, undef
2255 #line 308 "pidl/idl.yp"
2261 #line 312 "pidl/idl.yp"
2276 #line 314 "pidl/idl.yp"
2277 { "$_[1]$_[2]$_[3]" }
2282 #line 315 "pidl/idl.yp"
2283 { "$_[1]$_[2]$_[3]" }
2288 #line 316 "pidl/idl.yp"
2289 { "$_[1]$_[2]$_[3]" }
2294 #line 317 "pidl/idl.yp"
2295 { "$_[1]$_[2]$_[3]" }
2300 #line 318 "pidl/idl.yp"
2301 { "$_[1]$_[2]$_[3]" }
2306 #line 319 "pidl/idl.yp"
2307 { "$_[1]$_[2]$_[3]" }
2312 #line 320 "pidl/idl.yp"
2313 { "$_[1]$_[2]$_[3]" }
2318 #line 321 "pidl/idl.yp"
2319 { "$_[1]$_[2]$_[3]" }
2324 #line 322 "pidl/idl.yp"
2325 { "$_[1]$_[2]$_[3]" }
2330 #line 323 "pidl/idl.yp"
2331 { "$_[1]$_[2]$_[3]" }
2336 #line 324 "pidl/idl.yp"
2337 { "$_[1]$_[2]$_[3]" }
2342 #line 325 "pidl/idl.yp"
2343 { "$_[1]$_[2]$_[3]" }
2348 #line 326 "pidl/idl.yp"
2349 { "$_[1]$_[2]$_[3]" }
2354 #line 327 "pidl/idl.yp"
2355 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2360 #line 328 "pidl/idl.yp"
2361 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2364 'identifier', 1, undef
2367 'optional_identifier', 1, undef
2370 'optional_identifier', 0, undef
2373 'constant', 1, undef
2378 #line 342 "pidl/idl.yp"
2382 'optional_semicolon', 0, undef
2385 'optional_semicolon', 1, undef
2389 bless($self,$class);
2392 #line 353 "pidl/idl.yp"
2395 use Parse::Pidl qw(error);
2397 #####################################################################
2398 # flatten an array of hashes into a single hash
2404 for my $k (keys %{$d}) {
2413 #####################################################################
2414 # traverse a perl data structure removing any empty arrays or
2415 # hashes and any hash elements that map to undef
2420 return undef if (not defined($v));
2421 if (ref($v) eq "ARRAY") {
2422 foreach my $i (0 .. $#{$v}) {
2423 CleanData($v->[$i]);
2425 # this removes any undefined elements from the array
2426 @{$v} = grep { defined $_ } @{$v};
2427 } elsif (ref($v) eq "HASH") {
2428 foreach my $x (keys %{$v}) {
2429 CleanData($v->{$x});
2430 if (!defined $v->{$x}) { delete($v->{$x}); next; }
2437 if (exists $_[0]->YYData->{ERRMSG}) {
2438 error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2439 delete $_[0]->YYData->{ERRMSG};
2442 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2444 error($_[0]->YYData, "Syntax error near '$last_token'");
2451 $parser->YYData->{INPUT} or return('',undef);
2454 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2456 for ($parser->YYData->{INPUT}) {
2458 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2459 $parser->YYData->{LINE} = $1-1;
2460 $parser->YYData->{FILE} = $2;
2463 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2464 $parser->YYData->{LINE} = $1-1;
2465 $parser->YYData->{FILE} = $2;
2468 if (s/^(\#.*)$//m) {
2473 $parser->YYData->{LINE}++;
2476 if (s/^\"(.*?)\"//) {
2477 $parser->YYData->{LAST_TOKEN} = $1;
2480 if (s/^(\d+)(\W|$)/$2/) {
2481 $parser->YYData->{LAST_TOKEN} = $1;
2482 return('CONSTANT',$1);
2484 if (s/^([\w_]+)//) {
2485 $parser->YYData->{LAST_TOKEN} = $1;
2487 /^(coclass|interface|const|typedef|union|cpp_quote
2488 |struct|enum|bitmap|void|unsigned|signed|import|include
2492 return('IDENTIFIER',$1);
2495 $parser->YYData->{LAST_TOKEN} = $1;
2503 my ($data,$filename) = @_;
2505 my $self = new Parse::Pidl::IDL;
2507 $self->YYData->{FILE} = $filename;
2508 $self->YYData->{INPUT} = $data;
2509 $self->YYData->{LINE} = 0;
2510 $self->YYData->{LAST_TOKEN} = "NONE";
2512 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2514 return CleanData($idl);
2519 my ($filename,$incdirs) = @_;
2521 my $saved_delim = $/;
2523 my $cpp = $ENV{CPP};
2524 if (! defined $cpp) {
2527 my $includes = join('',map { " -I$_" } @$incdirs);
2528 my $data = `$cpp -D__PIDL__$includes -xc $filename`;
2531 return parse_string($data, $filename);