#
# Reduction rules for bool.pl
# Perl source code automatically generated at Thu Apr 16 19:16:10 1998 by
# py v.0.1 25 Aug 1995
# Source code copyright 1995 M-J. Dominus (mjd@pobox.com)
#

# rule 1
# bool -> '(' bool ')'
sub rule_1 {
  return $_[1];
}

# rule 2
# bool -> bool '|' bool
sub rule_2 {
  return $_[0] || $_[2];
}

# rule 3
# bool -> bool '^' bool
sub rule_3 {
  return $_[0] ^ $_[2];
}

# rule 4
# bool -> bool '&' bool
sub rule_4 {
  return $_[0] && $_[2];
}

# rule 5
# bool -> ATOM
sub rule_5 {
  return atomvalue($_[0]);
}

# rule 6
# bool -> CONSTANT
sub rule_6 {
  return $_[0];
}



# The lexer converts sequences of characters into 
# tokens.  A token may have a value, which is stored
# in the variable $yylval.  The return value from yylex
# says what the type of token is.
{
  my @tokens = ();

  sub yylex {
    my $token;
    until ($token =~ /\S/) {
      $token = shift @tokens;
      return End_of_Input unless defined $token;
    }

    if ($token =~ /^[TFtf10]$/ ) {
      $yylval = ($token =~ /^[Tt1]$/);
      return CONSTANT;
    } elsif ($token =~ /^[()&|^]$/) {
      return $token;
    } elsif ($token =~ /[^A-Za-z_]/) {
      warn "Bad token `$token' in input; aborting parse.\n";
      @tokens = ();
      return End_of_Input;
    } else {
      $yylval = $token;
      return ATOM;
    }
  }

  sub set_input {
    my $instr = join '', @_;
    $instr =~ tr/\n/ /;
    @tokens = split(/\b|(?=\W)/, $instr);
    local $" = '][';
#    print STDERR "TOKENS: [@tokens]\n";
  }
}


1;
