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_anonymous_identifier' => 127
775 'optional_anonymous_identifier' => 129
790 'optional_identifier' => 131
799 'optional_identifier' => 132
811 'existingtype' => 99,
815 'property_list' => 94,
1082 'union_body' => 141,
1083 'opt_union_body' => 139
1095 'struct_body' => 142,
1096 'opt_struct_body' => 144
1108 'opt_enum_body' => 147,
1118 'bitmap_body' => 150,
1119 'opt_bitmap_body' => 148
1182 'union_elements' => 157
1194 'element_list1' => 158
1205 'identifier' => 159,
1206 'enum_element' => 160,
1207 'enum_elements' => 161
1225 'identifier' => 164,
1226 'bitmap_element' => 163,
1227 'bitmap_elements' => 162,
1228 'opt_bitmap_elements' => 165
1243 'optional_const' => 166,
1244 'element_list2' => 168
1305 'optional_base_element' => 176,
1306 'property_list' => 175
1315 'base_element' => 178,
1316 'property_list' => 179
1356 'base_element' => 186,
1357 'property_list' => 179
1420 'base_or_empty' => 194,
1421 'base_element' => 195,
1422 'empty_element' => 196,
1423 'property_list' => 197
1447 'existingtype' => 99,
1451 'property_list' => 94,
1482 'identifier' => 159,
1483 'enum_element' => 201
1491 'identifier' => 164,
1492 'bitmap_element' => 202
1521 'optional_const' => 204
1617 'existingtype' => 99,
1621 'property_list' => 94,
1688 'base_element' => 213,
1689 'property_list' => 179
1779 { push(@{$_[1]}, $_[2]); $_[1] }
1785 { push(@{$_[1]}, $_[2]); $_[1] }
1791 { push(@{$_[1]}, $_[2]); $_[1] }
1797 { push(@{$_[1]}, $_[2]); $_[1] }
1803 { push(@{$_[1]}, $_[2]); $_[1] }
1809 { push(@{$_[1]}, $_[2]); $_[1] }
1818 "FILE" => $_[0]->YYData->{FILE},
1819 "LINE" => $_[0]->YYData->{LINE},
1827 "TYPE" => "INCLUDE",
1829 "FILE" => $_[0]->YYData->{FILE},
1830 "LINE" => $_[0]->YYData->{LINE},
1838 "TYPE" => "IMPORTLIB",
1840 "FILE" => $_[0]->YYData->{FILE},
1841 "LINE" => $_[0]->YYData->{LINE},
1854 { push(@{$_[1]}, $_[3]); $_[1] }
1861 "TYPE" => "COCLASS",
1862 "PROPERTIES" => $_[1],
1865 "FILE" => $_[0]->YYData->{FILE},
1866 "LINE" => $_[0]->YYData->{LINE},
1870 'interface_names', 0, undef
1873 'interface_names', 4,
1876 { push(@{$_[1]}, $_[2]); $_[1] }
1883 "TYPE" => "INTERFACE",
1884 "PROPERTIES" => $_[1],
1888 "FILE" => $_[0]->YYData->{FILE},
1889 "LINE" => $_[0]->YYData->{LINE},
1893 'base_interface', 0, undef
1896 'base_interface', 2,
1906 "TYPE" => "CPP_QUOTE",
1908 "FILE" => $_[0]->YYData->{FILE},
1909 "LINE" => $_[0]->YYData->{LINE},
1922 { push(@{$_[1]}, $_[2]); $_[1] }
1925 'definition', 1, undef
1928 'definition', 1, undef
1931 'definition', 1, undef
1934 'definition', 1, undef
1943 "POINTERS" => $_[3],
1946 "FILE" => $_[0]->YYData->{FILE},
1947 "LINE" => $_[0]->YYData->{LINE},
1957 "POINTERS" => $_[3],
1959 "ARRAY_LEN" => $_[5],
1961 "FILE" => $_[0]->YYData->{FILE},
1962 "LINE" => $_[0]->YYData->{LINE},
1970 "TYPE" => "FUNCTION",
1972 "RETURN_TYPE" => $_[2],
1973 "PROPERTIES" => $_[1],
1974 "ELEMENTS" => $_[5],
1975 "FILE" => $_[0]->YYData->{FILE},
1976 "LINE" => $_[0]->YYData->{LINE},
1984 "TYPE" => "TYPEDEF",
1985 "PROPERTIES" => $_[1],
1988 "POINTERS" => $_[4],
1989 "ARRAY_LEN" => $_[6],
1990 "FILE" => $_[0]->YYData->{FILE},
1991 "LINE" => $_[0]->YYData->{LINE},
1995 'usertype', 1, undef
1998 'usertype', 1, undef
2001 'usertype', 1, undef
2004 'usertype', 1, undef
2007 'usertype', 1, undef
2025 { ($_[1]?$_[1]:"signed") ." $_[2]" }
2028 'existingtype', 1, undef
2049 'opt_enum_body', 0, undef
2052 'opt_enum_body', 1, undef
2060 "PROPERTIES" => $_[1],
2062 "ELEMENTS" => $_[4],
2063 "FILE" => $_[0]->YYData->{FILE},
2064 "LINE" => $_[0]->YYData->{LINE},
2077 { push(@{$_[1]}, $_[3]); $_[1] }
2080 'enum_element', 1, undef
2086 { "$_[1]$_[2]$_[3]" }
2095 'opt_bitmap_body', 0, undef
2098 'opt_bitmap_body', 1, undef
2106 "PROPERTIES" => $_[1],
2108 "ELEMENTS" => $_[4],
2109 "FILE" => $_[0]->YYData->{FILE},
2110 "LINE" => $_[0]->YYData->{LINE},
2114 'bitmap_elements', 1,
2120 'bitmap_elements', 3,
2123 { push(@{$_[1]}, $_[3]); $_[1] }
2126 'opt_bitmap_elements', 0, undef
2129 'opt_bitmap_elements', 1, undef
2132 'bitmap_element', 3,
2135 { "$_[1] ( $_[3] )" }
2144 'opt_struct_body', 0, undef
2147 'opt_struct_body', 1, undef
2155 "PROPERTIES" => $_[1],
2157 "ELEMENTS" => $_[4],
2158 "FILE" => $_[0]->YYData->{FILE},
2159 "LINE" => $_[0]->YYData->{LINE},
2169 "PROPERTIES" => $_[1],
2172 "FILE" => $_[0]->YYData->{FILE},
2173 "LINE" => $_[0]->YYData->{LINE},
2177 'base_or_empty', 2, undef
2180 'base_or_empty', 1, undef
2183 'optional_base_element', 2,
2186 { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2189 'union_elements', 0, undef
2192 'union_elements', 2,
2195 { push(@{$_[1]}, $_[2]); $_[1] }
2204 'opt_union_body', 0, undef
2207 'opt_union_body', 1, undef
2215 "PROPERTIES" => $_[1],
2217 "ELEMENTS" => $_[4],
2218 "FILE" => $_[0]->YYData->{FILE},
2219 "LINE" => $_[0]->YYData->{LINE},
2229 "PROPERTIES" => $_[1],
2230 "POINTERS" => $_[3],
2231 "ARRAY_LEN" => $_[5],
2232 "FILE" => $_[0]->YYData->{FILE},
2233 "LINE" => $_[0]->YYData->{LINE},
2254 "PROPERTIES" => $_[1],
2258 "PROPERTIES" => $_[1],
2262 "PROPERTIES" => $_[1],
2265 "TYPE" => "uint3264",
2266 "FILE" => $_[0]->YYData->{FILE},
2267 "LINE" => $_[0]->YYData->{LINE},
2270 "PROPERTIES" => $_[1],
2272 "ARRAY_LEN" => [ "count" ],
2274 "FILE" => $_[0]->YYData->{FILE},
2275 "LINE" => $_[0]->YYData->{LINE},
2277 "FILE" => $_[0]->YYData->{FILE},
2278 "LINE" => $_[0]->YYData->{LINE},
2280 "FILE" => $_[0]->YYData->{FILE},
2281 "LINE" => $_[0]->YYData->{LINE},
2294 { push(@{$_[1]}, $_[2]); $_[1] }
2297 'optional_const', 0, undef
2300 'optional_const', 1, undef
2303 'element_list2', 0, undef
2306 'element_list2', 1, undef
2318 { push(@{$_[1]}, $_[4]); $_[1] }
2321 'array_len', 0, undef
2327 { push(@{$_[3]}, "*"); $_[3] }
2333 { push(@{$_[4]}, "$_[2]"); $_[4] }
2336 'property_list', 0, undef
2342 { FlattenHash([$_[1],$_[3]]); }
2354 { FlattenHash([$_[1], $_[3]]); }
2360 {{ "$_[1]" => "1" }}
2366 {{ "$_[1]" => "$_[3]" }}
2369 'commalisttext', 1, undef
2396 { "$_[1]$_[2]$_[3]" }
2402 { "$_[1]$_[2]$_[3]" }
2408 { "$_[1]$_[2]$_[3]" }
2414 { "$_[1]$_[2]$_[3]" }
2420 { "$_[1]$_[2]$_[3]" }
2426 { "$_[1]$_[2]$_[3]" }
2432 { "$_[1]$_[2]$_[3]" }
2438 { "$_[1]$_[2]$_[3]" }
2444 { "$_[1]$_[2]$_[3]" }
2450 { "$_[1]$_[2]$_[3]" }
2456 { "$_[1]$_[2]$_[3]" }
2462 { "$_[1]$_[2]$_[3]" }
2468 { "$_[1]$_[2]$_[3]" }
2474 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2480 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2483 'identifier', 1, undef
2486 'optional_identifier', 0, undef
2489 'optional_identifier', 1, undef
2492 'optional_anonymous_identifier', 0,
2495 { anonymous_identifier($_[0]) }
2498 'optional_anonymous_identifier', 1, undef
2501 'constant', 1, undef
2510 >>>>>>> 239255a... TODO pidl/IDL: give anonymous structs and unions a name...
2514 'optional_semicolon', 0, undef
2517 'optional_semicolon', 1, undef
2521 bless($self,$class);
2528 >>>>>>> 239255a... TODO pidl/IDL: give anonymous structs and unions a name...
2531 use Parse::Pidl qw(error);
2534 #####################################################################
2535 # flatten an array of hashes into a single hash
2541 for my $k (keys %{$d}) {
2548 #####################################################################
2549 # traverse a perl data structure removing any empty arrays or
2550 # hashes and any hash elements that map to undef
2556 return undef if (not defined($v));
2558 if (ref($v) eq "ARRAY") {
2559 foreach my $i (0 .. $#{$v}) {
2560 CleanData($v->[$i]);
2562 # this removes any undefined elements from the array
2563 @{$v} = grep { defined $_ } @{$v};
2564 } elsif (ref($v) eq "HASH") {
2565 foreach my $x (keys %{$v}) {
2566 CleanData($v->{$x});
2567 if (!defined $v->{$x}) {
2577 sub anonymous_identifier($)
2580 my $name = "__pidl_anonymous_";
2581 $name .= basename($parser->YYData->{FILE});
2583 $name .= $parser->YYData->{LINE};
2585 $name .= $parser->YYData->{ANONYMOUS_COUNTER}++;
2595 if (exists $_[0]->YYData->{ERRMSG}) {
2596 error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2597 delete $_[0]->YYData->{ERRMSG};
2601 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2603 error($_[0]->YYData, "Syntax error near '$last_token'");
2610 $parser->YYData->{INPUT} or return('',undef);
2613 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2615 for ($parser->YYData->{INPUT}) {
2617 # Linemarker format is described at
2618 # http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
2619 if (s/^\# (\d+) \"(.*?)\"(( \d+){1,4}|)//) {
2620 $parser->YYData->{LINE} = $1-1;
2621 $parser->YYData->{FILE} = $2;
2624 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2625 $parser->YYData->{LINE} = $1-1;
2626 $parser->YYData->{FILE} = $2;
2629 if (s/^(\#.*)$//m) {
2634 $parser->YYData->{LINE}++;
2637 if (s/^\"(.*?)\"//) {
2638 $parser->YYData->{LAST_TOKEN} = $1;
2641 if (s/^(\d+)(\W|$)/$2/) {
2642 $parser->YYData->{LAST_TOKEN} = $1;
2643 return('CONSTANT',$1);
2645 if (s/^([\w_]+)//) {
2646 $parser->YYData->{LAST_TOKEN} = $1;
2648 /^(coclass|interface|import|importlib
2649 |include|cpp_quote|typedef
2650 |union|struct|enum|bitmap|pipe
2651 |void|const|unsigned|signed)$/x) {
2654 return('IDENTIFIER',$1);
2657 $parser->YYData->{LAST_TOKEN} = $1;
2665 my ($data,$filename) = @_;
2667 my $self = new Parse::Pidl::IDL;
2669 $self->YYData->{FILE} = $filename;
2670 $self->YYData->{INPUT} = $data;
2671 $self->YYData->{LINE} = 0;
2672 $self->YYData->{LAST_TOKEN} = "NONE";
2673 $self->YYData->{ANONYMOUS_COUNTER} = 0;
2675 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2677 return CleanData($idl);
2682 my ($filename,$incdirs) = @_;
2684 my $saved_delim = $/;
2686 my $cpp = $ENV{CPP};
2688 if (! defined $cpp) {
2689 if (defined $ENV{CC}) {
2696 my $includes = join('',map { " -I$_" } @$incdirs);
2697 my $data = `$cpp $options -D__PIDL__$includes -xc "$filename"`;
2700 return parse_string($data, $filename);