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',
229 'interface_names' => 41
243 'property_list' => 47,
305 'property_list' => 47,
333 'existingtype' => 76,
336 'property_list' => 70,
418 'optional_semicolon' => 100
435 'optional_semicolon' => 102
453 'existingtype' => 76,
456 'property_list' => 70,
471 'optional_identifier' => 105
506 'optional_identifier' => 107
521 'optional_identifier' => 108
530 'optional_identifier' => 109
660 'commalisttext' => 120
717 'commalisttext' => 124
811 'opt_union_body' => 131
823 'struct_body' => 134,
824 'opt_struct_body' => 136
833 'opt_enum_body' => 139,
843 'bitmap_body' => 142,
844 'opt_bitmap_body' => 140
1119 'union_elements' => 151
1131 'element_list1' => 152
1142 'identifier' => 153,
1143 'enum_element' => 154,
1144 'enum_elements' => 155
1162 'identifier' => 158,
1163 'bitmap_element' => 157,
1164 'bitmap_elements' => 156,
1165 'opt_bitmap_elements' => 159
1179 'base_element' => 160,
1180 'element_list2' => 162,
1181 'property_list' => 161
1264 'optional_base_element' => 174,
1265 'property_list' => 173
1274 'base_element' => 176,
1275 'property_list' => 161
1325 'existingtype' => 76,
1328 'property_list' => 70,
1457 'base_or_empty' => 190,
1458 'base_element' => 191,
1459 'empty_element' => 192,
1460 'property_list' => 193
1496 'identifier' => 153,
1497 'enum_element' => 196
1505 'identifier' => 158,
1506 'bitmap_element' => 197
1535 'base_element' => 200,
1536 'property_list' => 161
1612 'existingtype' => 76,
1615 'property_list' => 70,
1748 { push(@{$_[1]}, $_[2]); $_[1] }
1754 { push(@{$_[1]}, $_[2]); $_[1] }
1760 { push(@{$_[1]}, $_[2]); $_[1] }
1766 { push(@{$_[1]}, $_[2]); $_[1] }
1772 { push(@{$_[1]}, $_[2]); $_[1] }
1778 { push(@{$_[1]}, $_[2]); $_[1] }
1787 "FILE" => $_[0]->YYData->{FILE},
1788 "LINE" => $_[0]->YYData->{LINE}
1796 "TYPE" => "INCLUDE",
1798 "FILE" => $_[0]->YYData->{FILE},
1799 "LINE" => $_[0]->YYData->{LINE}
1807 "TYPE" => "IMPORTLIB",
1809 "FILE" => $_[0]->YYData->{FILE},
1810 "LINE" => $_[0]->YYData->{LINE}
1823 { push(@{$_[1]}, $_[3]); $_[1] }
1830 "TYPE" => "COCLASS",
1831 "PROPERTIES" => $_[1],
1834 "FILE" => $_[0]->YYData->{FILE},
1835 "LINE" => $_[0]->YYData->{LINE},
1839 'interface_names', 0, undef
1842 'interface_names', 4,
1845 { push(@{$_[1]}, $_[2]); $_[1] }
1852 "TYPE" => "INTERFACE",
1853 "PROPERTIES" => $_[1],
1856 "FILE" => $_[0]->YYData->{FILE},
1857 "LINE" => $_[0]->YYData->{LINE},
1865 "TYPE" => "CPP_QUOTE",
1866 "FILE" => $_[0]->YYData->{FILE},
1867 "LINE" => $_[0]->YYData->{LINE},
1881 { push(@{$_[1]}, $_[2]); $_[1] }
1884 'definition', 1, undef
1887 'definition', 1, undef
1890 'definition', 1, undef
1893 'definition', 1, undef
1902 "POINTERS" => $_[3],
1905 "FILE" => $_[0]->YYData->{FILE},
1906 "LINE" => $_[0]->YYData->{LINE},
1916 "POINTERS" => $_[3],
1918 "ARRAY_LEN" => $_[5],
1920 "FILE" => $_[0]->YYData->{FILE},
1921 "LINE" => $_[0]->YYData->{LINE},
1929 "TYPE" => "FUNCTION",
1931 "RETURN_TYPE" => $_[2],
1932 "PROPERTIES" => $_[1],
1933 "ELEMENTS" => $_[5],
1934 "FILE" => $_[0]->YYData->{FILE},
1935 "LINE" => $_[0]->YYData->{LINE},
1943 "TYPE" => "TYPEDEF",
1944 "PROPERTIES" => $_[1],
1947 "ARRAY_LEN" => $_[5],
1948 "FILE" => $_[0]->YYData->{FILE},
1949 "LINE" => $_[0]->YYData->{LINE},
1953 'usertype', 1, undef
1956 'usertype', 1, undef
1959 'usertype', 1, undef
1962 'usertype', 1, undef
1980 { ($_[1]?$_[1]:"signed") ." $_[2]" }
1983 'existingtype', 1, undef
2004 'opt_enum_body', 0, undef
2007 'opt_enum_body', 1, undef
2015 "PROPERTIES" => $_[1],
2030 { push(@{$_[1]}, $_[3]); $_[1] }
2033 'enum_element', 1, undef
2039 { "$_[1]$_[2]$_[3]" }
2048 'opt_bitmap_body', 0, undef
2051 'opt_bitmap_body', 1, undef
2059 "PROPERTIES" => $_[1],
2065 'bitmap_elements', 1,
2071 'bitmap_elements', 3,
2074 { push(@{$_[1]}, $_[3]); $_[1] }
2077 'opt_bitmap_elements', 0, undef
2080 'opt_bitmap_elements', 1, undef
2083 'bitmap_element', 3,
2086 { "$_[1] ( $_[3] )" }
2095 'opt_struct_body', 0, undef
2098 'opt_struct_body', 1, undef
2106 "PROPERTIES" => $_[1],
2118 "PROPERTIES" => $_[1],
2121 "FILE" => $_[0]->YYData->{FILE},
2122 "LINE" => $_[0]->YYData->{LINE},
2126 'base_or_empty', 2, undef
2129 'base_or_empty', 1, undef
2132 'optional_base_element', 2,
2135 { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2138 'union_elements', 0, undef
2141 'union_elements', 2,
2144 { push(@{$_[1]}, $_[2]); $_[1] }
2153 'opt_union_body', 0, undef
2156 'opt_union_body', 1, undef
2164 "PROPERTIES" => $_[1],
2176 "PROPERTIES" => $_[1],
2177 "POINTERS" => $_[3],
2178 "ARRAY_LEN" => $_[5],
2179 "FILE" => $_[0]->YYData->{FILE},
2180 "LINE" => $_[0]->YYData->{LINE},
2205 { push(@{$_[1]}, $_[2]); $_[1] }
2208 'element_list2', 0, undef
2211 'element_list2', 1, undef
2223 { push(@{$_[1]}, $_[3]); $_[1] }
2226 'array_len', 0, undef
2232 { push(@{$_[3]}, "*"); $_[3] }
2238 { push(@{$_[4]}, "$_[2]"); $_[4] }
2241 'property_list', 0, undef
2247 { FlattenHash([$_[1],$_[3]]); }
2259 { FlattenHash([$_[1], $_[3]]); }
2265 {{ "$_[1]" => "1" }}
2271 {{ "$_[1]" => "$_[3]" }}
2274 'listtext', 1, undef
2283 'commalisttext', 1, undef
2310 { "$_[1]$_[2]$_[3]" }
2316 { "$_[1]$_[2]$_[3]" }
2322 { "$_[1]$_[2]$_[3]" }
2328 { "$_[1]$_[2]$_[3]" }
2334 { "$_[1]$_[2]$_[3]" }
2340 { "$_[1]$_[2]$_[3]" }
2346 { "$_[1]$_[2]$_[3]" }
2352 { "$_[1]$_[2]$_[3]" }
2358 { "$_[1]$_[2]$_[3]" }
2364 { "$_[1]$_[2]$_[3]" }
2370 { "$_[1]$_[2]$_[3]" }
2376 { "$_[1]$_[2]$_[3]" }
2382 { "$_[1]$_[2]$_[3]" }
2388 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2394 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2397 'identifier', 1, undef
2400 'optional_identifier', 1, undef
2403 'optional_identifier', 0, undef
2406 'constant', 1, undef
2415 'optional_semicolon', 0, undef
2418 'optional_semicolon', 1, undef
2422 bless($self,$class);
2428 use Parse::Pidl qw(error);
2430 #####################################################################
2431 # flatten an array of hashes into a single hash
2437 for my $k (keys %{$d}) {
2446 #####################################################################
2447 # traverse a perl data structure removing any empty arrays or
2448 # hashes and any hash elements that map to undef
2453 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}) { delete($v->{$x}); next; }
2470 if (exists $_[0]->YYData->{ERRMSG}) {
2471 error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2472 delete $_[0]->YYData->{ERRMSG};
2475 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2477 error($_[0]->YYData, "Syntax error near '$last_token'");
2484 $parser->YYData->{INPUT} or return('',undef);
2487 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2489 for ($parser->YYData->{INPUT}) {
2491 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2492 $parser->YYData->{LINE} = $1-1;
2493 $parser->YYData->{FILE} = $2;
2496 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2497 $parser->YYData->{LINE} = $1-1;
2498 $parser->YYData->{FILE} = $2;
2501 if (s/^(\#.*)$//m) {
2506 $parser->YYData->{LINE}++;
2509 if (s/^\"(.*?)\"//) {
2510 $parser->YYData->{LAST_TOKEN} = $1;
2513 if (s/^(\d+)(\W|$)/$2/) {
2514 $parser->YYData->{LAST_TOKEN} = $1;
2515 return('CONSTANT',$1);
2517 if (s/^([\w_]+)//) {
2518 $parser->YYData->{LAST_TOKEN} = $1;
2520 /^(coclass|interface|const|typedef|union|cpp_quote
2521 |struct|enum|bitmap|void|unsigned|signed|import|include
2525 return('IDENTIFIER',$1);
2528 $parser->YYData->{LAST_TOKEN} = $1;
2536 my ($data,$filename) = @_;
2538 my $self = new Parse::Pidl::IDL;
2540 $self->YYData->{FILE} = $filename;
2541 $self->YYData->{INPUT} = $data;
2542 $self->YYData->{LINE} = 0;
2543 $self->YYData->{LAST_TOKEN} = "NONE";
2545 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2547 return CleanData($idl);
2552 my ($filename,$incdirs) = @_;
2554 my $saved_delim = $/;
2556 my $cpp = $ENV{CPP};
2557 if (! defined $cpp) {
2560 my $includes = join('',map { " -I$_" } @$incdirs);
2561 my $data = `$cpp -D__PIDL__$includes -xc $filename`;
2564 return parse_string($data, $filename);