Skip to content

Commit

Permalink
bc: symbol table correction (#582)
Browse files Browse the repository at this point in the history
* Entries in sym_table hash need to have type & value
* When investigating a warning for "eq on undefined value" on L2400 I noticed the sym_table entry needs a type of "var" (this code handles auto-assignment of zero to variables)
* The hint came from further down in the code, where array values are initialised to zero (virtual 'p' instruction)
* Also remove the C preprocessor declaration of YYBYACC which was not referenced anywhere
  • Loading branch information
mknos committed Apr 28, 2024
1 parent 90d33db commit e6a3b34
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions bin/bc
Expand Up @@ -800,8 +800,6 @@ repository:
=cut

#define YYBYACC 1

use strict;

# The symbol table : the keys are the identifiers, the value is in the
Expand Down Expand Up @@ -2398,6 +2396,7 @@ sub exec_stmt
unless (defined($sym_table{$name})
and $sym_table{$name}{'type'} eq 'var') {
$sym_table{$name}{'value'} = 0;
$sym_table{$name}{'type'} = 'var';
}
push(@ope_stack, $sym_table{$name}{'value'});
next INSTR;
Expand Down

0 comments on commit e6a3b34

Please sign in to comment.