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 ####################################################################
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
703 'property_list' => 51
712 'optional_semicolon' => 58
791 'commalisttext' => 66
834 'commalisttext' => 69
913 'property_list' => 75
933 'property_list' => 51
961 'property_list' => 89
1161 'optional_semicolon' => 96
1221 'decl_bitmap' => 105,
1292 'union_elements' => 112
1300 'identifier' => 113,
1301 'enum_element' => 114,
1302 'enum_elements' => 115
1310 'identifier' => 118,
1311 'bitmap_elements' => 117,
1312 'bitmap_element' => 116
1323 'element_list1' => 120
1412 'optional_base_element' => 128,
1413 'property_list' => 127
1453 'base_element' => 135,
1454 'element_list2' => 138,
1455 'property_list' => 136
1464 'base_element' => 140,
1465 'property_list' => 136
1521 'base_or_empty' => 147,
1522 'base_element' => 148,
1523 'empty_element' => 149,
1524 'property_list' => 150
1552 'identifier' => 113,
1553 'enum_element' => 152
1564 'identifier' => 118,
1565 'bitmap_element' => 153
1764 'base_element' => 166,
1765 'property_list' => 136
1862 #line 19 "build/pidl/idl.yp"
1863 { push(@{$_[1]}, $_[2]); $_[1] }
1868 #line 20 "build/pidl/idl.yp"
1869 { push(@{$_[1]}, $_[2]); $_[1] }
1874 #line 24 "build/pidl/idl.yp"
1876 "TYPE" => "COCLASS",
1877 "PROPERTIES" => $_[1],
1880 "FILE" => $_[0]->YYData->{INPUT_FILENAME},
1881 "LINE" => $_[0]->YYData->{LINE},
1885 'interface_names', 0, undef
1888 'interface_names', 4,
1890 #line 36 "build/pidl/idl.yp"
1891 { push(@{$_[1]}, $_[2]); $_[1] }
1896 #line 40 "build/pidl/idl.yp"
1898 "TYPE" => "INTERFACE",
1899 "PROPERTIES" => $_[1],
1903 "FILE" => $_[0]->YYData->{INPUT_FILENAME},
1904 "LINE" => $_[0]->YYData->{LINE},
1908 'base_interface', 0, undef
1911 'base_interface', 2,
1913 #line 53 "build/pidl/idl.yp"
1919 #line 57 "build/pidl/idl.yp"
1925 #line 58 "build/pidl/idl.yp"
1926 { push(@{$_[1]}, $_[2]); $_[1] }
1929 'definition', 1, undef
1932 'definition', 1, undef
1935 'definition', 1, undef
1938 'definition', 1, undef
1943 #line 66 "build/pidl/idl.yp"
1949 "FILE" => $_[0]->YYData->{INPUT_FILENAME},
1950 "LINE" => $_[0]->YYData->{LINE},
1956 #line 75 "build/pidl/idl.yp"
1961 "ARRAY_LEN" => $_[4],
1963 "FILE" => $_[0]->YYData->{INPUT_FILENAME},
1964 "LINE" => $_[0]->YYData->{LINE},
1970 #line 88 "build/pidl/idl.yp"
1972 "TYPE" => "FUNCTION",
1974 "RETURN_TYPE" => $_[2],
1975 "PROPERTIES" => $_[1],
1976 "ELEMENTS" => $_[5],
1977 "FILE" => $_[0]->YYData->{INPUT_FILENAME},
1978 "LINE" => $_[0]->YYData->{LINE},
1984 #line 100 "build/pidl/idl.yp"
1986 "TYPE" => "DECLARE",
1987 "PROPERTIES" => $_[2],
1990 "FILE" => $_[0]->YYData->{INPUT_FILENAME},
1991 "LINE" => $_[0]->YYData->{LINE},
1995 'decl_type', 1, undef
1998 'decl_type', 1, undef
2003 #line 114 "build/pidl/idl.yp"
2011 #line 120 "build/pidl/idl.yp"
2019 #line 126 "build/pidl/idl.yp"
2021 "TYPE" => "TYPEDEF",
2022 "PROPERTIES" => $_[2],
2025 "ARRAY_LEN" => $_[5],
2026 "FILE" => $_[0]->YYData->{INPUT_FILENAME},
2027 "LINE" => $_[0]->YYData->{LINE},
2048 #line 138 "build/pidl/idl.yp"
2054 #line 143 "build/pidl/idl.yp"
2063 #line 150 "build/pidl/idl.yp"
2069 #line 151 "build/pidl/idl.yp"
2070 { push(@{$_[1]}, $_[3]); $_[1] }
2073 'enum_element', 1, undef
2078 #line 155 "build/pidl/idl.yp"
2079 { "$_[1]$_[2]$_[3]" }
2084 #line 159 "build/pidl/idl.yp"
2091 'bitmap_elements', 1,
2093 #line 166 "build/pidl/idl.yp"
2097 'bitmap_elements', 3,
2099 #line 167 "build/pidl/idl.yp"
2100 { push(@{$_[1]}, $_[3]); $_[1] }
2103 'bitmap_element', 3,
2105 #line 170 "build/pidl/idl.yp"
2106 { "$_[1] ( $_[3] )" }
2111 #line 174 "build/pidl/idl.yp"
2120 #line 181 "build/pidl/idl.yp"
2124 "PROPERTIES" => $_[1],
2127 "FILE" => $_[0]->YYData->{INPUT_FILENAME},
2128 "LINE" => $_[0]->YYData->{LINE},
2132 'base_or_empty', 2, undef
2135 'base_or_empty', 1, undef
2138 'optional_base_element', 2,
2140 #line 195 "build/pidl/idl.yp"
2141 { $_[2]->{PROPERTIES} = util::FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2144 'union_elements', 0, undef
2147 'union_elements', 2,
2149 #line 200 "build/pidl/idl.yp"
2150 { push(@{$_[1]}, $_[2]); $_[1] }
2155 #line 204 "build/pidl/idl.yp"
2164 #line 211 "build/pidl/idl.yp"
2168 "PROPERTIES" => $_[1],
2169 "POINTERS" => $_[3],
2170 "ARRAY_LEN" => $_[5],
2171 "FILE" => $_[0]->YYData->{INPUT_FILENAME},
2172 "LINE" => $_[0]->YYData->{LINE},
2178 #line 225 "build/pidl/idl.yp"
2184 #line 226 "build/pidl/idl.yp"
2188 'element_list1', 0, undef
2193 #line 231 "build/pidl/idl.yp"
2194 { push(@{$_[1]}, $_[2]); $_[1] }
2197 'element_list2', 0, undef
2200 'element_list2', 1, undef
2205 #line 237 "build/pidl/idl.yp"
2211 #line 238 "build/pidl/idl.yp"
2212 { push(@{$_[1]}, $_[3]); $_[1] }
2215 'array_len', 0, undef
2220 #line 243 "build/pidl/idl.yp"
2221 { push(@{$_[3]}, "*"); $_[3] }
2226 #line 244 "build/pidl/idl.yp"
2227 { push(@{$_[4]}, "$_[2]"); $_[4] }
2230 'property_list', 0, undef
2235 #line 250 "build/pidl/idl.yp"
2236 { util::FlattenHash([$_[1],$_[3]]); }
2241 #line 253 "build/pidl/idl.yp"
2247 #line 254 "build/pidl/idl.yp"
2248 { util::FlattenHash([$_[1], $_[3]]); }
2253 #line 257 "build/pidl/idl.yp"
2254 {{ "$_[1]" => "1" }}
2259 #line 258 "build/pidl/idl.yp"
2260 {{ "$_[1]" => "$_[3]" }}
2263 'listtext', 1, undef
2268 #line 263 "build/pidl/idl.yp"
2272 'commalisttext', 1, undef
2277 #line 268 "build/pidl/idl.yp"
2283 #line 272 "build/pidl/idl.yp"
2298 #line 274 "build/pidl/idl.yp"
2299 { "$_[1]$_[2]$_[3]" }
2304 #line 275 "build/pidl/idl.yp"
2305 { "$_[1]$_[2]$_[3]" }
2310 #line 276 "build/pidl/idl.yp"
2311 { "$_[1]$_[2]$_[3]" }
2316 #line 277 "build/pidl/idl.yp"
2317 { "$_[1]$_[2]$_[3]" }
2322 #line 278 "build/pidl/idl.yp"
2323 { "$_[1]$_[2]$_[3]" }
2328 #line 279 "build/pidl/idl.yp"
2329 { "$_[1]$_[2]$_[3]" }
2334 #line 280 "build/pidl/idl.yp"
2335 { "$_[1]$_[2]$_[3]" }
2340 #line 281 "build/pidl/idl.yp"
2341 { "$_[1]$_[2]$_[3]" }
2346 #line 282 "build/pidl/idl.yp"
2347 { "$_[1]$_[2]$_[3]" }
2352 #line 283 "build/pidl/idl.yp"
2353 { "$_[1]$_[2]$_[3]" }
2358 #line 284 "build/pidl/idl.yp"
2359 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2364 #line 285 "build/pidl/idl.yp"
2365 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2368 'identifier', 1, undef
2371 'constant', 1, undef
2376 #line 294 "build/pidl/idl.yp"
2380 'optional_semicolon', 0, undef
2383 'optional_semicolon', 1, undef
2387 bless($self,$class);
2390 #line 305 "build/pidl/idl.yp"
2396 if (exists $_[0]->YYData->{ERRMSG}) {
2397 print $_[0]->YYData->{ERRMSG};
2398 delete $_[0]->YYData->{ERRMSG};
2401 my $line = $_[0]->YYData->{LINE};
2402 my $last_token = $_[0]->YYData->{LAST_TOKEN};
2403 my $file = $_[0]->YYData->{INPUT_FILENAME};
2405 print "$file:$line: Syntax error near '$last_token'\n";
2412 $parser->YYData->{INPUT}
2413 or return('',undef);
2416 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
2418 for ($parser->YYData->{INPUT}) {
2420 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2421 $parser->YYData->{LINE} = $1-1;
2422 $parser->YYData->{INPUT_FILENAME} = $2;
2425 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2426 $parser->YYData->{LINE} = $1-1;
2427 $parser->YYData->{INPUT_FILENAME} = $2;
2430 if (s/^(\#.*)$//m) {
2435 $parser->YYData->{LINE}++;
2438 if (s/^\"(.*?)\"//) {
2439 $parser->YYData->{LAST_TOKEN} = $1;
2442 if (s/^(\d+)(\W|$)/$2/) {
2443 $parser->YYData->{LAST_TOKEN} = $1;
2444 return('CONSTANT',$1);
2446 if (s/^([\w_]+)//) {
2447 $parser->YYData->{LAST_TOKEN} = $1;
2449 /^(coclass|interface|const|typedef|declare|union
2450 |struct|enum|bitmap|void)$/x) {
2453 return('IDENTIFIER',$1);
2456 $parser->YYData->{LAST_TOKEN} = $1;
2465 my $filename = shift;
2467 my $saved_delim = $/;
2469 my $cpp = $ENV{CPP};
2470 if (! defined $cpp) {
2473 my $data = `$cpp -xc $filename`;
2476 $self->YYData->{INPUT} = $data;
2477 $self->YYData->{LINE} = 0;
2478 $self->YYData->{LAST_TOKEN} = "NONE";
2480 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2482 return util::CleanData($idl);