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],
2255 "PROPERTIES" => $_[1],
2259 "PROPERTIES" => $_[1],
2262 "TYPE" => "uint3264",
2263 "FILE" => $_[0]->YYData->{FILE},
2264 "LINE" => $_[0]->YYData->{LINE},
2267 "PROPERTIES" => $_[1],
2269 "ARRAY_LEN" => [ "count" ],
2271 "FILE" => $_[0]->YYData->{FILE},
2272 "LINE" => $_[0]->YYData->{LINE},
2274 "FILE" => $_[0]->YYData->{FILE},
2275 "LINE" => $_[0]->YYData->{LINE},
2277 "FILE" => $_[0]->YYData->{FILE},
2278 "LINE" => $_[0]->YYData->{LINE},
2291 { push(@{$_[1]}, $_[2]); $_[1] }
2294 'optional_const', 0, undef
2297 'optional_const', 1, undef
2300 'element_list2', 0, undef
2303 'element_list2', 1, undef
2315 { push(@{$_[1]}, $_[4]); $_[1] }
2318 'array_len', 0, undef
2324 { push(@{$_[3]}, "*"); $_[3] }
2330 { push(@{$_[4]}, "$_[2]"); $_[4] }
2333 'property_list', 0, undef
2339 { FlattenHash([$_[1],$_[3]]); }
2351 { FlattenHash([$_[1], $_[3]]); }
2357 {{ "$_[1]" => "1" }}
2363 {{ "$_[1]" => "$_[3]" }}
2366 'commalisttext', 1, undef
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]" }
2453 { "$_[1]$_[2]$_[3]" }
2459 { "$_[1]$_[2]$_[3]" }
2465 { "$_[1]$_[2]$_[3]" }
2471 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2477 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2480 'identifier', 1, undef
2483 'optional_identifier', 0, undef
2486 'optional_identifier', 1, undef
2489 'constant', 1, undef
2498 'optional_semicolon', 0, undef
2501 'optional_semicolon', 1, undef
2505 bless($self,$class);
2511 use Parse::Pidl qw(error);
2513 #####################################################################
2514 # flatten an array of hashes into a single hash
2520 for my $k (keys %{$d}) {
2527 #####################################################################
2528 # traverse a perl data structure removing any empty arrays or
2529 # hashes and any hash elements that map to undef
2535 return undef if (not defined($v));
2537 if (ref($v) eq "ARRAY") {
2538 foreach my $i (0 .. $#{$v}) {
2539 CleanData($v->[$i]);
2541 # this removes any undefined elements from the array
2542 @{$v} = grep { defined $_ } @{$v};
2543 } elsif (ref($v) eq "HASH") {
2544 foreach my $x (keys %{$v}) {
2545 CleanData($v->{$x});
2546 if (!defined $v->{$x}) {
2557 if (exists $_[0]->YYData->{ERRMSG}) {
2558 error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2559 delete $_[0]->YYData->{ERRMSG};
2563 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2565 error($_[0]->YYData, "Syntax error near '$last_token'");
2572 $parser->YYData->{INPUT} or return('',undef);
2575 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2577 for ($parser->YYData->{INPUT}) {
2579 # Linemarker format is described at
2580 # http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
2581 if (s/^\# (\d+) \"(.*?)\"(( \d+){1,4}|)//) {
2582 $parser->YYData->{LINE} = $1-1;
2583 $parser->YYData->{FILE} = $2;
2586 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2587 $parser->YYData->{LINE} = $1-1;
2588 $parser->YYData->{FILE} = $2;
2591 if (s/^(\#.*)$//m) {
2596 $parser->YYData->{LINE}++;
2599 if (s/^\"(.*?)\"//) {
2600 $parser->YYData->{LAST_TOKEN} = $1;
2603 if (s/^(\d+)(\W|$)/$2/) {
2604 $parser->YYData->{LAST_TOKEN} = $1;
2605 return('CONSTANT',$1);
2607 if (s/^([\w_]+)//) {
2608 $parser->YYData->{LAST_TOKEN} = $1;
2610 /^(coclass|interface|import|importlib
2611 |include|cpp_quote|typedef
2612 |union|struct|enum|bitmap|pipe
2613 |void|const|unsigned|signed)$/x) {
2616 return('IDENTIFIER',$1);
2619 $parser->YYData->{LAST_TOKEN} = $1;
2627 my ($data,$filename) = @_;
2629 my $self = new Parse::Pidl::IDL;
2631 $self->YYData->{FILE} = $filename;
2632 $self->YYData->{INPUT} = $data;
2633 $self->YYData->{LINE} = 0;
2634 $self->YYData->{LAST_TOKEN} = "NONE";
2636 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2638 return CleanData($idl);
2643 my ($filename,$incdirs) = @_;
2645 my $saved_delim = $/;
2647 my $cpp = $ENV{CPP};
2649 if (! defined $cpp) {
2650 if (defined $ENV{CC}) {
2657 my $includes = join('',map { " -I$_" } @$incdirs);
2658 my $data = `$cpp $options -D__PIDL__$includes -xc "$filename"`;
2661 return parse_string($data, $filename);