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',
229 'interface_names' => 41
243 'property_list' => 47,
276 'commalisttext' => 59
305 'property_list' => 47,
333 'existingtype' => 76,
336 'property_list' => 70,
418 'optional_semicolon' => 100
435 'optional_semicolon' => 102
453 'existingtype' => 76,
456 'property_list' => 70,
471 'optional_identifier' => 105
506 'optional_identifier' => 107
521 'optional_identifier' => 108
530 'optional_identifier' => 109
660 'commalisttext' => 119
717 'commalisttext' => 123
811 'opt_union_body' => 130
823 'struct_body' => 133,
824 'opt_struct_body' => 135
833 'opt_enum_body' => 138,
843 'bitmap_body' => 141,
844 'opt_bitmap_body' => 139
1099 'union_elements' => 149
1111 'element_list1' => 150
1122 'identifier' => 151,
1123 'enum_element' => 152,
1124 'enum_elements' => 153
1142 'identifier' => 156,
1143 'bitmap_element' => 155,
1144 'bitmap_elements' => 154,
1145 'opt_bitmap_elements' => 157
1159 'base_element' => 158,
1160 'element_list2' => 160,
1161 'property_list' => 159
1230 'optional_base_element' => 171,
1231 'property_list' => 170
1240 'base_element' => 173,
1241 'property_list' => 159
1291 'existingtype' => 76,
1294 'property_list' => 70,
1403 'base_or_empty' => 187,
1404 'base_element' => 188,
1405 'empty_element' => 189,
1406 'property_list' => 190
1442 'identifier' => 151,
1443 'enum_element' => 193
1451 'identifier' => 156,
1452 'bitmap_element' => 194
1481 'base_element' => 197,
1482 'property_list' => 159
1558 'existingtype' => 76,
1561 'property_list' => 70,
1693 #line 19 "pidl/idl.yp"
1694 { push(@{$_[1]}, $_[2]); $_[1] }
1699 #line 20 "pidl/idl.yp"
1700 { push(@{$_[1]}, $_[2]); $_[1] }
1705 #line 21 "pidl/idl.yp"
1706 { push(@{$_[1]}, $_[2]); $_[1] }
1711 #line 22 "pidl/idl.yp"
1712 { push(@{$_[1]}, $_[2]); $_[1] }
1717 #line 23 "pidl/idl.yp"
1718 { push(@{$_[1]}, $_[2]); $_[1] }
1723 #line 24 "pidl/idl.yp"
1724 { push(@{$_[1]}, $_[2]); $_[1] }
1729 #line 27 "pidl/idl.yp"
1733 "FILE" => $_[0]->YYData->{FILE},
1734 "LINE" => $_[0]->YYData->{LINE}
1740 #line 34 "pidl/idl.yp"
1742 "TYPE" => "INCLUDE",
1744 "FILE" => $_[0]->YYData->{FILE},
1745 "LINE" => $_[0]->YYData->{LINE}
1751 #line 41 "pidl/idl.yp"
1753 "TYPE" => "IMPORTLIB",
1755 "FILE" => $_[0]->YYData->{FILE},
1756 "LINE" => $_[0]->YYData->{LINE}
1762 #line 50 "pidl/idl.yp"
1768 #line 51 "pidl/idl.yp"
1769 { push(@{$_[1]}, $_[3]); $_[1] }
1774 #line 55 "pidl/idl.yp"
1776 "TYPE" => "COCLASS",
1777 "PROPERTIES" => $_[1],
1780 "FILE" => $_[0]->YYData->{FILE},
1781 "LINE" => $_[0]->YYData->{LINE},
1785 'interface_names', 0, undef
1788 'interface_names', 4,
1790 #line 67 "pidl/idl.yp"
1791 { push(@{$_[1]}, $_[2]); $_[1] }
1796 #line 71 "pidl/idl.yp"
1798 "TYPE" => "INTERFACE",
1799 "PROPERTIES" => $_[1],
1802 "FILE" => $_[0]->YYData->{FILE},
1803 "LINE" => $_[0]->YYData->{LINE},
1809 #line 82 "pidl/idl.yp"
1811 "TYPE" => "CPP_QUOTE",
1812 "FILE" => $_[0]->YYData->{FILE},
1813 "LINE" => $_[0]->YYData->{LINE},
1820 #line 91 "pidl/idl.yp"
1826 #line 92 "pidl/idl.yp"
1827 { push(@{$_[1]}, $_[2]); $_[1] }
1830 'definition', 1, undef
1833 'definition', 1, undef
1836 'definition', 1, undef
1839 'definition', 1, undef
1844 #line 100 "pidl/idl.yp"
1848 "POINTERS" => $_[3],
1851 "FILE" => $_[0]->YYData->{FILE},
1852 "LINE" => $_[0]->YYData->{LINE},
1858 #line 110 "pidl/idl.yp"
1862 "POINTERS" => $_[3],
1864 "ARRAY_LEN" => $_[5],
1866 "FILE" => $_[0]->YYData->{FILE},
1867 "LINE" => $_[0]->YYData->{LINE},
1873 #line 124 "pidl/idl.yp"
1875 "TYPE" => "FUNCTION",
1877 "RETURN_TYPE" => $_[2],
1878 "PROPERTIES" => $_[1],
1879 "ELEMENTS" => $_[5],
1880 "FILE" => $_[0]->YYData->{FILE},
1881 "LINE" => $_[0]->YYData->{LINE},
1887 #line 136 "pidl/idl.yp"
1889 "TYPE" => "TYPEDEF",
1890 "PROPERTIES" => $_[1],
1893 "ARRAY_LEN" => $_[5],
1894 "FILE" => $_[0]->YYData->{FILE},
1895 "LINE" => $_[0]->YYData->{LINE},
1899 'usertype', 1, undef
1902 'usertype', 1, undef
1905 'usertype', 1, undef
1908 'usertype', 1, undef
1913 #line 149 "pidl/idl.yp"
1925 #line 154 "pidl/idl.yp"
1926 { ($_[1]?$_[1]:"signed") ." $_[2]" }
1929 'existingtype', 1, undef
1940 #line 158 "pidl/idl.yp"
1946 #line 160 "pidl/idl.yp"
1950 'opt_enum_body', 0, undef
1953 'opt_enum_body', 1, undef
1958 #line 163 "pidl/idl.yp"
1961 "PROPERTIES" => $_[1],
1969 #line 172 "pidl/idl.yp"
1975 #line 173 "pidl/idl.yp"
1976 { push(@{$_[1]}, $_[3]); $_[1] }
1979 'enum_element', 1, undef
1984 #line 177 "pidl/idl.yp"
1985 { "$_[1]$_[2]$_[3]" }
1990 #line 180 "pidl/idl.yp"
1994 'opt_bitmap_body', 0, undef
1997 'opt_bitmap_body', 1, undef
2002 #line 183 "pidl/idl.yp"
2005 "PROPERTIES" => $_[1],
2011 'bitmap_elements', 1,
2013 #line 192 "pidl/idl.yp"
2017 'bitmap_elements', 3,
2019 #line 193 "pidl/idl.yp"
2020 { push(@{$_[1]}, $_[3]); $_[1] }
2023 'opt_bitmap_elements', 0, undef
2026 'opt_bitmap_elements', 1, undef
2029 'bitmap_element', 3,
2031 #line 198 "pidl/idl.yp"
2032 { "$_[1] ( $_[3] )" }
2037 #line 201 "pidl/idl.yp"
2041 'opt_struct_body', 0, undef
2044 'opt_struct_body', 1, undef
2049 #line 205 "pidl/idl.yp"
2052 "PROPERTIES" => $_[1],
2060 #line 214 "pidl/idl.yp"
2064 "PROPERTIES" => $_[1],
2067 "FILE" => $_[0]->YYData->{FILE},
2068 "LINE" => $_[0]->YYData->{LINE},
2072 'base_or_empty', 2, undef
2075 'base_or_empty', 1, undef
2078 'optional_base_element', 2,
2080 #line 228 "pidl/idl.yp"
2081 { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2084 'union_elements', 0, undef
2087 'union_elements', 2,
2089 #line 233 "pidl/idl.yp"
2090 { push(@{$_[1]}, $_[2]); $_[1] }
2095 #line 236 "pidl/idl.yp"
2099 'opt_union_body', 0, undef
2102 'opt_union_body', 1, undef
2107 #line 240 "pidl/idl.yp"
2110 "PROPERTIES" => $_[1],
2118 #line 249 "pidl/idl.yp"
2122 "PROPERTIES" => $_[1],
2123 "POINTERS" => $_[3],
2124 "ARRAY_LEN" => $_[5],
2125 "FILE" => $_[0]->YYData->{FILE},
2126 "LINE" => $_[0]->YYData->{LINE},
2132 #line 263 "pidl/idl.yp"
2138 #line 264 "pidl/idl.yp"
2144 #line 268 "pidl/idl.yp"
2150 #line 269 "pidl/idl.yp"
2151 { push(@{$_[1]}, $_[2]); $_[1] }
2154 'element_list2', 0, undef
2157 'element_list2', 1, undef
2162 #line 275 "pidl/idl.yp"
2168 #line 276 "pidl/idl.yp"
2169 { push(@{$_[1]}, $_[3]); $_[1] }
2172 'array_len', 0, undef
2177 #line 281 "pidl/idl.yp"
2178 { push(@{$_[3]}, "*"); $_[3] }
2183 #line 282 "pidl/idl.yp"
2184 { push(@{$_[4]}, "$_[2]"); $_[4] }
2187 'property_list', 0, undef
2192 #line 288 "pidl/idl.yp"
2193 { FlattenHash([$_[1],$_[3]]); }
2198 #line 291 "pidl/idl.yp"
2204 #line 292 "pidl/idl.yp"
2205 { FlattenHash([$_[1], $_[3]]); }
2210 #line 295 "pidl/idl.yp"
2211 {{ "$_[1]" => "1" }}
2216 #line 296 "pidl/idl.yp"
2217 {{ "$_[1]" => "$_[3]" }}
2220 'commalisttext', 1, undef
2225 #line 301 "pidl/idl.yp"
2231 #line 305 "pidl/idl.yp"
2246 #line 307 "pidl/idl.yp"
2247 { "$_[1]$_[2]$_[3]" }
2252 #line 308 "pidl/idl.yp"
2253 { "$_[1]$_[2]$_[3]" }
2258 #line 309 "pidl/idl.yp"
2259 { "$_[1]$_[2]$_[3]" }
2264 #line 310 "pidl/idl.yp"
2265 { "$_[1]$_[2]$_[3]" }
2270 #line 311 "pidl/idl.yp"
2271 { "$_[1]$_[2]$_[3]" }
2276 #line 312 "pidl/idl.yp"
2277 { "$_[1]$_[2]$_[3]" }
2282 #line 313 "pidl/idl.yp"
2283 { "$_[1]$_[2]$_[3]" }
2288 #line 314 "pidl/idl.yp"
2289 { "$_[1]$_[2]$_[3]" }
2294 #line 315 "pidl/idl.yp"
2295 { "$_[1]$_[2]$_[3]" }
2300 #line 316 "pidl/idl.yp"
2301 { "$_[1]$_[2]$_[3]" }
2306 #line 317 "pidl/idl.yp"
2307 { "$_[1]$_[2]$_[3]" }
2312 #line 318 "pidl/idl.yp"
2313 { "$_[1]$_[2]$_[3]" }
2318 #line 319 "pidl/idl.yp"
2319 { "$_[1]$_[2]$_[3]" }
2324 #line 320 "pidl/idl.yp"
2325 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2330 #line 321 "pidl/idl.yp"
2331 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2334 'identifier', 1, undef
2337 'optional_identifier', 1, undef
2340 'optional_identifier', 0, undef
2343 'constant', 1, undef
2348 #line 335 "pidl/idl.yp"
2352 'optional_semicolon', 0, undef
2355 'optional_semicolon', 1, undef
2359 bless($self,$class);
2362 #line 346 "pidl/idl.yp"
2365 use Parse::Pidl qw(error);
2367 #####################################################################
2368 # flatten an array of hashes into a single hash
2374 for my $k (keys %{$d}) {
2383 #####################################################################
2384 # traverse a perl data structure removing any empty arrays or
2385 # hashes and any hash elements that map to undef
2390 return undef if (not defined($v));
2391 if (ref($v) eq "ARRAY") {
2392 foreach my $i (0 .. $#{$v}) {
2393 CleanData($v->[$i]);
2395 # this removes any undefined elements from the array
2396 @{$v} = grep { defined $_ } @{$v};
2397 } elsif (ref($v) eq "HASH") {
2398 foreach my $x (keys %{$v}) {
2399 CleanData($v->{$x});
2400 if (!defined $v->{$x}) { delete($v->{$x}); next; }
2407 if (exists $_[0]->YYData->{ERRMSG}) {
2408 error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2409 delete $_[0]->YYData->{ERRMSG};
2412 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2414 error($_[0]->YYData, "Syntax error near '$last_token'");
2421 $parser->YYData->{INPUT} or return('',undef);
2424 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2426 for ($parser->YYData->{INPUT}) {
2428 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2429 $parser->YYData->{LINE} = $1-1;
2430 $parser->YYData->{FILE} = $2;
2433 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2434 $parser->YYData->{LINE} = $1-1;
2435 $parser->YYData->{FILE} = $2;
2438 if (s/^(\#.*)$//m) {
2443 $parser->YYData->{LINE}++;
2446 if (s/^\"(.*?)\"//) {
2447 $parser->YYData->{LAST_TOKEN} = $1;
2450 if (s/^(\d+)(\W|$)/$2/) {
2451 $parser->YYData->{LAST_TOKEN} = $1;
2452 return('CONSTANT',$1);
2454 if (s/^([\w_]+)//) {
2455 $parser->YYData->{LAST_TOKEN} = $1;
2457 /^(coclass|interface|const|typedef|union|cpp_quote
2458 |struct|enum|bitmap|void|unsigned|signed|import|include
2462 return('IDENTIFIER',$1);
2465 $parser->YYData->{LAST_TOKEN} = $1;
2473 my ($data,$filename) = @_;
2475 my $self = new Parse::Pidl::IDL;
2477 $self->YYData->{FILE} = $filename;
2478 $self->YYData->{INPUT} = $data;
2479 $self->YYData->{LINE} = 0;
2480 $self->YYData->{LAST_TOKEN} = "NONE";
2482 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2484 return CleanData($idl);
2489 my ($filename,$incdirs) = @_;
2491 my $saved_delim = $/;
2493 my $cpp = $ENV{CPP};
2494 if (! defined $cpp) {
2497 my $includes = join('',map { " -I$_" } @$incdirs);
2498 my $data = `$cpp -D__PIDL__$includes -xc $filename`;
2501 return parse_string($data, $filename);