1234567891011121314151617181920212223242526272829303132333435 |
- #Change the grammar notation by introducing a conversion table file in place.
- open(FH,'<', 'BisonifyConversionTable');
- %NEWEXP = map { / *(.*?) +\|\|\|\| +(.*)/; "$1"=>"$2"; } (<FH>);
- open(FH, '<', 'newjava7.y');
- open(OFH, '>', 'newjava72.y');
- @LIST = (<FH>);
- foreach (@LIST) {
- @LIST2 = ($_);
- $lcurr = $_;
- foreach $K (keys %NEWEXP) {
- $k = $K;
- $k =~ s/([]{}.|[])/\\\1/g;
- while($lcurr =~ /$k/g) {
- $length = @LIST2;
- for ($i=0; $i<$length*2; $i+=2) {
- @LIST2 = (@LIST2[0..$i], @LIST2[$i..@LIST2-1]);
- $LIST2[$i] =~ s/$k//;
- $LIST2[$i+1] =~ s/$k/$NEWEXP{$K}/;
- }
- }
- }
- print OFH (@LIST2);
- }
- foreach $k (keys %NEWEXP){
- print OFH "\n";
- print OFH $NEWEXP{$k} . ":\n";
- $s = $k;
- $s =~ s/\{ *//;
- $s =~ s/ *\}$//;
- print OFH " $s\n";
- print OFH " | $NEWEXP{$k} $s\n";
- print OFH " ;\n";
- }
|