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
244 'property_list' => 47,
308 'property_list' => 47,
337 'existingtype' => 78,
340 'property_list' => 72,
359 'property_list' => 83
435 'optional_semicolon' => 107
452 'optional_semicolon' => 109
470 'existingtype' => 78,
473 'property_list' => 72,
488 'optional_identifier' => 112
523 'optional_identifier' => 114
538 'optional_identifier' => 115
547 'optional_identifier' => 116
702 'commalisttext' => 131
759 'commalisttext' => 135
853 'opt_union_body' => 142
865 'struct_body' => 145,
866 'opt_struct_body' => 147
875 'opt_enum_body' => 150,
885 'bitmap_body' => 153,
886 'opt_bitmap_body' => 151
1175 'union_elements' => 163
1187 'element_list1' => 164
1198 'identifier' => 165,
1199 'enum_element' => 166,
1200 'enum_elements' => 167
1218 'identifier' => 170,
1219 'bitmap_element' => 169,
1220 'bitmap_elements' => 168,
1221 'opt_bitmap_elements' => 171
1235 'base_element' => 172,
1236 'element_list2' => 174,
1237 'property_list' => 173
1323 'optional_base_element' => 186,
1324 'property_list' => 185
1333 'base_element' => 188,
1334 'property_list' => 173
1384 'existingtype' => 78,
1387 'property_list' => 72,
1516 'base_or_empty' => 202,
1517 'base_element' => 203,
1518 'empty_element' => 204,
1519 'property_list' => 205
1555 'identifier' => 165,
1556 'enum_element' => 208
1564 'identifier' => 170,
1565 'bitmap_element' => 209
1594 'base_element' => 212,
1595 'property_list' => 173
1671 'existingtype' => 78,
1674 'property_list' => 72,
1807 { push(@{$_[1]}, $_[2]); $_[1] }
1813 { push(@{$_[1]}, $_[2]); $_[1] }
1819 { push(@{$_[1]}, $_[2]); $_[1] }
1825 { push(@{$_[1]}, $_[2]); $_[1] }
1831 { push(@{$_[1]}, $_[2]); $_[1] }
1837 { push(@{$_[1]}, $_[2]); $_[1] }
1846 "FILE" => $_[0]->YYData->{FILE},
1847 "LINE" => $_[0]->YYData->{LINE}
1855 "TYPE" => "INCLUDE",
1857 "FILE" => $_[0]->YYData->{FILE},
1858 "LINE" => $_[0]->YYData->{LINE}
1866 "TYPE" => "IMPORTLIB",
1868 "FILE" => $_[0]->YYData->{FILE},
1869 "LINE" => $_[0]->YYData->{LINE}
1882 { push(@{$_[1]}, $_[3]); $_[1] }
1889 "TYPE" => "COCLASS",
1890 "PROPERTIES" => $_[1],
1893 "FILE" => $_[0]->YYData->{FILE},
1894 "LINE" => $_[0]->YYData->{LINE},
1898 'interface_names', 0, undef
1901 'interface_names', 4,
1904 { push(@{$_[1]}, $_[2]); $_[1] }
1911 "TYPE" => "INTERFACE",
1912 "PROPERTIES" => $_[1],
1915 "FILE" => $_[0]->YYData->{FILE},
1916 "LINE" => $_[0]->YYData->{LINE},
1924 "TYPE" => "CPP_QUOTE",
1925 "FILE" => $_[0]->YYData->{FILE},
1926 "LINE" => $_[0]->YYData->{LINE},
1940 { push(@{$_[1]}, $_[2]); $_[1] }
1943 'definition', 1, undef
1946 'definition', 1, undef
1949 'definition', 1, undef
1952 'definition', 1, undef
1955 'definition', 1, undef
1964 "POINTERS" => $_[3],
1967 "FILE" => $_[0]->YYData->{FILE},
1968 "LINE" => $_[0]->YYData->{LINE},
1978 "POINTERS" => $_[3],
1980 "ARRAY_LEN" => $_[5],
1982 "FILE" => $_[0]->YYData->{FILE},
1983 "LINE" => $_[0]->YYData->{LINE},
1991 "TYPE" => "FUNCTION",
1993 "RETURN_TYPE" => $_[2],
1994 "PROPERTIES" => $_[1],
1995 "ELEMENTS" => $_[5],
1996 "FILE" => $_[0]->YYData->{FILE},
1997 "LINE" => $_[0]->YYData->{LINE},
2005 "TYPE" => "DECLARE",
2008 "FILE" => $_[0]->YYData->{FILE},
2009 "LINE" => $_[0]->YYData->{LINE},
2013 'decl_type', 1, undef
2016 'decl_type', 1, undef
2019 'decl_type', 1, undef
2027 "PROPERTIES" => $_[1]
2036 "PROPERTIES" => $_[1]
2045 "PROPERTIES" => $_[1]
2053 "TYPE" => "TYPEDEF",
2054 "PROPERTIES" => $_[1],
2057 "ARRAY_LEN" => $_[5],
2058 "FILE" => $_[0]->YYData->{FILE},
2059 "LINE" => $_[0]->YYData->{LINE},
2063 'usertype', 1, undef
2066 'usertype', 1, undef
2069 'usertype', 1, undef
2072 'usertype', 1, undef
2090 { ($_[1]?$_[1]:"signed") ." $_[2]" }
2093 'existingtype', 1, undef
2114 'opt_enum_body', 0, undef
2117 'opt_enum_body', 1, undef
2125 "PROPERTIES" => $_[1],
2140 { push(@{$_[1]}, $_[3]); $_[1] }
2143 'enum_element', 1, undef
2149 { "$_[1]$_[2]$_[3]" }
2158 'opt_bitmap_body', 0, undef
2161 'opt_bitmap_body', 1, undef
2169 "PROPERTIES" => $_[1],
2175 'bitmap_elements', 1,
2181 'bitmap_elements', 3,
2184 { push(@{$_[1]}, $_[3]); $_[1] }
2187 'opt_bitmap_elements', 0, undef
2190 'opt_bitmap_elements', 1, undef
2193 'bitmap_element', 3,
2196 { "$_[1] ( $_[3] )" }
2205 'opt_struct_body', 0, undef
2208 'opt_struct_body', 1, undef
2216 "PROPERTIES" => $_[1],
2228 "PROPERTIES" => $_[1],
2231 "FILE" => $_[0]->YYData->{FILE},
2232 "LINE" => $_[0]->YYData->{LINE},
2236 'base_or_empty', 2, undef
2239 'base_or_empty', 1, undef
2242 'optional_base_element', 2,
2245 { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2248 'union_elements', 0, undef
2251 'union_elements', 2,
2254 { push(@{$_[1]}, $_[2]); $_[1] }
2263 'opt_union_body', 0, undef
2266 'opt_union_body', 1, undef
2274 "PROPERTIES" => $_[1],
2286 "PROPERTIES" => $_[1],
2287 "POINTERS" => $_[3],
2288 "ARRAY_LEN" => $_[5],
2289 "FILE" => $_[0]->YYData->{FILE},
2290 "LINE" => $_[0]->YYData->{LINE},
2315 { push(@{$_[1]}, $_[2]); $_[1] }
2318 'element_list2', 0, undef
2321 'element_list2', 1, undef
2333 { push(@{$_[1]}, $_[3]); $_[1] }
2336 'array_len', 0, undef
2342 { push(@{$_[3]}, "*"); $_[3] }
2348 { push(@{$_[4]}, "$_[2]"); $_[4] }
2351 'property_list', 0, undef
2357 { FlattenHash([$_[1],$_[3]]); }
2369 { FlattenHash([$_[1], $_[3]]); }
2375 {{ "$_[1]" => "1" }}
2381 {{ "$_[1]" => "$_[3]" }}
2384 'listtext', 1, undef
2393 'commalisttext', 1, undef
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]" }
2480 { "$_[1]$_[2]$_[3]" }
2486 { "$_[1]$_[2]$_[3]" }
2492 { "$_[1]$_[2]$_[3]" }
2498 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2504 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2507 'identifier', 1, undef
2510 'optional_identifier', 1, undef
2513 'optional_identifier', 0, undef
2516 'constant', 1, undef
2525 'optional_semicolon', 0, undef
2528 'optional_semicolon', 1, undef
2532 bless($self,$class);
2538 use Parse::Pidl qw(error);
2540 #####################################################################
2541 # flatten an array of hashes into a single hash
2547 for my $k (keys %{$d}) {
2556 #####################################################################
2557 # traverse a perl data structure removing any empty arrays or
2558 # hashes and any hash elements that map to undef
2563 return undef if (not defined($v));
2564 if (ref($v) eq "ARRAY") {
2565 foreach my $i (0 .. $#{$v}) {
2566 CleanData($v->[$i]);
2568 # this removes any undefined elements from the array
2569 @{$v} = grep { defined $_ } @{$v};
2570 } elsif (ref($v) eq "HASH") {
2571 foreach my $x (keys %{$v}) {
2572 CleanData($v->{$x});
2573 if (!defined $v->{$x}) { delete($v->{$x}); next; }
2580 if (exists $_[0]->YYData->{ERRMSG}) {
2581 error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2582 delete $_[0]->YYData->{ERRMSG};
2585 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2587 error($_[0]->YYData, "Syntax error near '$last_token'");
2594 $parser->YYData->{INPUT} or return('',undef);
2597 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2599 for ($parser->YYData->{INPUT}) {
2601 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2602 $parser->YYData->{LINE} = $1-1;
2603 $parser->YYData->{FILE} = $2;
2606 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2607 $parser->YYData->{LINE} = $1-1;
2608 $parser->YYData->{FILE} = $2;
2611 if (s/^(\#.*)$//m) {
2616 $parser->YYData->{LINE}++;
2619 if (s/^\"(.*?)\"//) {
2620 $parser->YYData->{LAST_TOKEN} = $1;
2623 if (s/^(\d+)(\W|$)/$2/) {
2624 $parser->YYData->{LAST_TOKEN} = $1;
2625 return('CONSTANT',$1);
2627 if (s/^([\w_]+)//) {
2628 $parser->YYData->{LAST_TOKEN} = $1;
2630 /^(coclass|interface|const|typedef|declare|union|cpp_quote
2631 |struct|enum|bitmap|void|unsigned|signed|import|include
2635 return('IDENTIFIER',$1);
2638 $parser->YYData->{LAST_TOKEN} = $1;
2646 my ($data,$filename) = @_;
2648 my $self = new Parse::Pidl::IDL;
2650 $self->YYData->{FILE} = $filename;
2651 $self->YYData->{INPUT} = $data;
2652 $self->YYData->{LINE} = 0;
2653 $self->YYData->{LAST_TOKEN} = "NONE";
2655 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2657 return CleanData($idl);
2662 my ($filename,$incdirs) = @_;
2664 my $saved_delim = $/;
2666 my $cpp = $ENV{CPP};
2667 if (! defined $cpp) {
2670 my $includes = join('',map { " -I$_" } @$incdirs);
2671 my $data = `$cpp -D__PIDL__$includes -xc $filename`;
2674 return parse_string($data, $filename);