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',
572 'base_interface' => 16
668 'property_list' => 41
753 'commalisttext' => 52
828 'property_list' => 59
846 'property_list' => 41
863 'property_list' => 59
982 'optional_semicolon' => 75
1038 'enum_element' => 82,
1039 'enum_elements' => 83
1114 'union_elements' => 93,
1115 'union_element' => 94
1121 'element_list1' => 96
1152 'base_element' => 100,
1153 'element_list2' => 103,
1154 'property_list' => 101
1194 'enum_element' => 106
1203 'union_element' => 108
1221 'base_element' => 112,
1222 'property_list' => 101
1262 'property_list' => 59
1341 'base_element' => 122,
1342 'property_list' => 101
1373 'base_element' => 126,
1374 'property_list' => 101
1446 'base_element' => 134,
1447 'property_list' => 101
1473 #line 19 "build/pidl/idl.yp"
1475 push(@{$_[1]}, $_[2]); $_[1]
1481 #line 25 "build/pidl/idl.yp"
1483 "TYPE" => "INTERFACE",
1484 "PROPERTIES" => $_[1],
1491 'base_interface', 0, undef
1494 'base_interface', 2,
1496 #line 36 "build/pidl/idl.yp"
1502 #line 40 "build/pidl/idl.yp"
1508 #line 41 "build/pidl/idl.yp"
1509 { push(@{$_[1]}, $_[2]); $_[1] }
1512 'definition', 1, undef
1515 'definition', 1, undef
1518 'definition', 1, undef
1523 #line 49 "build/pidl/idl.yp"
1534 #line 59 "build/pidl/idl.yp"
1536 "TYPE" => "FUNCTION",
1538 "RETURN_TYPE" => $_[2],
1539 "PROPERTIES" => $_[1],
1546 #line 69 "build/pidl/idl.yp"
1548 "TYPE" => "TYPEDEF",
1551 "ARRAY_LEN" => $_[4]
1569 #line 78 "build/pidl/idl.yp"
1575 #line 83 "build/pidl/idl.yp"
1584 #line 90 "build/pidl/idl.yp"
1590 #line 91 "build/pidl/idl.yp"
1591 { push(@{$_[1]}, $_[3]); $_[1] }
1594 'enum_element', 1, undef
1599 #line 95 "build/pidl/idl.yp"
1600 { "$_[1]$_[2]$_[3]" }
1605 #line 99 "build/pidl/idl.yp"
1608 "PROPERTIES" => $_[1],
1615 #line 107 "build/pidl/idl.yp"
1618 "PROPERTIES" => $_[1],
1623 'union_elements', 1,
1625 #line 115 "build/pidl/idl.yp"
1629 'union_elements', 2,
1631 #line 116 "build/pidl/idl.yp"
1632 { push(@{$_[1]}, $_[2]); $_[1] }
1637 #line 121 "build/pidl/idl.yp"
1639 "TYPE" => "UNION_ELEMENT",
1647 #line 127 "build/pidl/idl.yp"
1656 #line 132 "build/pidl/idl.yp"
1658 "TYPE" => "UNION_ELEMENT",
1659 "CASE" => "default",
1666 #line 138 "build/pidl/idl.yp"
1669 "CASE" => "default",
1675 #line 145 "build/pidl/idl.yp"
1679 "PROPERTIES" => $_[1],
1680 "POINTERS" => $_[3],
1681 "ARRAY_LEN" => $_[5]
1687 #line 157 "build/pidl/idl.yp"
1693 #line 158 "build/pidl/idl.yp"
1697 'element_list1', 0, undef
1702 #line 165 "build/pidl/idl.yp"
1703 { push(@{$_[1]}, $_[2]); $_[1] }
1706 'element_list2', 0, undef
1709 'element_list2', 1, undef
1714 #line 171 "build/pidl/idl.yp"
1720 #line 172 "build/pidl/idl.yp"
1721 { push(@{$_[1]}, $_[3]); $_[1] }
1724 'array_len', 0, undef
1729 #line 177 "build/pidl/idl.yp"
1735 #line 178 "build/pidl/idl.yp"
1739 'property_list', 0, undef
1744 #line 184 "build/pidl/idl.yp"
1745 { util::FlattenHash([$_[1],$_[3]]); }
1750 #line 187 "build/pidl/idl.yp"
1756 #line 188 "build/pidl/idl.yp"
1757 { util::FlattenHash([$_[1], $_[3]]); }
1762 #line 191 "build/pidl/idl.yp"
1763 {{ "$_[1]" => "1" }}
1768 #line 192 "build/pidl/idl.yp"
1769 {{ "$_[1]" => "$_[3]" }}
1772 'listtext', 1, undef
1777 #line 197 "build/pidl/idl.yp"
1781 'commalisttext', 1, undef
1786 #line 202 "build/pidl/idl.yp"
1792 #line 206 "build/pidl/idl.yp"
1807 #line 208 "build/pidl/idl.yp"
1808 { "$_[1]$_[2]$_[3]" }
1813 #line 209 "build/pidl/idl.yp"
1814 { "$_[1]$_[2]$_[3]" }
1819 #line 210 "build/pidl/idl.yp"
1820 { "$_[1]$_[2]$_[3]" }
1825 #line 211 "build/pidl/idl.yp"
1826 { "$_[1]$_[2]$_[3]" }
1831 #line 212 "build/pidl/idl.yp"
1832 { "$_[1]$_[2]$_[3]" }
1837 #line 213 "build/pidl/idl.yp"
1838 { "$_[1]$_[2]$_[3]" }
1843 #line 214 "build/pidl/idl.yp"
1844 { "$_[1]$_[2]$_[3]" }
1849 #line 215 "build/pidl/idl.yp"
1850 { "$_[1]$_[2]$_[3]" }
1855 #line 216 "build/pidl/idl.yp"
1856 { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
1859 'identifier', 1, undef
1862 'constant', 1, undef
1867 #line 225 "build/pidl/idl.yp"
1871 'optional_semicolon', 0, undef
1874 'optional_semicolon', 1, undef
1878 bless($self,$class);
1881 #line 236 "build/pidl/idl.yp"
1887 if (exists $_[0]->YYData->{ERRMSG}) {
1888 print $_[0]->YYData->{ERRMSG};
1889 delete $_[0]->YYData->{ERRMSG};
1892 my $line = $_[0]->YYData->{LINE};
1893 my $last_token = $_[0]->YYData->{LAST_TOKEN};
1894 my $file = $_[0]->YYData->{INPUT_FILENAME};
1896 print "$file:$line: Syntax error near '$last_token'\n";
1903 $parser->YYData->{INPUT}
1904 or return('',undef);
1907 $parser->YYData->{INPUT} =~ s/^[ \t]*//;
1909 for ($parser->YYData->{INPUT}) {
1911 if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
1912 $parser->YYData->{LINE} = $1-1;
1913 $parser->YYData->{INPUT_FILENAME} = $2;
1916 if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
1917 $parser->YYData->{LINE} = $1-1;
1918 $parser->YYData->{INPUT_FILENAME} = $2;
1921 if (s/^(\#.*)$//m) {
1926 $parser->YYData->{LINE}++;
1929 if (s/^\"(.*?)\"//) {
1930 $parser->YYData->{LAST_TOKEN} = $1;
1933 if (s/^(\d+)(\W|$)/$2/) {
1934 $parser->YYData->{LAST_TOKEN} = $1;
1935 return('CONSTANT',$1);
1937 if (s/^([\w_]+)//) {
1938 $parser->YYData->{LAST_TOKEN} = $1;
1940 /^(interface|const|typedef|union
1941 |struct|enum|void|case|default)$/x) {
1944 return('IDENTIFIER',$1);
1947 $parser->YYData->{LAST_TOKEN} = $1;
1956 my $filename = shift;
1958 my $saved_delim = $/;
1960 my $cpp = $ENV{CPP};
1961 if (! defined $cpp) {
1964 my $data = `$cpp -xc $filename`;
1967 $self->YYData->{INPUT} = $data;
1968 $self->YYData->{LINE} = 0;
1969 $self->YYData->{LAST_TOKEN} = "NONE";
1971 my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
1973 foreach my $x (@{$idl}) {
1974 # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
1975 # for 'object' interfaces
1976 if (defined($x->{PROPERTIES}->{object})) {
1977 foreach my $e (@{$x->{DATA}}) {
1978 if($e->{TYPE} eq "FUNCTION") {
1979 unshift(@{$e->{DATA}},
1980 { 'NAME' => 'ORPCthis',
1982 'PROPERTIES' => { 'in' => '1' },
1983 'TYPE' => 'ORPCTHIS'
1985 unshift(@{$e->{DATA}},
1986 { 'NAME' => 'ORPCthat',
1988 'PROPERTIES' => { 'out' => '1' },
1989 'TYPE' => 'ORPCTHAT'
1995 # Do the inheritance
1996 if (defined($x->{BASE}) and $x->{BASE} ne "") {
1997 my $parent = util::get_interface($idl, $x->{BASE});
1999 if(not defined($parent)) {
2000 die("No such parent interface " . $x->{BASE});
2003 @{$x->{INHERITED_DATA}} = (@{$parent->{INHERITED_DATA}}, @{$x->{DATA}});
2005 $x->{INHERITED_DATA} = $x->{DATA};