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
646 'property_list' => 34
703 'property_list' => 50
712 'optional_semicolon' => 55
764 'commalisttext' => 60
821 'commalisttext' => 64
886 'property_list' => 69
904 'property_list' => 50
1064 'optional_semicolon' => 88
1182 'union_elements' => 99,
1183 'union_element' => 100
1191 'identifier' => 102,
1192 'enum_element' => 103,
1193 'enum_elements' => 104
1201 'identifier' => 107,
1202 'bitmap_elements' => 106,
1203 'bitmap_element' => 105
1214 'element_list1' => 109
1277 'union_element' => 115
1326 'base_element' => 124,
1327 'element_list2' => 127,
1328 'property_list' => 125
1337 'base_element' => 129,
1338 'property_list' => 125
1418 'identifier' => 102,
1419 'enum_element' => 138
1430 'identifier' => 107,
1431 'bitmap_element' => 139
1557 'base_element' => 150,
1558 'property_list' => 125
1606 'base_element' => 152,
1607 'property_list' => 125
1706 'base_element' => 162,
1707 'property_list' => 125
1736 #line 19 "build/pidl/idl.yp"
1737 { push(@
{$_[1]}, $_[2]); $_[1] }
1742 #line 20 "build/pidl/idl.yp"
1743 { push(@
{$_[1]}, $_[2]); $_[1] }
1748 #line 24 "build/pidl/idl.yp"
1750 "TYPE" => "COCLASS",
1751 "PROPERTIES" => $_[1],
1757 'interfaces', 0, undef
1762 #line 34 "build/pidl/idl.yp"
1763 { push(@
{$_[1]}, $_[2]); $_[1] }
1768 #line 38 "build/pidl/idl.yp"
1770 "TYPE" => "INTERFACE",
1771 "PROPERTIES" => $_[1],
1778 'base_interface', 0, undef
1781 'base_interface', 2,
1783 #line 49 "build/pidl/idl.yp"
1789 #line 53 "build/pidl/idl.yp"
1795 #line 54 "build/pidl/idl.yp"
1796 { push(@
{$_[1]}, $_[2]); $_[1] }
1799 'definition', 1, undef
1802 'definition', 1, undef
1805 'definition', 1, undef
1810 #line 62 "build/pidl/idl.yp"
1821 #line 69 "build/pidl/idl.yp"
1826 "ARRAY_LEN" => $_[4],
1833 #line 80 "build/pidl/idl.yp"
1835 "TYPE" => "FUNCTION",
1837 "RETURN_TYPE" => $_[2],
1838 "PROPERTIES" => $_[1],
1845 #line 90 "build/pidl/idl.yp"
1847 "TYPE" => "TYPEDEF",
1848 "PROPERTIES" => $_[2],
1851 "ARRAY_LEN" => $_[5]
1872 #line 100 "build/pidl/idl.yp"
1878 #line 105 "build/pidl/idl.yp"
1887 #line 112 "build/pidl/idl.yp"
1893 #line 113 "build/pidl/idl.yp"
1894 { push(@
{$_[1]}, $_[3]); $_[1] }
1897 'enum_element', 1, undef
1902 #line 117 "build/pidl/idl.yp"
1903 { "$_[1]$_[2]$_[3]" }
1908 #line 121 "build/pidl/idl.yp"
1915 'bitmap_elements', 1,
1917 #line 128 "build/pidl/idl.yp"
1921 'bitmap_elements', 3,
1923 #line 129 "build/pidl/idl.yp"
1924 { push(@
{$_[1]}, $_[3]); $_[1] }
1927 'bitmap_element', 3,
1929 #line 132 "build/pidl/idl.yp"
1930 { "$_[1] ( $_[3] )" }
1935 #line 136 "build/pidl/idl.yp"
1944 #line 143 "build/pidl/idl.yp"
1951 'union_elements', 1,
1953 #line 150 "build/pidl/idl.yp"
1957 'union_elements', 2,
1959 #line 151 "build/pidl/idl.yp"
1960 { push(@
{$_[1]}, $_[2]); $_[1] }
1965 #line 156 "build/pidl/idl.yp"
1967 "TYPE" => "UNION_ELEMENT",
1975 #line 162 "build/pidl/idl.yp"
1984 #line 167 "build/pidl/idl.yp"
1986 "TYPE" => "UNION_ELEMENT",
1987 "CASE" => "default",
1994 #line 173 "build/pidl/idl.yp"
1997 "CASE" => "default",
2003 #line 180 "build/pidl/idl.yp"
2007 "PROPERTIES" => $_[1],
2008 "POINTERS" => $_[3],
2009 "ARRAY_LEN" => $_[5]
2015 #line 192 "build/pidl/idl.yp"
2021 #line 193 "build/pidl/idl.yp"
2025 'element_list1', 0, undef
2030 #line 200 "build/pidl/idl.yp"
2031 { push(@
{$_[1]}, $_[2]); $_[1] }
2034 'element_list2', 0, undef
2037 'element_list2', 1, undef
2042 #line 206 "build/pidl/idl.yp"
2048 #line 207 "build/pidl/idl.yp"
2049 { push(@
{$_[1]}, $_[3]); $_[1] }
2052 'array_len', 0, undef
2057 #line 212 "build/pidl/idl.yp"
2063 #line 213 "build/pidl/idl.yp"
2067 'property_list', 0, undef
2072 #line 219 "build/pidl/idl.yp"
2073 { util
::FlattenHash
([$_[1],$_[3]]); }
2078 #line 222 "build/pidl/idl.yp"
2084 #line 223 "build/pidl/idl.yp"
2085 { util
::FlattenHash
([$_[1], $_[3]]); }
2090 #line 226 "build/pidl/idl.yp"
2091 {{ "$_[1]" => "1" }}
2096 #line 227 "build/pidl/idl.yp"
2097 {{ "$_[1]" => "$_[3]" }}
2100 'listtext', 1, undef
2105 #line 232 "build/pidl/idl.yp"
2109 'commalisttext', 1, undef
2114 #line 237 "build/pidl/idl.yp"
2120 #line 241 "build/pidl/idl.yp"
2135 #line 243 "build/pidl/idl.yp"
2136 { "$_[1]$_[2]$_[3]" }
2141 #line 244 "build/pidl/idl.yp"
2142 { "$_[1]$_[2]$_[3]" }
2147 #line 245 "build/pidl/idl.yp"
2148 { "$_[1]$_[2]$_[3]" }
2153 #line 246 "build/pidl/idl.yp"
2154 { "$_[1]$_[2]$_[3]" }
2159 #line 247 "build/pidl/idl.yp"
2160 { "$_[1]$_[2]$_[3]" }
2165 #line 248 "build/pidl/idl.yp"
2166 { "$_[1]$_[2]$_[3]" }
2171 #line 249 "build/pidl/idl.yp"
2172 { "$_[1]$_[2]$_[3]" }
2177 #line 250 "build/pidl/idl.yp"
2178 { "$_[1]$_[2]$_[3]" }
2183 #line 251 "build/pidl/idl.yp"
2184 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2189 #line 252 "build/pidl/idl.yp"
2190 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2193 'identifier', 1, undef
2196 'constant', 1, undef
2201 #line 261 "build/pidl/idl.yp"
2205 'optional_semicolon', 0, undef
2208 'optional_semicolon', 1, undef
2212 bless($self,$class);
2215 #line 272 "build/pidl/idl.yp"
2221 if (exists $_[0]->YYData->{ERRMSG
}) {
2222 print $_[0]->YYData->{ERRMSG
};
2223 delete $_[0]->YYData->{ERRMSG
};
2226 my $line = $_[0]->YYData->{LINE
};
2227 my $last_token = $_[0]->YYData->{LAST_TOKEN
};
2228 my $file = $_[0]->YYData->{INPUT_FILENAME
};
2230 print "$file:$line: Syntax error near '$last_token'\n";
2237 $parser->YYData->{INPUT
}
2238 or return('',undef);
2241 $parser->YYData->{INPUT
} =~ s/^[ \t]*//;
2243 for ($parser->YYData->{INPUT
}) {
2245 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
2246 $parser->YYData->{LINE
} = $1-1;
2247 $parser->YYData->{INPUT_FILENAME
} = $2;
2250 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
2251 $parser->YYData->{LINE
} = $1-1;
2252 $parser->YYData->{INPUT_FILENAME
} = $2;
2255 if (s/^(\#.*)$//m) {
2260 $parser->YYData->{LINE
}++;
2263 if (s/^\"(.*?)\"//) {
2264 $parser->YYData->{LAST_TOKEN
} = $1;
2267 if (s/^(\d+)(\W|$)/$2/) {
2268 $parser->YYData->{LAST_TOKEN
} = $1;
2269 return('CONSTANT',$1);
2271 if (s/^([\w_]+)//) {
2272 $parser->YYData->{LAST_TOKEN
} = $1;
2274 /^(coclass
|interface
|const
|typedef
|union
2275 |struct
|enum
|bitmap
|void
|case
|default)$/x
) {
2278 return('IDENTIFIER',$1);
2281 $parser->YYData->{LAST_TOKEN
} = $1;
2290 my $filename = shift;
2292 my $saved_delim = $/;
2294 my $cpp = $ENV{CPP
};
2295 if (! defined $cpp) {
2298 my $data = `$cpp -xc $filename`;
2301 $self->YYData->{INPUT
} = $data;
2302 $self->YYData->{LINE
} = 0;
2303 $self->YYData->{LAST_TOKEN
} = "NONE";
2305 my $idl = $self->YYParse( yylex
=> \
&_Lexer
, yyerror
=> \
&_Error
);
2307 foreach my $x (@
{$idl}) {
2308 # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
2309 # for 'object' interfaces
2310 if (defined($x->{PROPERTIES
}->{object
})) {
2311 foreach my $e (@
{$x->{DATA
}}) {
2312 if($e->{TYPE
} eq "FUNCTION") {
2313 $e->{PROPERTIES
}->{object
} = 1;
2314 unshift(@
{$e->{DATA
}},
2315 { 'NAME' => 'ORPCthis',
2317 'PROPERTIES' => { 'in' => '1' },
2318 'TYPE' => 'ORPCTHIS'
2320 unshift(@
{$e->{DATA
}},
2321 { 'NAME' => 'ORPCthat',
2323 'PROPERTIES' => { 'out' => '1' },
2324 'TYPE' => 'ORPCTHAT'
2330 # Do the inheritance
2331 if (defined($x->{BASE
}) and $x->{BASE
} ne "") {
2332 my $parent = util
::get_interface
($idl, $x->{BASE
});
2334 if(not defined($parent)) {
2335 die("No such parent interface " . $x->{BASE
});
2338 @
{$x->{INHERITED_DATA
}} = (@
{$parent->{INHERITED_DATA
}}, @
{$x->{DATA
}});
2340 $x->{INHERITED_DATA
} = $x->{DATA
};