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,
1082 'union_body' => 140,
1083 'opt_union_body' => 138
1095 'struct_body' => 141,
1096 'opt_struct_body' => 143
1105 'opt_enum_body' => 146,
1115 'bitmap_body' => 149,
1116 'opt_bitmap_body' => 147
1179 'union_elements' => 156
1191 'element_list1' => 157
1202 'identifier' => 158,
1203 'enum_element' => 159,
1204 'enum_elements' => 160
1222 'identifier' => 163,
1223 'bitmap_element' => 162,
1224 'bitmap_elements' => 161,
1225 'opt_bitmap_elements' => 164
1240 'optional_const' => 165,
1241 'element_list2' => 167
1302 'optional_base_element' => 175,
1303 'property_list' => 174
1312 'base_element' => 177,
1313 'property_list' => 178
1353 'base_element' => 185,
1354 'property_list' => 178
1417 'base_or_empty' => 193,
1418 'base_element' => 194,
1419 'empty_element' => 195,
1420 'property_list' => 196
1444 'existingtype' => 99,
1448 'property_list' => 94,
1479 'identifier' => 158,
1480 'enum_element' => 200
1488 'identifier' => 163,
1489 'bitmap_element' => 201
1518 'optional_const' => 203
1614 'existingtype' => 99,
1618 'property_list' => 94,
1685 'base_element' => 212,
1686 'property_list' => 178
1776 { push(@{$_[1]}, $_[2]); $_[1] }
1782 { push(@{$_[1]}, $_[2]); $_[1] }
1788 { push(@{$_[1]}, $_[2]); $_[1] }
1794 { push(@{$_[1]}, $_[2]); $_[1] }
1800 { push(@{$_[1]}, $_[2]); $_[1] }
1806 { push(@{$_[1]}, $_[2]); $_[1] }
1815 "FILE" => $_[0]->YYData->{FILE},
1816 "LINE" => $_[0]->YYData->{LINE},
1824 "TYPE" => "INCLUDE",
1826 "FILE" => $_[0]->YYData->{FILE},
1827 "LINE" => $_[0]->YYData->{LINE},
1835 "TYPE" => "IMPORTLIB",
1837 "FILE" => $_[0]->YYData->{FILE},
1838 "LINE" => $_[0]->YYData->{LINE},
1851 { push(@{$_[1]}, $_[3]); $_[1] }
1858 "TYPE" => "COCLASS",
1859 "PROPERTIES" => $_[1],
1862 "FILE" => $_[0]->YYData->{FILE},
1863 "LINE" => $_[0]->YYData->{LINE},
1867 'interface_names', 0, undef
1870 'interface_names', 4,
1873 { push(@{$_[1]}, $_[2]); $_[1] }
1880 "TYPE" => "INTERFACE",
1881 "PROPERTIES" => $_[1],
1885 "FILE" => $_[0]->YYData->{FILE},
1886 "LINE" => $_[0]->YYData->{LINE},
1890 'base_interface', 0, undef
1893 'base_interface', 2,
1903 "TYPE" => "CPP_QUOTE",
1905 "FILE" => $_[0]->YYData->{FILE},
1906 "LINE" => $_[0]->YYData->{LINE},
1919 { push(@{$_[1]}, $_[2]); $_[1] }
1922 'definition', 1, undef
1925 'definition', 1, undef
1928 'definition', 1, undef
1931 'definition', 1, undef
1940 "POINTERS" => $_[3],
1943 "FILE" => $_[0]->YYData->{FILE},
1944 "LINE" => $_[0]->YYData->{LINE},
1954 "POINTERS" => $_[3],
1956 "ARRAY_LEN" => $_[5],
1958 "FILE" => $_[0]->YYData->{FILE},
1959 "LINE" => $_[0]->YYData->{LINE},
1967 "TYPE" => "FUNCTION",
1969 "RETURN_TYPE" => $_[2],
1970 "PROPERTIES" => $_[1],
1971 "ELEMENTS" => $_[5],
1972 "FILE" => $_[0]->YYData->{FILE},
1973 "LINE" => $_[0]->YYData->{LINE},
1981 "TYPE" => "TYPEDEF",
1982 "PROPERTIES" => $_[1],
1985 "POINTERS" => $_[4],
1986 "ARRAY_LEN" => $_[6],
1987 "FILE" => $_[0]->YYData->{FILE},
1988 "LINE" => $_[0]->YYData->{LINE},
1992 'usertype', 1, undef
1995 'usertype', 1, undef
1998 'usertype', 1, undef
2001 'usertype', 1, undef
2004 'usertype', 1, undef
2022 { ($_[1]?$_[1]:"signed") ." $_[2]" }
2025 'existingtype', 1, undef
2046 'opt_enum_body', 0, undef
2049 'opt_enum_body', 1, undef
2057 "PROPERTIES" => $_[1],
2059 "ELEMENTS" => $_[4],
2060 "FILE" => $_[0]->YYData->{FILE},
2061 "LINE" => $_[0]->YYData->{LINE},
2074 { push(@{$_[1]}, $_[3]); $_[1] }
2077 'enum_element', 1, undef
2083 { "$_[1]$_[2]$_[3]" }
2092 'opt_bitmap_body', 0, undef
2095 'opt_bitmap_body', 1, undef
2103 "PROPERTIES" => $_[1],
2105 "ELEMENTS" => $_[4],
2106 "FILE" => $_[0]->YYData->{FILE},
2107 "LINE" => $_[0]->YYData->{LINE},
2111 'bitmap_elements', 1,
2117 'bitmap_elements', 3,
2120 { push(@{$_[1]}, $_[3]); $_[1] }
2123 'opt_bitmap_elements', 0, undef
2126 'opt_bitmap_elements', 1, undef
2129 'bitmap_element', 3,
2132 { "$_[1] ( $_[3] )" }
2141 'opt_struct_body', 0, undef
2144 'opt_struct_body', 1, undef
2152 "PROPERTIES" => $_[1],
2154 "ELEMENTS" => $_[4],
2155 "FILE" => $_[0]->YYData->{FILE},
2156 "LINE" => $_[0]->YYData->{LINE},
2166 "PROPERTIES" => $_[1],
2169 "FILE" => $_[0]->YYData->{FILE},
2170 "LINE" => $_[0]->YYData->{LINE},
2174 'base_or_empty', 2, undef
2177 'base_or_empty', 1, undef
2180 'optional_base_element', 2,
2183 { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2186 'union_elements', 0, undef
2189 'union_elements', 2,
2192 { push(@{$_[1]}, $_[2]); $_[1] }
2201 'opt_union_body', 0, undef
2204 'opt_union_body', 1, undef
2212 "PROPERTIES" => $_[1],
2214 "ELEMENTS" => $_[4],
2215 "FILE" => $_[0]->YYData->{FILE},
2216 "LINE" => $_[0]->YYData->{LINE},
2226 "PROPERTIES" => $_[1],
2227 "POINTERS" => $_[3],
2228 "ARRAY_LEN" => $_[5],
2229 "FILE" => $_[0]->YYData->{FILE},
2230 "LINE" => $_[0]->YYData->{LINE},
2251 "PROPERTIES" => $_[1],
2253 "FILE" => $_[0]->YYData->{FILE},
2254 "LINE" => $_[0]->YYData->{LINE},
2267 { push(@{$_[1]}, $_[2]); $_[1] }
2270 'optional_const', 0, undef
2273 'optional_const', 1, undef
2276 'element_list2', 0, undef
2279 'element_list2', 1, undef
2291 { push(@{$_[1]}, $_[4]); $_[1] }
2294 'array_len', 0, undef
2300 { push(@{$_[3]}, "*"); $_[3] }
2306 { push(@{$_[4]}, "$_[2]"); $_[4] }
2309 'property_list', 0, undef
2315 { FlattenHash([$_[1],$_[3]]); }
2327 { FlattenHash([$_[1], $_[3]]); }
2333 {{ "$_[1]" => "1" }}
2339 {{ "$_[1]" => "$_[3]" }}
2342 'commalisttext', 1, undef
2369 { "$_[1]$_[2]$_[3]" }
2375 { "$_[1]$_[2]$_[3]" }
2381 { "$_[1]$_[2]$_[3]" }
2387 { "$_[1]$_[2]$_[3]" }
2393 { "$_[1]$_[2]$_[3]" }
2399 { "$_[1]$_[2]$_[3]" }
2405 { "$_[1]$_[2]$_[3]" }
2411 { "$_[1]$_[2]$_[3]" }
2417 { "$_[1]$_[2]$_[3]" }
2423 { "$_[1]$_[2]$_[3]" }
2429 { "$_[1]$_[2]$_[3]" }
2435 { "$_[1]$_[2]$_[3]" }
2441 { "$_[1]$_[2]$_[3]" }
2447 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2453 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2456 'identifier', 1, undef
2459 'optional_identifier', 0, undef
2462 'optional_identifier', 1, undef
2465 'constant', 1, undef
2474 'optional_semicolon', 0, undef
2477 'optional_semicolon', 1, undef
2481 bless($self,$class);
2487 use Parse::Pidl qw(error);
2489 #####################################################################
2490 # flatten an array of hashes into a single hash
2496 for my $k (keys %{$d}) {
2503 #####################################################################
2504 # traverse a perl data structure removing any empty arrays or
2505 # hashes and any hash elements that map to undef
2511 return undef if (not defined($v));
2513 if (ref($v) eq "ARRAY") {
2514 foreach my $i (0 .. $#{$v}) {
2515 CleanData($v->[$i]);
2517 # this removes any undefined elements from the array
2518 @{$v} = grep { defined $_ } @{$v};
2519 } elsif (ref($v) eq "HASH") {
2520 foreach my $x (keys %{$v}) {
2521 CleanData($v->{$x});
2522 if (!defined $v->{$x}) {
2533 if (exists $_[0]->YYData->{ERRMSG}) {
2534 error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2535 delete $_[0]->YYData->{ERRMSG};
2539 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2541 error($_[0]->YYData, "Syntax error near '$last_token'");
2548 $parser->YYData->{INPUT} or return('',undef);
2551 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2553 for ($parser->YYData->{INPUT}) {
2555 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2556 $parser->YYData->{LINE} = $1-1;
2557 $parser->YYData->{FILE} = $2;
2560 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2561 $parser->YYData->{LINE} = $1-1;
2562 $parser->YYData->{FILE} = $2;
2565 if (s/^(\#.*)$//m) {
2570 $parser->YYData->{LINE}++;
2573 if (s/^\"(.*?)\"//) {
2574 $parser->YYData->{LAST_TOKEN} = $1;
2577 if (s/^(\d+)(\W|$)/$2/) {
2578 $parser->YYData->{LAST_TOKEN} = $1;
2579 return('CONSTANT',$1);
2581 if (s/^([\w_]+)//) {
2582 $parser->YYData->{LAST_TOKEN} = $1;
2584 /^(coclass|interface|import|importlib
2585 |include|cpp_quote|typedef
2586 |union|struct|enum|bitmap|pipe
2587 |void|const|unsigned|signed)$/x) {
2590 return('IDENTIFIER',$1);
2593 $parser->YYData->{LAST_TOKEN} = $1;
2601 my ($data,$filename) = @_;
2603 my $self = new Parse::Pidl::IDL;
2605 $self->YYData->{FILE} = $filename;
2606 $self->YYData->{INPUT} = $data;
2607 $self->YYData->{LINE} = 0;
2608 $self->YYData->{LAST_TOKEN} = "NONE";
2610 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2612 return CleanData($idl);
2617 my ($filename,$incdirs) = @_;
2619 my $saved_delim = $/;
2621 my $cpp = $ENV{CPP};
2623 if (! defined $cpp) {
2624 if (defined $ENV{CC}) {
2631 my $includes = join('',map { " -I$_" } @$incdirs);
2632 my $data = `$cpp $options -D__PIDL__$includes -xc "$filename"`;
2635 return parse_string($data, $filename);