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
702 'property_list' => 49
711 'optional_semicolon' => 54
805 'commalisttext' => 62
880 'property_list' => 69
898 'property_list' => 49
915 'property_list' => 69
1040 'optional_semicolon' => 85
1096 'enum_element' => 91,
1097 'enum_elements' => 92
1169 'union_elements' => 102,
1170 'union_element' => 103
1176 'element_list1' => 105
1207 'base_element' => 109,
1208 'element_list2' => 112,
1209 'property_list' => 110
1249 'enum_element' => 115
1258 'union_element' => 117
1276 'base_element' => 121,
1277 'property_list' => 110
1317 'property_list' => 69
1396 'base_element' => 131,
1397 'property_list' => 110
1428 'base_element' => 135,
1429 'property_list' => 110
1501 'base_element' => 143,
1502 'property_list' => 110
1528 #line 19 "build/pidl/idl.yp"
1529 { push(@{$_[1]}, $_[2]); $_[1] }
1534 #line 20 "build/pidl/idl.yp"
1535 { push(@{$_[1]}, $_[2]); $_[1] }
1540 #line 24 "build/pidl/idl.yp"
1542 "TYPE" => "COCLASS",
1543 "PROPERTIES" => $_[1],
1549 'interfaces', 0, undef
1554 #line 34 "build/pidl/idl.yp"
1555 { push(@{$_[1]}, $_[2]); $_[1] }
1560 #line 38 "build/pidl/idl.yp"
1562 "TYPE" => "INTERFACE",
1563 "PROPERTIES" => $_[1],
1570 'base_interface', 0, undef
1573 'base_interface', 2,
1575 #line 49 "build/pidl/idl.yp"
1581 #line 53 "build/pidl/idl.yp"
1587 #line 54 "build/pidl/idl.yp"
1588 { push(@{$_[1]}, $_[2]); $_[1] }
1591 'definition', 1, undef
1594 'definition', 1, undef
1597 'definition', 1, undef
1602 #line 62 "build/pidl/idl.yp"
1613 #line 72 "build/pidl/idl.yp"
1615 "TYPE" => "FUNCTION",
1617 "RETURN_TYPE" => $_[2],
1618 "PROPERTIES" => $_[1],
1625 #line 82 "build/pidl/idl.yp"
1627 "TYPE" => "TYPEDEF",
1630 "ARRAY_LEN" => $_[4]
1648 #line 91 "build/pidl/idl.yp"
1654 #line 96 "build/pidl/idl.yp"
1663 #line 103 "build/pidl/idl.yp"
1669 #line 104 "build/pidl/idl.yp"
1670 { push(@{$_[1]}, $_[3]); $_[1] }
1673 'enum_element', 1, undef
1678 #line 108 "build/pidl/idl.yp"
1679 { "$_[1]$_[2]$_[3]" }
1684 #line 112 "build/pidl/idl.yp"
1687 "PROPERTIES" => $_[1],
1694 #line 120 "build/pidl/idl.yp"
1697 "PROPERTIES" => $_[1],
1702 'union_elements', 1,
1704 #line 128 "build/pidl/idl.yp"
1708 'union_elements', 2,
1710 #line 129 "build/pidl/idl.yp"
1711 { push(@{$_[1]}, $_[2]); $_[1] }
1716 #line 134 "build/pidl/idl.yp"
1718 "TYPE" => "UNION_ELEMENT",
1726 #line 140 "build/pidl/idl.yp"
1735 #line 145 "build/pidl/idl.yp"
1737 "TYPE" => "UNION_ELEMENT",
1738 "CASE" => "default",
1745 #line 151 "build/pidl/idl.yp"
1748 "CASE" => "default",
1754 #line 158 "build/pidl/idl.yp"
1758 "PROPERTIES" => $_[1],
1759 "POINTERS" => $_[3],
1760 "ARRAY_LEN" => $_[5]
1766 #line 170 "build/pidl/idl.yp"
1772 #line 171 "build/pidl/idl.yp"
1776 'element_list1', 0, undef
1781 #line 178 "build/pidl/idl.yp"
1782 { push(@{$_[1]}, $_[2]); $_[1] }
1785 'element_list2', 0, undef
1788 'element_list2', 1, undef
1793 #line 184 "build/pidl/idl.yp"
1799 #line 185 "build/pidl/idl.yp"
1800 { push(@{$_[1]}, $_[3]); $_[1] }
1803 'array_len', 0, undef
1808 #line 190 "build/pidl/idl.yp"
1814 #line 191 "build/pidl/idl.yp"
1818 'property_list', 0, undef
1823 #line 197 "build/pidl/idl.yp"
1824 { util::FlattenHash([$_[1],$_[3]]); }
1829 #line 200 "build/pidl/idl.yp"
1835 #line 201 "build/pidl/idl.yp"
1836 { util::FlattenHash([$_[1], $_[3]]); }
1841 #line 204 "build/pidl/idl.yp"
1842 {{ "$_[1]" => "1" }}
1847 #line 205 "build/pidl/idl.yp"
1848 {{ "$_[1]" => "$_[3]" }}
1851 'listtext', 1, undef
1856 #line 210 "build/pidl/idl.yp"
1860 'commalisttext', 1, undef
1865 #line 215 "build/pidl/idl.yp"
1871 #line 219 "build/pidl/idl.yp"
1886 #line 221 "build/pidl/idl.yp"
1887 { "$_[1]$_[2]$_[3]" }
1892 #line 222 "build/pidl/idl.yp"
1893 { "$_[1]$_[2]$_[3]" }
1898 #line 223 "build/pidl/idl.yp"
1899 { "$_[1]$_[2]$_[3]" }
1904 #line 224 "build/pidl/idl.yp"
1905 { "$_[1]$_[2]$_[3]" }
1910 #line 225 "build/pidl/idl.yp"
1911 { "$_[1]$_[2]$_[3]" }
1916 #line 226 "build/pidl/idl.yp"
1917 { "$_[1]$_[2]$_[3]" }
1922 #line 227 "build/pidl/idl.yp"
1923 { "$_[1]$_[2]$_[3]" }
1928 #line 228 "build/pidl/idl.yp"
1929 { "$_[1]$_[2]$_[3]" }
1934 #line 229 "build/pidl/idl.yp"
1935 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
1938 'identifier', 1, undef
1941 'constant', 1, undef
1946 #line 238 "build/pidl/idl.yp"
1950 'optional_semicolon', 0, undef
1953 'optional_semicolon', 1, undef
1957 bless($self,$class);
1960 #line 249 "build/pidl/idl.yp"
1966 if (exists $_[0]->YYData->{ERRMSG}) {
1967 print $_[0]->YYData->{ERRMSG};
1968 delete $_[0]->YYData->{ERRMSG};
1971 my $line = $_[0]->YYData->{LINE};
1972 my $last_token = $_[0]->YYData->{LAST_TOKEN};
1973 my $file = $_[0]->YYData->{INPUT_FILENAME};
1975 print "$file:$line: Syntax error near '$last_token'\n";
1982 $parser->YYData->{INPUT}
1983 or return('',undef);
1986 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
1988 for ($parser->YYData->{INPUT}) {
1990 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
1991 $parser->YYData->{LINE} = $1-1;
1992 $parser->YYData->{INPUT_FILENAME} = $2;
1995 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
1996 $parser->YYData->{LINE} = $1-1;
1997 $parser->YYData->{INPUT_FILENAME} = $2;
2000 if (s/^(\#.*)$//m) {
2005 $parser->YYData->{LINE}++;
2008 if (s/^\"(.*?)\"//) {
2009 $parser->YYData->{LAST_TOKEN} = $1;
2012 if (s/^(\d+)(\W|$)/$2/) {
2013 $parser->YYData->{LAST_TOKEN} = $1;
2014 return('CONSTANT',$1);
2016 if (s/^([\w_]+)//) {
2017 $parser->YYData->{LAST_TOKEN} = $1;
2019 /^(coclass|interface|const|typedef|union
2020 |struct|enum|void|case|default)$/x) {
2023 return('IDENTIFIER',$1);
2026 $parser->YYData->{LAST_TOKEN} = $1;
2035 my $filename = shift;
2037 my $saved_delim = $/;
2039 my $cpp = $ENV{CPP};
2040 if (! defined $cpp) {
2043 my $data = `$cpp -xc $filename`;
2046 $self->YYData->{INPUT} = $data;
2047 $self->YYData->{LINE} = 0;
2048 $self->YYData->{LAST_TOKEN} = "NONE";
2050 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2052 foreach my $x (@{$idl}) {
2053 # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
2054 # for 'object' interfaces
2055 if (defined($x->{PROPERTIES}->{object})) {
2056 foreach my $e (@{$x->{DATA}}) {
2057 if($e->{TYPE} eq "FUNCTION") {
2058 $e->{PROPERTIES}->{object} = 1;
2059 unshift(@{$e->{DATA}},
2060 { 'NAME' => 'ORPCthis',
2062 'PROPERTIES' => { 'in' => '1' },
2063 'TYPE' => 'ORPCTHIS'
2065 unshift(@{$e->{DATA}},
2066 { 'NAME' => 'ORPCthat',
2068 'PROPERTIES' => { 'out' => '1' },
2069 'TYPE' => 'ORPCTHAT'
2075 # Do the inheritance
2076 if (defined($x->{BASE}) and $x->{BASE} ne "") {
2077 my $parent = util::get_interface($idl, $x->{BASE});
2079 if(not defined($parent)) {
2080 die("No such parent interface " . $x->{BASE});
2083 @{$x->{INHERITED_DATA}} = (@{$parent->{INHERITED_DATA}}, @{$x->{DATA}});
2085 $x->{INHERITED_DATA} = $x->{DATA};