Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Assignment to $[ is no longer supported errors #164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 25 additions & 29 deletions scripts/fa_preproc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ while (0 < 1 + $#ARGV) {

$s = <<'EOF';

$[ = 1; # set array base to 1
$, = ' '; # set output field separator
$\ = "\n"; # set output record separator

Expand All @@ -121,9 +120,9 @@ while (<>) {

@Fld = split(' ', $_, 9999);

if ('_include' eq $Fld[1]) {
if ('_include' eq $Fld[0]) {

$filename = $ENV{'DICTS_ROOT'} . '/' . $Fld[2];
$filename = $ENV{'DICTS_ROOT'} . '/' . $Fld[1];

open INPUT, "< $filename" ;

Expand Down Expand Up @@ -153,7 +152,6 @@ close $fh;

$s = <<'EOF';

$[ = 1; # set array base to 1
$, = ' '; # set output field separator
$\ = "\n"; # set output record separator

Expand All @@ -163,7 +161,7 @@ line: while (<>) {
@Fld = split(' ', $_, 9999);

# skip right parts as-is
if ('{' eq $Fld[1] && 1 == $#Fld) {
if ('{' eq $Fld[0] && 0 == $#Fld) {
while ('}' ne $_) {
print $_;
$_ = &Getline();
Expand All @@ -173,7 +171,7 @@ line: while (<>) {
}

# skip additional code as is
if ('%{' eq $Fld[1] && 1 == $#Fld) {
if ('%{' eq $Fld[0] && 0 == $#Fld) {
while ('%}' ne $_) {
print $_;
$_ = &Getline();
Expand Down Expand Up @@ -216,7 +214,6 @@ close $fh;

$s = <<'EOF';

$[ = 1; # set array base to 1
$FS = ' '; # set field separator
$, = ' '; # set output field separator
$\ = "\n"; # set output record separator
Expand All @@ -227,23 +224,23 @@ line: while (<>) {
@Fld = split($FS, $_, 9999);

# single-line define
if ('_define' eq $Fld[1] && 2 < $#Fld) {
if ('_define' eq $Fld[0] && 1 < $#Fld) {

$val = '';
for ($i = 3; $i < $#Fld; ++$i) {
for ($i = 2; $i < $#Fld; ++$i) {
$val = $val . '' . $Fld[$i] . ' ';
}
$val = $val . '' . $Fld[$#Fld];

&CheckName($Fld[2]);
$defines{$Fld[2]} = $val;
&CheckName($Fld[1]);
$defines{$Fld[1]} = $val;

next line;
}
# multi-lines define
if ('_define' eq $Fld[1] && 2 == $#Fld) {
if ('_define' eq $Fld[0] && 1 == $#Fld) {

$key = $Fld[2];
$key = $Fld[1];
$val = '';
$_ = &Getline();

Expand All @@ -260,7 +257,7 @@ line: while (<>) {
}

# skip right parts as-is
if ('{' eq $Fld[1] && 1 == $#Fld) {
if ('{' eq $Fld[0] && 0 == $#Fld) {
while ('}' ne $_) {
print $_;
$_ = &Getline();
Expand All @@ -269,7 +266,7 @@ line: while (<>) {
next line;
}
# skip additional code as is
if ('%{' eq $Fld[1] && 1 == $#Fld) {
if ('%{' eq $Fld[0] && 0 == $#Fld) {
while ('%}' ne $_) {
print $_;
$_ = &Getline();
Expand All @@ -278,7 +275,7 @@ line: while (<>) {
next line;
}
# skip %lines as is
if ('%' eq substr($Fld[1], 1, 1)) {
if ('%' eq substr($Fld[0], 0, 1)) {
print $_;
next line;
}
Expand All @@ -302,7 +299,7 @@ line: while (<>) {

$name_begin = -1;

for ($i = 1; $i <= $#Fld; ++$i) {
for ($i = 0; $i <= $#Fld; ++$i) {

$c = '' . $Fld[$i];

Expand Down Expand Up @@ -396,7 +393,6 @@ close $fh;

$s = <<'EOF';

$[ = 1; # set array base to 1
$, = ' '; # set output field separator
$\ = "\n"; # set output record separator

Expand All @@ -417,31 +413,31 @@ line: while (<>) {

# get C++ function arguments from the input file
# %ARGS = void * pData, const int RuleId, const int To
if ($Fld[1] eq '%ARGS' && $Fld[2] eq '=') {
if ($Fld[0] eq '%ARGS' && $Fld[1] eq '=') {

$Fld[0] = '';
$Fld[1] = '';
$Fld[2] = '';
$cpp_args = join($,,@Fld);

next line;
}

# %OBJECT = Name
if ($Fld[1] eq '%OBJECT' && $Fld[2] eq '=') {
$cpp_object = $Fld[3];
if ($Fld[0] eq '%OBJECT' && $Fld[1] eq '=') {
$cpp_object = $Fld[2];
next line;
}

# %BASE = Name
if ($Fld[1] eq '%BASE' && $Fld[2] eq '=') {
$cpp_base_class = $Fld[3];
if ($Fld[0] eq '%BASE' && $Fld[1] eq '=') {
$cpp_base_class = $Fld[2];
next line;
}

# %CLASS = Name
if ($Fld[1] eq '%CLASS' && $Fld[2] eq '=') {
if ($Fld[0] eq '%CLASS' && $Fld[1] eq '=') {

$cpp_class = $Fld[3];
$cpp_class = $Fld[2];
$fn_name_pref = $cpp_class . "::";

print CPPOUT "class " . $cpp_class ;
Expand Down Expand Up @@ -471,7 +467,7 @@ PRINT_END
}

# skip additional code as is
if ('%{' eq $Fld[1] && 1 == $#Fld) {
if ('%{' eq $Fld[0] && 0 == $#Fld) {

while ('%}' ne $_) {

Expand All @@ -485,13 +481,13 @@ PRINT_END
}

# print the line into the cpp out as is, but without %
if ('%' eq substr($Fld[1], 1, 1)) {
if ('%' eq substr($Fld[0], 1, 1)) {
print CPPOUT substr($_, 2, 999999) ;
next line ;
}

# print the right part of the rule
if ('{' eq $Fld[1] && 1 == $#Fld) {
if ('{' eq $Fld[0] && 0 == $#Fld) {

# print next C++ function
print CPPOUT 'static void ' . 'fn' . $cpp_fcount . ' (' . $cpp_args . ')' ;
Expand Down