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
1208 'optional_const' => 163,
1209 'element_list2' => 165
1281 'optional_base_element' => 174,
1282 'property_list' => 173
1291 'base_element' => 176,
1292 'property_list' => 177
1332 'base_element' => 184,
1333 'property_list' => 177
1408 'base_or_empty' => 191,
1409 'base_element' => 192,
1410 'empty_element' => 193,
1411 'property_list' => 194
1435 'existingtype' => 99,
1438 'property_list' => 93,
1469 'identifier' => 156,
1470 'enum_element' => 198
1478 'identifier' => 161,
1479 'bitmap_element' => 199
1508 'optional_const' => 201
1584 'existingtype' => 99,
1587 'property_list' => 93,
1654 'base_element' => 209,
1655 'property_list' => 177
1732 #line 20 "./../pidl/idl.yp"
1733 { push(@
{$_[1]}, $_[2]); $_[1] }
1738 #line 22 "./../pidl/idl.yp"
1739 { push(@
{$_[1]}, $_[2]); $_[1] }
1744 #line 24 "./../pidl/idl.yp"
1745 { push(@
{$_[1]}, $_[2]); $_[1] }
1750 #line 26 "./../pidl/idl.yp"
1751 { push(@
{$_[1]}, $_[2]); $_[1] }
1756 #line 28 "./../pidl/idl.yp"
1757 { push(@
{$_[1]}, $_[2]); $_[1] }
1762 #line 30 "./../pidl/idl.yp"
1763 { push(@
{$_[1]}, $_[2]); $_[1] }
1768 #line 35 "./../pidl/idl.yp"
1772 "FILE" => $_[0]->YYData->{FILE
},
1773 "LINE" => $_[0]->YYData->{LINE
},
1779 #line 45 "./../pidl/idl.yp"
1781 "TYPE" => "INCLUDE",
1783 "FILE" => $_[0]->YYData->{FILE
},
1784 "LINE" => $_[0]->YYData->{LINE
},
1790 #line 55 "./../pidl/idl.yp"
1792 "TYPE" => "IMPORTLIB",
1794 "FILE" => $_[0]->YYData->{FILE
},
1795 "LINE" => $_[0]->YYData->{LINE
},
1801 #line 64 "./../pidl/idl.yp"
1807 #line 66 "./../pidl/idl.yp"
1808 { push(@
{$_[1]}, $_[3]); $_[1] }
1813 #line 71 "./../pidl/idl.yp"
1815 "TYPE" => "COCLASS",
1816 "PROPERTIES" => $_[1],
1819 "FILE" => $_[0]->YYData->{FILE
},
1820 "LINE" => $_[0]->YYData->{LINE
},
1824 'interface_names', 0, undef
1827 'interface_names', 4,
1829 #line 84 "./../pidl/idl.yp"
1830 { push(@
{$_[1]}, $_[2]); $_[1] }
1835 #line 89 "./../pidl/idl.yp"
1837 "TYPE" => "INTERFACE",
1838 "PROPERTIES" => $_[1],
1842 "FILE" => $_[0]->YYData->{FILE
},
1843 "LINE" => $_[0]->YYData->{LINE
},
1847 'base_interface', 0, undef
1850 'base_interface', 2,
1852 #line 103 "./../pidl/idl.yp"
1858 #line 109 "./../pidl/idl.yp"
1860 "TYPE" => "CPP_QUOTE",
1862 "FILE" => $_[0]->YYData->{FILE
},
1863 "LINE" => $_[0]->YYData->{LINE
},
1869 #line 118 "./../pidl/idl.yp"
1875 #line 120 "./../pidl/idl.yp"
1876 { push(@
{$_[1]}, $_[2]); $_[1] }
1879 'definition', 1, undef
1882 'definition', 1, undef
1885 'definition', 1, undef
1888 'definition', 1, undef
1893 #line 135 "./../pidl/idl.yp"
1897 "POINTERS" => $_[3],
1900 "FILE" => $_[0]->YYData->{FILE
},
1901 "LINE" => $_[0]->YYData->{LINE
},
1907 #line 146 "./../pidl/idl.yp"
1911 "POINTERS" => $_[3],
1913 "ARRAY_LEN" => $_[5],
1915 "FILE" => $_[0]->YYData->{FILE
},
1916 "LINE" => $_[0]->YYData->{LINE
},
1922 #line 160 "./../pidl/idl.yp"
1924 "TYPE" => "FUNCTION",
1926 "RETURN_TYPE" => $_[2],
1927 "PROPERTIES" => $_[1],
1928 "ELEMENTS" => $_[5],
1929 "FILE" => $_[0]->YYData->{FILE
},
1930 "LINE" => $_[0]->YYData->{LINE
},
1936 #line 173 "./../pidl/idl.yp"
1938 "TYPE" => "TYPEDEF",
1939 "PROPERTIES" => $_[1],
1942 "ARRAY_LEN" => $_[5],
1943 "FILE" => $_[0]->YYData->{FILE
},
1944 "LINE" => $_[0]->YYData->{LINE
},
1948 'usertype', 1, undef
1951 'usertype', 1, undef
1954 'usertype', 1, undef
1957 'usertype', 1, undef
1962 #line 195 "./../pidl/idl.yp"
1974 #line 205 "./../pidl/idl.yp"
1975 { ($_[1]?
$_[1]:"signed") ." $_[2]" }
1978 'existingtype', 1, undef
1989 #line 215 "./../pidl/idl.yp"
1995 #line 219 "./../pidl/idl.yp"
1999 'opt_enum_body', 0, undef
2002 'opt_enum_body', 1, undef
2007 #line 230 "./../pidl/idl.yp"
2010 "PROPERTIES" => $_[1],
2012 "ELEMENTS" => $_[4],
2013 "FILE" => $_[0]->YYData->{FILE
},
2014 "LINE" => $_[0]->YYData->{LINE
},
2020 #line 241 "./../pidl/idl.yp"
2026 #line 243 "./../pidl/idl.yp"
2027 { push(@
{$_[1]}, $_[3]); $_[1] }
2030 'enum_element', 1, undef
2035 #line 249 "./../pidl/idl.yp"
2036 { "$_[1]$_[2]$_[3]" }
2041 #line 253 "./../pidl/idl.yp"
2045 'opt_bitmap_body', 0, undef
2048 'opt_bitmap_body', 1, undef
2053 #line 264 "./../pidl/idl.yp"
2056 "PROPERTIES" => $_[1],
2058 "ELEMENTS" => $_[4],
2059 "FILE" => $_[0]->YYData->{FILE
},
2060 "LINE" => $_[0]->YYData->{LINE
},
2064 'bitmap_elements', 1,
2066 #line 275 "./../pidl/idl.yp"
2070 'bitmap_elements', 3,
2072 #line 277 "./../pidl/idl.yp"
2073 { push(@
{$_[1]}, $_[3]); $_[1] }
2076 'opt_bitmap_elements', 0, undef
2079 'opt_bitmap_elements', 1, undef
2082 'bitmap_element', 3,
2084 #line 287 "./../pidl/idl.yp"
2085 { "$_[1] ( $_[3] )" }
2090 #line 291 "./../pidl/idl.yp"
2094 'opt_struct_body', 0, undef
2097 'opt_struct_body', 1, undef
2102 #line 302 "./../pidl/idl.yp"
2105 "PROPERTIES" => $_[1],
2107 "ELEMENTS" => $_[4],
2108 "FILE" => $_[0]->YYData->{FILE
},
2109 "LINE" => $_[0]->YYData->{LINE
},
2115 #line 314 "./../pidl/idl.yp"
2119 "PROPERTIES" => $_[1],
2122 "FILE" => $_[0]->YYData->{FILE
},
2123 "LINE" => $_[0]->YYData->{LINE
},
2127 'base_or_empty', 2, undef
2130 'base_or_empty', 1, undef
2133 'optional_base_element', 2,
2135 #line 331 "./../pidl/idl.yp"
2136 { $_[2]->{PROPERTIES
} = FlattenHash
([$_[1],$_[2]->{PROPERTIES
}]); $_[2] }
2139 'union_elements', 0, undef
2142 'union_elements', 2,
2144 #line 337 "./../pidl/idl.yp"
2145 { push(@
{$_[1]}, $_[2]); $_[1] }
2150 #line 341 "./../pidl/idl.yp"
2154 'opt_union_body', 0, undef
2157 'opt_union_body', 1, undef
2162 #line 352 "./../pidl/idl.yp"
2165 "PROPERTIES" => $_[1],
2167 "ELEMENTS" => $_[4],
2168 "FILE" => $_[0]->YYData->{FILE
},
2169 "LINE" => $_[0]->YYData->{LINE
},
2175 #line 364 "./../pidl/idl.yp"
2179 "PROPERTIES" => $_[1],
2180 "POINTERS" => $_[3],
2181 "ARRAY_LEN" => $_[5],
2182 "FILE" => $_[0]->YYData->{FILE
},
2183 "LINE" => $_[0]->YYData->{LINE
},
2189 #line 377 "./../pidl/idl.yp"
2195 #line 379 "./../pidl/idl.yp"
2201 #line 384 "./../pidl/idl.yp"
2207 #line 386 "./../pidl/idl.yp"
2208 { push(@
{$_[1]}, $_[2]); $_[1] }
2211 'optional_const', 0, undef
2214 'optional_const', 1, undef
2217 'element_list2', 0, undef
2220 'element_list2', 1, undef
2225 #line 400 "./../pidl/idl.yp"
2231 #line 402 "./../pidl/idl.yp"
2232 { push(@
{$_[1]}, $_[4]); $_[1] }
2235 'array_len', 0, undef
2240 #line 408 "./../pidl/idl.yp"
2241 { push(@
{$_[3]}, "*"); $_[3] }
2246 #line 410 "./../pidl/idl.yp"
2247 { push(@
{$_[4]}, "$_[2]"); $_[4] }
2250 'property_list', 0, undef
2255 #line 416 "./../pidl/idl.yp"
2256 { FlattenHash
([$_[1],$_[3]]); }
2261 #line 420 "./../pidl/idl.yp"
2267 #line 422 "./../pidl/idl.yp"
2268 { FlattenHash
([$_[1], $_[3]]); }
2273 #line 426 "./../pidl/idl.yp"
2274 {{ "$_[1]" => "1" }}
2279 #line 428 "./../pidl/idl.yp"
2280 {{ "$_[1]" => "$_[3]" }}
2283 'commalisttext', 1, undef
2288 #line 434 "./../pidl/idl.yp"
2294 #line 439 "./../pidl/idl.yp"
2309 #line 447 "./../pidl/idl.yp"
2310 { "$_[1]$_[2]$_[3]" }
2315 #line 449 "./../pidl/idl.yp"
2316 { "$_[1]$_[2]$_[3]" }
2321 #line 451 "./../pidl/idl.yp"
2322 { "$_[1]$_[2]$_[3]" }
2327 #line 453 "./../pidl/idl.yp"
2328 { "$_[1]$_[2]$_[3]" }
2333 #line 455 "./../pidl/idl.yp"
2334 { "$_[1]$_[2]$_[3]" }
2339 #line 457 "./../pidl/idl.yp"
2340 { "$_[1]$_[2]$_[3]" }
2345 #line 459 "./../pidl/idl.yp"
2346 { "$_[1]$_[2]$_[3]" }
2351 #line 461 "./../pidl/idl.yp"
2352 { "$_[1]$_[2]$_[3]" }
2357 #line 463 "./../pidl/idl.yp"
2358 { "$_[1]$_[2]$_[3]" }
2363 #line 465 "./../pidl/idl.yp"
2364 { "$_[1]$_[2]$_[3]" }
2369 #line 467 "./../pidl/idl.yp"
2370 { "$_[1]$_[2]$_[3]" }
2375 #line 469 "./../pidl/idl.yp"
2376 { "$_[1]$_[2]$_[3]" }
2381 #line 471 "./../pidl/idl.yp"
2382 { "$_[1]$_[2]$_[3]" }
2387 #line 473 "./../pidl/idl.yp"
2388 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2393 #line 475 "./../pidl/idl.yp"
2394 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2397 'identifier', 1, undef
2400 'optional_identifier', 0, undef
2403 'optional_identifier', 1, undef
2406 'constant', 1, undef
2411 #line 493 "./../pidl/idl.yp"
2415 'optional_semicolon', 0, undef
2418 'optional_semicolon', 1, undef
2422 bless($self,$class);
2425 #line 505 "./../pidl/idl.yp"
2428 use Parse
::Pidl
qw(error);
2430 #####################################################################
2431 # flatten an array of hashes into a single hash
2437 for my $k (keys %{$d}) {
2444 #####################################################################
2445 # traverse a perl data structure removing any empty arrays or
2446 # hashes and any hash elements that map to undef
2452 return undef if (not defined($v));
2454 if (ref($v) eq "ARRAY") {
2455 foreach my $i (0 .. $#{$v}) {
2456 CleanData
($v->[$i]);
2458 # this removes any undefined elements from the array
2459 @
{$v} = grep { defined $_ } @
{$v};
2460 } elsif (ref($v) eq "HASH") {
2461 foreach my $x (keys %{$v}) {
2462 CleanData
($v->{$x});
2463 if (!defined $v->{$x}) {
2474 if (exists $_[0]->YYData->{ERRMSG
}) {
2475 error
($_[0]->YYData, $_[0]->YYData->{ERRMSG
});
2476 delete $_[0]->YYData->{ERRMSG
};
2480 my $last_token = $_[0]->YYData->{LAST_TOKEN
};
2482 error
($_[0]->YYData, "Syntax error near '$last_token'");
2489 $parser->YYData->{INPUT
} or return('',undef);
2492 $parser->YYData->{INPUT
} =~ s/^[ \t]*//;
2494 for ($parser->YYData->{INPUT
}) {
2496 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2497 $parser->YYData->{LINE
} = $1-1;
2498 $parser->YYData->{FILE
} = $2;
2501 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2502 $parser->YYData->{LINE
} = $1-1;
2503 $parser->YYData->{FILE
} = $2;
2506 if (s/^(\#.*)$//m) {
2511 $parser->YYData->{LINE
}++;
2514 if (s/^\"(.*?)\"//) {
2515 $parser->YYData->{LAST_TOKEN
} = $1;
2518 if (s/^(\d+)(\W|$)/$2/) {
2519 $parser->YYData->{LAST_TOKEN
} = $1;
2520 return('CONSTANT',$1);
2522 if (s/^([\w_]+)//) {
2523 $parser->YYData->{LAST_TOKEN
} = $1;
2525 /^(coclass
|interface
|import
|importlib
2526 |include
|cpp_quote
|typedef
2527 |union
|struct
|enum
|bitmap
2528 |void
|const
|unsigned
|signed
)$/x
) {
2531 return('IDENTIFIER',$1);
2534 $parser->YYData->{LAST_TOKEN
} = $1;
2542 my ($data,$filename) = @_;
2544 my $self = new Parse
::Pidl
::IDL
;
2546 $self->YYData->{FILE
} = $filename;
2547 $self->YYData->{INPUT
} = $data;
2548 $self->YYData->{LINE
} = 0;
2549 $self->YYData->{LAST_TOKEN
} = "NONE";
2551 my $idl = $self->YYParse( yylex
=> \
&_Lexer
, yyerror
=> \
&_Error
);
2553 return CleanData
($idl);
2558 my ($filename,$incdirs) = @_;
2560 my $saved_delim = $/;
2562 my $cpp = $ENV{CPP
};
2563 if (! defined $cpp) {
2566 my $includes = join('',map { " -I$_" } @
$incdirs);
2567 my $data = `$cpp -D__PIDL__$includes -xc $filename`;
2570 return parse_string
($data, $filename);