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 #Included Parse/Yapp/Driver.pm file----------------------------------------
18 # Module Parse::Yapp::Driver
20 # This module is part of the Parse::Yapp package available on your
23 # Any use of this module in a standalone parser make the included
24 # text under the same copyright as the Parse::Yapp module itself.
26 # This notice should remain unchanged.
28 # (c) Copyright 1998-2001 Francois Desarmenien, all rights reserved.
29 # (see the pod text in Parse::Yapp module for use and distribution rights)
32 package Parse
::Yapp
::Driver
;
38 use vars qw
( $VERSION $COMPATIBLE $FILENAME );
46 #Known parameters, all starting with YY (leading YY will be discarded)
47 my(%params)=(YYLEX
=> 'CODE', 'YYERROR' => 'CODE', YYVERSION
=> '',
48 YYRULES
=> 'ARRAY', YYSTATES
=> 'ARRAY', YYDEBUG
=> '');
50 my(@params)=('LEX','RULES','STATES');
54 my($errst,$nberr,$token,$value,$check,$dotpos);
55 my($self)={ ERROR
=> \
&_Error
,
65 _CheckParams
( [], \
%params, \
@_, $self );
67 exists($$self{VERSION
})
68 and $$self{VERSION
} < $COMPATIBLE
69 and croak
"Yapp driver version $VERSION ".
70 "incompatible with version $$self{VERSION}:\n".
71 "Please recompile parser module.";
74 and $class=ref($class);
83 _CheckParams
( \
@params, \
%params, \
@_, $self );
87 $retval = eval '$self->_DBParse()';#Do not create stab entry on compile
91 $retval = $self->_Parse();
122 ${$$self{ERRST
}} != 0;
128 ${$$self{CHECK}}='ABORT';
135 ${$$self{CHECK}}='ACCEPT';
142 ${$$self{CHECK}}='ERROR';
148 my($index)= $_[0] - ${$$self{DOTPOS
}} - 1;
151 and -$index <= @
{$$self{STACK
}}
152 and return $$self{STACK
}[$index][1];
154 undef; #Invalid index
161 and ${$$self{TOKEN
}}=$_[0];
169 and ${$$self{VALUE
}}=$_[0];
176 keys %{$self->{STATES
}[$self->{STACK
}[-1][0]]{ACTIONS
}}
192 my($mandatory,$checklist,$inarray,$outhash)=@_;
196 while(($prm,$value)=splice(@
$inarray,0,2)) {
198 exists($$checklist{$prm})
199 or croak
("Unknow parameter '$prm'");
200 ref($value) eq $$checklist{$prm}
201 or croak
("Invalid value for parameter '$prm'");
202 $prm=unpack('@2A*',$prm);
203 $$outhash{$prm}=$value;
206 exists($$outhash{$_})
207 or croak
("Missing mandatory parameter '".lc($_)."'");
212 print "Parse error.\n";
219 exists(${__PACKAGE__
.'::'}{_DBParse
})#Already loaded ?
224 open(DRV
,"<$fname") or die "Report this as a BUG: Cannot open $fname";
226 /^\s*sub\s+_Parse\s*{\s*$/ .. /^\s*}\s*#\s*_Parse\s*$/
238 #Note that for loading debugging version of the driver,
239 #this file will be parsed from 'sub _Parse' up to '}#_Parse' inclusive.
240 #So, DO NOT remove comment at end of sub !!!
244 my($rules,$states,$lex,$error)
245 = @
$self{ 'RULES', 'STATES', 'LEX', 'ERROR' };
246 my($errstatus,$nberror,$token,$value,$stack,$check,$dotpos)
247 = @
$self{ 'ERRST', 'NBERR', 'TOKEN', 'VALUE', 'STACK', 'CHECK', 'DOTPOS' };
249 #DBG> my($debug)=$$self{DEBUG};
250 #DBG> my($dbgerror)=0;
252 #DBG> my($ShowCurToken) = sub {
254 #DBG> for (split('',$$token)) {
255 #DBG> $tok.= (ord($_) < 32 or ord($_) > 126)
256 #DBG> ? sprintf('<%02X>',ord($_))
264 ($$token,$$value)=(undef,undef);
265 @
$stack=( [ 0, undef ] );
269 my($actions,$act,$stateno);
271 $stateno=$$stack[-1][0];
272 $actions=$$states[$stateno];
274 #DBG> print STDERR ('-' x 40),"\n";
276 #DBG> and print STDERR "In state $stateno:\n";
278 #DBG> and print STDERR "Stack:[".
279 #DBG> join(',',map { $$_[0] } @$stack).
283 if (exists($$actions{ACTIONS
})) {
287 ($$token,$$value)=&$lex($self);
289 #DBG> and print STDERR "Need token. Got ".&$ShowCurToken."\n";
292 $act= exists($$actions{ACTIONS
}{$$token})
293 ?
$$actions{ACTIONS
}{$$token}
294 : exists($$actions{DEFAULT
})
299 $act=$$actions{DEFAULT
};
301 #DBG> and print STDERR "Don't need token.\n";
311 #DBG> and print STDERR "Shift and go to state $act.\n";
319 #DBG> and $$errstatus == 0
321 #DBG> print STDERR "**End of Error recovery.\n";
327 push(@
$stack,[ $act, $$value ]);
329 $$token ne '' #Don't eat the eof
330 and $$token=$$value=undef;
335 my($lhs,$len,$code,@sempar,$semval);
336 ($lhs,$len,$code)=@
{$$rules[-$act]};
340 #DBG> and print STDERR "Reduce using rule ".-$act." ($lhs,$len): ";
343 or $self->YYAccept();
347 unpack('A1',$lhs) eq '@' #In line rule
349 $lhs =~ /^\@[0-9]+\-([0-9]+)$/
350 or die "In line rule name '$lhs' ill formed: ".
351 "report it as a BUG.\n";
356 ?
map { $$_[1] } @
$stack[ -$$dotpos .. -1 ]
359 $semval = $code ?
&$code( $self, @sempar )
360 : @sempar ?
$sempar[0] : undef;
362 splice(@
$stack,-$len,$len);
368 #DBG> and print STDERR "Accept.\n";
377 #DBG> and print STDERR "Abort.\n";
384 #DBG> and print STDERR "Back to state $$stack[-1][0], then ";
389 #DBG> and print STDERR
390 #DBG> "go to state $$states[$$stack[-1][0]]{GOTOS}{$lhs}.\n";
394 #DBG> and $$errstatus == 0
396 #DBG> print STDERR "**End of Error recovery.\n";
401 [ $$states[$$stack[-1][0]]{GOTOS
}{$lhs}, $semval ]);
407 #DBG> and print STDERR "Forced Error recovery.\n";
419 $$errstatus # if 0, then YYErrok has been called
420 or next; # so continue parsing
424 #DBG> print STDERR "**Entering Error recovery.\n";
432 $$errstatus == 3 #The next token is not valid: discard it
434 $$token eq '' # End of input: no hope
437 #DBG> and print STDERR "**At eof: aborting.\n";
442 #DBG> and print STDERR "**Dicard invalid token ".&$ShowCurToken.".\n";
444 $$token=$$value=undef;
450 and ( not exists($$states[$$stack[-1][0]]{ACTIONS
})
451 or not exists($$states[$$stack[-1][0]]{ACTIONS
}{error
})
452 or $$states[$$stack[-1][0]]{ACTIONS
}{error
} <= 0)) {
455 #DBG> and print STDERR "**Pop state $$stack[-1][0].\n";
464 #DBG> and print STDERR "**No state left on stack: aborting.\n";
469 #shift the error token
472 #DBG> and print STDERR "**Shift \$error token and go to state ".
473 #DBG> $$states[$$stack[-1][0]]{ACTIONS}{error}.
476 push(@
$stack, [ $$states[$$stack[-1][0]]{ACTIONS
}{error
}, undef ]);
481 croak
("Error in driver logic. Please, report it as a BUG");
484 #DO NOT remove comment
489 #End of include--------------------------------------------------
497 and $class=ref($class);
499 my($self)=$class->SUPER::new
( yyversion
=> '1.05',
590 'base_interface' => 20
596 'interface_names' => 21
709 'property_list' => 56,
725 'optional_semicolon' => 72
832 'commalisttext' => 81
889 'commalisttext' => 85
968 'property_list' => 91
977 'optional_identifier' => 93
1000 'property_list' => 56,
1041 'property_list' => 101
1067 'optional_identifier' => 103
1079 'optional_identifier' => 104
1088 'optional_identifier' => 105
1388 'optional_semicolon' => 112
1422 'decl_bitmap' => 115,
1505 'union_elements' => 127
1548 'element_list1' => 133
1556 'identifier' => 134,
1557 'enum_element' => 135,
1558 'enum_elements' => 136
1566 'identifier' => 139,
1567 'bitmap_elements' => 138,
1568 'bitmap_element' => 137
1637 'optional_base_element' => 143,
1638 'property_list' => 142
1649 'base_element' => 144,
1650 'element_list2' => 146,
1651 'property_list' => 145
1699 'base_element' => 154,
1700 'property_list' => 145
1746 'base_or_empty' => 162,
1747 'base_element' => 163,
1748 'empty_element' => 164,
1749 'property_list' => 165
1883 'identifier' => 134,
1884 'enum_element' => 175
1895 'identifier' => 139,
1896 'bitmap_element' => 176
1957 'base_element' => 181,
1958 'property_list' => 145
2104 #line 19 "pidl/idl.yp"
2105 { push(@
{$_[1]}, $_[2]); $_[1] }
2110 #line 20 "pidl/idl.yp"
2111 { push(@
{$_[1]}, $_[2]); $_[1] }
2116 #line 24 "pidl/idl.yp"
2118 "TYPE" => "COCLASS",
2119 "PROPERTIES" => $_[1],
2122 "FILE" => $_[0]->YYData->{INPUT_FILENAME
},
2123 "LINE" => $_[0]->YYData->{LINE
},
2127 'interface_names', 0, undef
2130 'interface_names', 4,
2132 #line 36 "pidl/idl.yp"
2133 { push(@
{$_[1]}, $_[2]); $_[1] }
2138 #line 40 "pidl/idl.yp"
2140 "TYPE" => "INTERFACE",
2141 "PROPERTIES" => $_[1],
2145 "FILE" => $_[0]->YYData->{INPUT_FILENAME
},
2146 "LINE" => $_[0]->YYData->{LINE
},
2150 'base_interface', 0, undef
2153 'base_interface', 2,
2155 #line 53 "pidl/idl.yp"
2161 #line 57 "pidl/idl.yp"
2167 #line 58 "pidl/idl.yp"
2168 { push(@
{$_[1]}, $_[2]); $_[1] }
2171 'definition', 1, undef
2174 'definition', 1, undef
2177 'definition', 1, undef
2180 'definition', 1, undef
2183 'definition', 1, undef
2188 #line 66 "pidl/idl.yp"
2194 "FILE" => $_[0]->YYData->{INPUT_FILENAME
},
2195 "LINE" => $_[0]->YYData->{LINE
},
2201 #line 75 "pidl/idl.yp"
2206 "ARRAY_LEN" => $_[4],
2208 "FILE" => $_[0]->YYData->{INPUT_FILENAME
},
2209 "LINE" => $_[0]->YYData->{LINE
},
2215 #line 88 "pidl/idl.yp"
2217 "TYPE" => "FUNCTION",
2219 "RETURN_TYPE" => $_[2],
2220 "PROPERTIES" => $_[1],
2221 "ELEMENTS" => $_[5],
2222 "FILE" => $_[0]->YYData->{INPUT_FILENAME
},
2223 "LINE" => $_[0]->YYData->{LINE
},
2229 #line 100 "pidl/idl.yp"
2231 "TYPE" => "DECLARE",
2232 "PROPERTIES" => $_[2],
2235 "FILE" => $_[0]->YYData->{INPUT_FILENAME
},
2236 "LINE" => $_[0]->YYData->{LINE
},
2240 'decl_type', 1, undef
2243 'decl_type', 1, undef
2248 #line 114 "pidl/idl.yp"
2256 #line 120 "pidl/idl.yp"
2264 #line 126 "pidl/idl.yp"
2266 "TYPE" => "TYPEDEF",
2267 "PROPERTIES" => $_[2],
2270 "ARRAY_LEN" => $_[5],
2271 "FILE" => $_[0]->YYData->{INPUT_FILENAME
},
2272 "LINE" => $_[0]->YYData->{LINE
},
2276 'usertype', 1, undef
2279 'usertype', 1, undef
2282 'usertype', 1, undef
2285 'usertype', 1, undef
2290 #line 139 "pidl/idl.yp"
2302 #line 142 "pidl/idl.yp"
2308 #line 146 "pidl/idl.yp"
2318 #line 154 "pidl/idl.yp"
2324 #line 155 "pidl/idl.yp"
2325 { push(@
{$_[1]}, $_[3]); $_[1] }
2328 'enum_element', 1, undef
2333 #line 159 "pidl/idl.yp"
2334 { "$_[1]$_[2]$_[3]" }
2339 #line 163 "pidl/idl.yp"
2347 'bitmap_elements', 1,
2349 #line 171 "pidl/idl.yp"
2353 'bitmap_elements', 3,
2355 #line 172 "pidl/idl.yp"
2356 { push(@
{$_[1]}, $_[3]); $_[1] }
2359 'bitmap_element', 3,
2361 #line 175 "pidl/idl.yp"
2362 { "$_[1] ( $_[3] )" }
2367 #line 179 "pidl/idl.yp"
2377 #line 187 "pidl/idl.yp"
2381 "PROPERTIES" => $_[1],
2384 "FILE" => $_[0]->YYData->{INPUT_FILENAME
},
2385 "LINE" => $_[0]->YYData->{LINE
},
2389 'base_or_empty', 2, undef
2392 'base_or_empty', 1, undef
2395 'optional_base_element', 2,
2397 #line 201 "pidl/idl.yp"
2398 { $_[2]->{PROPERTIES
} = Parse
::Pidl
::Util
::FlattenHash
([$_[1],$_[2]->{PROPERTIES
}]); $_[2] }
2401 'union_elements', 0, undef
2404 'union_elements', 2,
2406 #line 206 "pidl/idl.yp"
2407 { push(@
{$_[1]}, $_[2]); $_[1] }
2412 #line 210 "pidl/idl.yp"
2422 #line 218 "pidl/idl.yp"
2426 "PROPERTIES" => $_[1],
2427 "POINTERS" => $_[3],
2428 "ARRAY_LEN" => $_[5],
2429 "FILE" => $_[0]->YYData->{INPUT_FILENAME
},
2430 "LINE" => $_[0]->YYData->{LINE
},
2436 #line 232 "pidl/idl.yp"
2442 #line 233 "pidl/idl.yp"
2446 'element_list1', 0, undef
2451 #line 238 "pidl/idl.yp"
2452 { push(@
{$_[1]}, $_[2]); $_[1] }
2455 'element_list2', 0, undef
2458 'element_list2', 1, undef
2463 #line 244 "pidl/idl.yp"
2469 #line 245 "pidl/idl.yp"
2470 { push(@
{$_[1]}, $_[3]); $_[1] }
2473 'array_len', 0, undef
2478 #line 250 "pidl/idl.yp"
2479 { push(@
{$_[3]}, "*"); $_[3] }
2484 #line 251 "pidl/idl.yp"
2485 { push(@
{$_[4]}, "$_[2]"); $_[4] }
2488 'property_list', 0, undef
2493 #line 257 "pidl/idl.yp"
2494 { Parse
::Pidl
::Util
::FlattenHash
([$_[1],$_[3]]); }
2499 #line 260 "pidl/idl.yp"
2505 #line 261 "pidl/idl.yp"
2506 { Parse
::Pidl
::Util
::FlattenHash
([$_[1], $_[3]]); }
2511 #line 264 "pidl/idl.yp"
2512 {{ "$_[1]" => "1" }}
2517 #line 265 "pidl/idl.yp"
2518 {{ "$_[1]" => "$_[3]" }}
2521 'listtext', 1, undef
2526 #line 270 "pidl/idl.yp"
2530 'commalisttext', 1, undef
2535 #line 275 "pidl/idl.yp"
2541 #line 279 "pidl/idl.yp"
2556 #line 281 "pidl/idl.yp"
2557 { "$_[1]$_[2]$_[3]" }
2562 #line 282 "pidl/idl.yp"
2563 { "$_[1]$_[2]$_[3]" }
2568 #line 283 "pidl/idl.yp"
2569 { "$_[1]$_[2]$_[3]" }
2574 #line 284 "pidl/idl.yp"
2575 { "$_[1]$_[2]$_[3]" }
2580 #line 285 "pidl/idl.yp"
2581 { "$_[1]$_[2]$_[3]" }
2586 #line 286 "pidl/idl.yp"
2587 { "$_[1]$_[2]$_[3]" }
2592 #line 287 "pidl/idl.yp"
2593 { "$_[1]$_[2]$_[3]" }
2598 #line 288 "pidl/idl.yp"
2599 { "$_[1]$_[2]$_[3]" }
2604 #line 289 "pidl/idl.yp"
2605 { "$_[1]$_[2]$_[3]" }
2610 #line 290 "pidl/idl.yp"
2611 { "$_[1]$_[2]$_[3]" }
2616 #line 291 "pidl/idl.yp"
2617 { "$_[1]$_[2]$_[3]" }
2622 #line 292 "pidl/idl.yp"
2623 { "$_[1]$_[2]$_[3]" }
2628 #line 293 "pidl/idl.yp"
2629 { "$_[1]$_[2]$_[3]" }
2634 #line 294 "pidl/idl.yp"
2635 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2640 #line 295 "pidl/idl.yp"
2641 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2644 'identifier', 1, undef
2647 'optional_identifier', 1, undef
2650 'optional_identifier', 0, undef
2653 'constant', 1, undef
2658 #line 309 "pidl/idl.yp"
2662 'optional_semicolon', 0, undef
2665 'optional_semicolon', 1, undef
2669 bless($self,$class);
2672 #line 320 "pidl/idl.yp"
2675 use Parse
::Pidl
::Util
;
2677 #####################################################################
2678 # traverse a perl data structure removing any empty arrays or
2679 # hashes and any hash elements that map to undef
2684 if (ref($v) eq "ARRAY") {
2685 foreach my $i (0 .. $#{$v}) {
2686 CleanData
($v->[$i]);
2687 if (ref($v->[$i]) eq "ARRAY" && $#{$v->[$i]}==-1) {
2692 # this removes any undefined elements from the array
2693 @
{$v} = grep { defined $_ } @
{$v};
2694 } elsif (ref($v) eq "HASH") {
2695 foreach my $x (keys %{$v}) {
2696 CleanData
($v->{$x});
2697 if (!defined $v->{$x}) { delete($v->{$x}); next; }
2698 if (ref($v->{$x}) eq "ARRAY" && $#{$v->{$x}}==-1) { delete($v->{$x}); next; }
2705 if (exists $_[0]->YYData->{ERRMSG
}) {
2706 print $_[0]->YYData->{ERRMSG
};
2707 delete $_[0]->YYData->{ERRMSG
};
2710 my $line = $_[0]->YYData->{LINE
};
2711 my $last_token = $_[0]->YYData->{LAST_TOKEN
};
2712 my $file = $_[0]->YYData->{INPUT_FILENAME
};
2714 print "$file:$line: Syntax error near '$last_token'\n";
2721 $parser->YYData->{INPUT
} or return('',undef);
2724 $parser->YYData->{INPUT
} =~ s/^[ \t]*//;
2726 for ($parser->YYData->{INPUT
}) {
2728 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2729 $parser->YYData->{LINE
} = $1-1;
2730 $parser->YYData->{INPUT_FILENAME
} = $2;
2733 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2734 $parser->YYData->{LINE
} = $1-1;
2735 $parser->YYData->{INPUT_FILENAME
} = $2;
2738 if (s/^(\#.*)$//m) {
2743 $parser->YYData->{LINE
}++;
2746 if (s/^\"(.*?)\"//) {
2747 $parser->YYData->{LAST_TOKEN
} = $1;
2750 if (s/^(\d+)(\W|$)/$2/) {
2751 $parser->YYData->{LAST_TOKEN
} = $1;
2752 return('CONSTANT',$1);
2754 if (s/^([\w_]+)//) {
2755 $parser->YYData->{LAST_TOKEN
} = $1;
2757 /^(coclass
|interface
|const
|typedef
|declare
|union
2758 |struct
|enum
|bitmap
|void
)$/x
) {
2761 return('IDENTIFIER',$1);
2764 $parser->YYData->{LAST_TOKEN
} = $1;
2772 my ($self,$filename) = @_;
2774 my $saved_delim = $/;
2776 my $cpp = $ENV{CPP
};
2777 if (! defined $cpp) {
2780 my $data = `$cpp -D__PIDL__ -xc $filename`;
2783 $self->YYData->{INPUT
} = $data;
2784 $self->YYData->{LINE
} = 0;
2785 $self->YYData->{LAST_TOKEN
} = "NONE";
2787 my $idl = $self->YYParse( yylex
=> \
&_Lexer
, yyerror
=> \
&_Error
);
2789 return CleanData
($idl);