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',
203 'interface_names' => 36
218 'property_list' => 42,
282 'property_list' => 42,
311 'existingtype' => 73,
314 'property_list' => 67,
333 'property_list' => 78
409 'optional_semicolon' => 102
426 'optional_semicolon' => 104
444 'existingtype' => 73,
447 'property_list' => 67,
462 'optional_identifier' => 107
497 'optional_identifier' => 109
512 'optional_identifier' => 110
521 'optional_identifier' => 111
676 'commalisttext' => 126
733 'commalisttext' => 130
827 'opt_union_body' => 137
839 'struct_body' => 140,
840 'opt_struct_body' => 142
849 'opt_enum_body' => 145,
859 'bitmap_body' => 148,
860 'opt_bitmap_body' => 146
1149 'union_elements' => 158
1161 'element_list1' => 159
1172 'identifier' => 160,
1173 'enum_element' => 161,
1174 'enum_elements' => 162
1192 'identifier' => 165,
1193 'bitmap_element' => 164,
1194 'bitmap_elements' => 163,
1195 'opt_bitmap_elements' => 166
1209 'base_element' => 167,
1210 'element_list2' => 169,
1211 'property_list' => 168
1297 'optional_base_element' => 181,
1298 'property_list' => 180
1307 'base_element' => 183,
1308 'property_list' => 168
1358 'existingtype' => 73,
1361 'property_list' => 67,
1490 'base_or_empty' => 197,
1491 'base_element' => 198,
1492 'empty_element' => 199,
1493 'property_list' => 200
1529 'identifier' => 160,
1530 'enum_element' => 203
1538 'identifier' => 165,
1539 'bitmap_element' => 204
1568 'base_element' => 207,
1569 'property_list' => 168
1645 'existingtype' => 73,
1648 'property_list' => 67,
1780 #line 19 "pidl/idl.yp"
1781 { push(@{$_[1]}, $_[2]); $_[1] }
1786 #line 20 "pidl/idl.yp"
1787 { push(@{$_[1]}, $_[2]); $_[1] }
1792 #line 21 "pidl/idl.yp"
1793 { push(@{$_[1]}, $_[2]); $_[1] }
1798 #line 22 "pidl/idl.yp"
1799 { push(@{$_[1]}, $_[2]); $_[1] }
1804 #line 23 "pidl/idl.yp"
1805 { push(@{$_[1]}, $_[2]); $_[1] }
1810 #line 26 "pidl/idl.yp"
1814 "FILE" => $_[0]->YYData->{FILE},
1815 "LINE" => $_[0]->YYData->{LINE}
1821 #line 33 "pidl/idl.yp"
1823 "TYPE" => "INCLUDE",
1825 "FILE" => $_[0]->YYData->{FILE},
1826 "LINE" => $_[0]->YYData->{LINE}
1832 #line 40 "pidl/idl.yp"
1834 "TYPE" => "IMPORTLIB",
1836 "FILE" => $_[0]->YYData->{FILE},
1837 "LINE" => $_[0]->YYData->{LINE}
1843 #line 49 "pidl/idl.yp"
1849 #line 50 "pidl/idl.yp"
1850 { push(@{$_[1]}, $_[3]); $_[1] }
1855 #line 54 "pidl/idl.yp"
1857 "TYPE" => "COCLASS",
1858 "PROPERTIES" => $_[1],
1861 "FILE" => $_[0]->YYData->{FILE},
1862 "LINE" => $_[0]->YYData->{LINE},
1866 'interface_names', 0, undef
1869 'interface_names', 4,
1871 #line 66 "pidl/idl.yp"
1872 { push(@{$_[1]}, $_[2]); $_[1] }
1877 #line 70 "pidl/idl.yp"
1879 "TYPE" => "INTERFACE",
1880 "PROPERTIES" => $_[1],
1883 "FILE" => $_[0]->YYData->{FILE},
1884 "LINE" => $_[0]->YYData->{LINE},
1890 #line 81 "pidl/idl.yp"
1896 #line 82 "pidl/idl.yp"
1897 { push(@{$_[1]}, $_[2]); $_[1] }
1900 'definition', 1, undef
1903 'definition', 1, undef
1906 'definition', 1, undef
1909 'definition', 1, undef
1912 'definition', 1, undef
1917 #line 90 "pidl/idl.yp"
1921 "POINTERS" => $_[3],
1924 "FILE" => $_[0]->YYData->{FILE},
1925 "LINE" => $_[0]->YYData->{LINE},
1931 #line 100 "pidl/idl.yp"
1935 "POINTERS" => $_[3],
1937 "ARRAY_LEN" => $_[5],
1939 "FILE" => $_[0]->YYData->{FILE},
1940 "LINE" => $_[0]->YYData->{LINE},
1946 #line 114 "pidl/idl.yp"
1948 "TYPE" => "FUNCTION",
1950 "RETURN_TYPE" => $_[2],
1951 "PROPERTIES" => $_[1],
1952 "ELEMENTS" => $_[5],
1953 "FILE" => $_[0]->YYData->{FILE},
1954 "LINE" => $_[0]->YYData->{LINE},
1960 #line 126 "pidl/idl.yp"
1962 "TYPE" => "DECLARE",
1965 "FILE" => $_[0]->YYData->{FILE},
1966 "LINE" => $_[0]->YYData->{LINE},
1970 'decl_type', 1, undef
1973 'decl_type', 1, undef
1976 'decl_type', 1, undef
1981 #line 139 "pidl/idl.yp"
1984 "PROPERTIES" => $_[1]
1990 #line 146 "pidl/idl.yp"
1993 "PROPERTIES" => $_[1]
1999 #line 153 "pidl/idl.yp"
2002 "PROPERTIES" => $_[1]
2008 #line 160 "pidl/idl.yp"
2010 "TYPE" => "TYPEDEF",
2011 "PROPERTIES" => $_[1],
2014 "ARRAY_LEN" => $_[5],
2015 "FILE" => $_[0]->YYData->{FILE},
2016 "LINE" => $_[0]->YYData->{LINE},
2020 'usertype', 1, undef
2023 'usertype', 1, undef
2026 'usertype', 1, undef
2029 'usertype', 1, undef
2034 #line 173 "pidl/idl.yp"
2046 #line 178 "pidl/idl.yp"
2047 { ($_[1]?$_[1]:"signed") ." $_[2]" }
2050 'existingtype', 1, undef
2061 #line 182 "pidl/idl.yp"
2067 #line 184 "pidl/idl.yp"
2071 'opt_enum_body', 0, undef
2074 'opt_enum_body', 1, undef
2079 #line 187 "pidl/idl.yp"
2082 "PROPERTIES" => $_[1],
2090 #line 196 "pidl/idl.yp"
2096 #line 197 "pidl/idl.yp"
2097 { push(@{$_[1]}, $_[3]); $_[1] }
2100 'enum_element', 1, undef
2105 #line 201 "pidl/idl.yp"
2106 { "$_[1]$_[2]$_[3]" }
2111 #line 204 "pidl/idl.yp"
2115 'opt_bitmap_body', 0, undef
2118 'opt_bitmap_body', 1, undef
2123 #line 207 "pidl/idl.yp"
2126 "PROPERTIES" => $_[1],
2132 'bitmap_elements', 1,
2134 #line 216 "pidl/idl.yp"
2138 'bitmap_elements', 3,
2140 #line 217 "pidl/idl.yp"
2141 { push(@{$_[1]}, $_[3]); $_[1] }
2144 'opt_bitmap_elements', 0, undef
2147 'opt_bitmap_elements', 1, undef
2150 'bitmap_element', 3,
2152 #line 222 "pidl/idl.yp"
2153 { "$_[1] ( $_[3] )" }
2158 #line 225 "pidl/idl.yp"
2162 'opt_struct_body', 0, undef
2165 'opt_struct_body', 1, undef
2170 #line 229 "pidl/idl.yp"
2173 "PROPERTIES" => $_[1],
2181 #line 238 "pidl/idl.yp"
2185 "PROPERTIES" => $_[1],
2188 "FILE" => $_[0]->YYData->{FILE},
2189 "LINE" => $_[0]->YYData->{LINE},
2193 'base_or_empty', 2, undef
2196 'base_or_empty', 1, undef
2199 'optional_base_element', 2,
2201 #line 252 "pidl/idl.yp"
2202 { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2205 'union_elements', 0, undef
2208 'union_elements', 2,
2210 #line 257 "pidl/idl.yp"
2211 { push(@{$_[1]}, $_[2]); $_[1] }
2216 #line 260 "pidl/idl.yp"
2220 'opt_union_body', 0, undef
2223 'opt_union_body', 1, undef
2228 #line 264 "pidl/idl.yp"
2231 "PROPERTIES" => $_[1],
2239 #line 273 "pidl/idl.yp"
2243 "PROPERTIES" => $_[1],
2244 "POINTERS" => $_[3],
2245 "ARRAY_LEN" => $_[5],
2246 "FILE" => $_[0]->YYData->{FILE},
2247 "LINE" => $_[0]->YYData->{LINE},
2253 #line 287 "pidl/idl.yp"
2259 #line 288 "pidl/idl.yp"
2265 #line 292 "pidl/idl.yp"
2271 #line 293 "pidl/idl.yp"
2272 { push(@{$_[1]}, $_[2]); $_[1] }
2275 'element_list2', 0, undef
2278 'element_list2', 1, undef
2283 #line 299 "pidl/idl.yp"
2289 #line 300 "pidl/idl.yp"
2290 { push(@{$_[1]}, $_[3]); $_[1] }
2293 'array_len', 0, undef
2298 #line 305 "pidl/idl.yp"
2299 { push(@{$_[3]}, "*"); $_[3] }
2304 #line 306 "pidl/idl.yp"
2305 { push(@{$_[4]}, "$_[2]"); $_[4] }
2308 'property_list', 0, undef
2313 #line 312 "pidl/idl.yp"
2314 { FlattenHash([$_[1],$_[3]]); }
2319 #line 315 "pidl/idl.yp"
2325 #line 316 "pidl/idl.yp"
2326 { FlattenHash([$_[1], $_[3]]); }
2331 #line 319 "pidl/idl.yp"
2332 {{ "$_[1]" => "1" }}
2337 #line 320 "pidl/idl.yp"
2338 {{ "$_[1]" => "$_[3]" }}
2341 'listtext', 1, undef
2346 #line 325 "pidl/idl.yp"
2350 'commalisttext', 1, undef
2355 #line 330 "pidl/idl.yp"
2361 #line 334 "pidl/idl.yp"
2376 #line 336 "pidl/idl.yp"
2377 { "$_[1]$_[2]$_[3]" }
2382 #line 337 "pidl/idl.yp"
2383 { "$_[1]$_[2]$_[3]" }
2388 #line 338 "pidl/idl.yp"
2389 { "$_[1]$_[2]$_[3]" }
2394 #line 339 "pidl/idl.yp"
2395 { "$_[1]$_[2]$_[3]" }
2400 #line 340 "pidl/idl.yp"
2401 { "$_[1]$_[2]$_[3]" }
2406 #line 341 "pidl/idl.yp"
2407 { "$_[1]$_[2]$_[3]" }
2412 #line 342 "pidl/idl.yp"
2413 { "$_[1]$_[2]$_[3]" }
2418 #line 343 "pidl/idl.yp"
2419 { "$_[1]$_[2]$_[3]" }
2424 #line 344 "pidl/idl.yp"
2425 { "$_[1]$_[2]$_[3]" }
2430 #line 345 "pidl/idl.yp"
2431 { "$_[1]$_[2]$_[3]" }
2436 #line 346 "pidl/idl.yp"
2437 { "$_[1]$_[2]$_[3]" }
2442 #line 347 "pidl/idl.yp"
2443 { "$_[1]$_[2]$_[3]" }
2448 #line 348 "pidl/idl.yp"
2449 { "$_[1]$_[2]$_[3]" }
2454 #line 349 "pidl/idl.yp"
2455 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2460 #line 350 "pidl/idl.yp"
2461 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2464 'identifier', 1, undef
2467 'optional_identifier', 1, undef
2470 'optional_identifier', 0, undef
2473 'constant', 1, undef
2478 #line 364 "pidl/idl.yp"
2482 'optional_semicolon', 0, undef
2485 'optional_semicolon', 1, undef
2489 bless($self,$class);
2492 #line 375 "pidl/idl.yp"
2495 use Parse::Pidl qw(error);
2497 #####################################################################
2498 # flatten an array of hashes into a single hash
2504 for my $k (keys %{$d}) {
2513 #####################################################################
2514 # traverse a perl data structure removing any empty arrays or
2515 # hashes and any hash elements that map to undef
2520 return undef if (not defined($v));
2521 if (ref($v) eq "ARRAY") {
2522 foreach my $i (0 .. $#{$v}) {
2523 CleanData($v->[$i]);
2525 # this removes any undefined elements from the array
2526 @{$v} = grep { defined $_ } @{$v};
2527 } elsif (ref($v) eq "HASH") {
2528 foreach my $x (keys %{$v}) {
2529 CleanData($v->{$x});
2530 if (!defined $v->{$x}) { delete($v->{$x}); next; }
2537 if (exists $_[0]->YYData->{ERRMSG}) {
2538 error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2539 delete $_[0]->YYData->{ERRMSG};
2542 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2544 error($_[0]->YYData, "Syntax error near '$last_token'");
2551 $parser->YYData->{INPUT} or return('',undef);
2554 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2556 for ($parser->YYData->{INPUT}) {
2558 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2559 $parser->YYData->{LINE} = $1-1;
2560 $parser->YYData->{FILE} = $2;
2563 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2564 $parser->YYData->{LINE} = $1-1;
2565 $parser->YYData->{FILE} = $2;
2568 if (s/^(\#.*)$//m) {
2573 $parser->YYData->{LINE}++;
2576 if (s/^\"(.*?)\"//) {
2577 $parser->YYData->{LAST_TOKEN} = $1;
2580 if (s/^(\d+)(\W|$)/$2/) {
2581 $parser->YYData->{LAST_TOKEN} = $1;
2582 return('CONSTANT',$1);
2584 if (s/^([\w_]+)//) {
2585 $parser->YYData->{LAST_TOKEN} = $1;
2587 /^(coclass|interface|const|typedef|declare|union
2588 |struct|enum|bitmap|void|unsigned|signed|import|include
2592 return('IDENTIFIER',$1);
2595 $parser->YYData->{LAST_TOKEN} = $1;
2603 my ($data,$filename) = @_;
2605 my $self = new Parse::Pidl::IDL;
2607 $self->YYData->{FILE} = $filename;
2608 $self->YYData->{INPUT} = $data;
2609 $self->YYData->{LINE} = 0;
2610 $self->YYData->{LAST_TOKEN} = "NONE";
2612 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2614 return CleanData($idl);
2619 my ($filename,$incdirs) = @_;
2621 my $saved_delim = $/;
2623 my $cpp = $ENV{CPP};
2624 if (! defined $cpp) {
2627 my $includes = join('',map { " -I$_" } @$incdirs);
2628 my $data = `$cpp -D__PIDL__$includes -xc $filename`;
2631 return parse_string($data, $filename);