package SQL::Translator;
# ----------------------------------------------------------------------
-# $Id: Translator.pm,v 1.25 2003-05-06 12:44:54 dlc Exp $
+# $Id: Translator.pm,v 1.26 2003-05-09 16:51:47 kycl4rk Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
# darren chamberlain <darren@cpan.org>,
use base 'Class::Base';
$VERSION = '0.01';
-$REVISION = sprintf "%d.%02d", q$Revision: 1.25 $ =~ /(\d+)\.(\d+)/;
+$REVISION = sprintf "%d.%02d", q$Revision: 1.26 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
$ERROR = "";
use File::Spec::Functions qw(catfile);
use File::Basename qw(dirname);
use IO::Dir;
+use SQL::Translator::Schema;
# ----------------------------------------------------------------------
# The default behavior is to "pass through" values (note that the
return $self->{'data'};
}
+# ----------------------------------------------------------------------
+sub schema {
+#
+# Returns the SQL::Translator::Schema object
+#
+ my $self = shift;
+
+ unless ( defined $self->{'schema'} ) {
+ $self->{'schema'} = SQL::Translator::Schema->new;
+ }
+ return $self->{'schema'};
+}
+
+# ----------------------------------------------------------------------
sub trace {
my $self = shift;
my $arg = shift;
# the future, each of these might happen in a Safe environment,
# depending on how paranoid we want to be.
# ----------------------------------------------------------------
- eval { $parser_output = $parser->($self, $$data) };
+ my $schema = $self->schema;
+ eval { $parser_output = $parser->($self, $$data, $schema) };
if ($@ || ! $parser_output) {
my $msg = sprintf "translate: Error with parser '%s': %s",
$parser_type, ($@) ? $@ : " no results";
return $self->error($msg);
}
- eval { $producer_output = $producer->($self, $parser_output) };
+ eval { $producer_output = $producer->($self, $parser_output, $schema) };
if ($@ || ! $producer_output) {
my $msg = sprintf "translate: Error with producer '%s': %s",
$producer_type, ($@) ? $@ : " no results";
=pod
+=head2 schema
+
+Returns the SQL::Translator::Schema object.
+
=head2 trace
Turns on/off the tracing option of Parse::RecDescent.