X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FOracle.pm;h=4da09fb9b492e711de6eb8a899313bddeb43d4f9;hb=ac7adbab6451299d70b5ecc59c6bb7f8a6f9473b;hp=9bcc35c877b76c87e2a0d2f077fd7fc28b747e48;hpb=0c04c5a2210135419771878dc7e341a1cba52cca;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser/Oracle.pm b/lib/SQL/Translator/Parser/Oracle.pm index 9bcc35c..4da09fb 100644 --- a/lib/SQL/Translator/Parser/Oracle.pm +++ b/lib/SQL/Translator/Parser/Oracle.pm @@ -77,23 +77,19 @@ was altered to better handle the syntax created by DDL::Oracle. use strict; use warnings; -our ( $DEBUG, $GRAMMAR, @EXPORT_OK ); + our $VERSION = '1.59'; + +our $DEBUG; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; -use Parse::RecDescent; -use Exporter; -use base qw(Exporter); - -@EXPORT_OK = qw(parse); +use SQL::Translator::Utils qw/ddl_parser_instance/; -# Enable warnings within the Parse::RecDescent module. -$::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error -$::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c. -$::RD_HINT = 1; # Give out hints to help fix problems. +use base qw(Exporter); +our @EXPORT_OK = qw(parse); -$GRAMMAR = q` +our $GRAMMAR = <<'END_OF_GRAMMAR'; { my ( %tables, %indices, %constraints, $table_order, @table_comments, %views, $view_order, %procedures, $proc_order ) } @@ -592,19 +588,20 @@ VALUE : /[-+]?\.?\d+(?:[eE]\d+)?/ | /NULL/ { 'NULL' } -`; +END_OF_GRAMMAR sub parse { my ( $translator, $data ) = @_; - my $parser = Parse::RecDescent->new($GRAMMAR); - local $::RD_TRACE = $translator->trace ? 1 : undef; - local $DEBUG = $translator->debug; + # Enable warnings within the Parse::RecDescent module. + local $::RD_ERRORS = 1 unless defined $::RD_ERRORS; # Make sure the parser dies when it encounters an error + local $::RD_WARN = 1 unless defined $::RD_WARN; # Enable warnings. This will warn on unused rules &c. + local $::RD_HINT = 1 unless defined $::RD_HINT; # Give out hints to help fix problems. - unless (defined $parser) { - return $translator->error("Error instantiating Parse::RecDescent ". - "instance: Bad grammer"); - } + local $::RD_TRACE = $translator->trace ? 1 : undef; + local $DEBUG = $translator->debug; + + my $parser = ddl_parser_instance('Oracle'); my $result = $parser->startrule( $data ); die "Parse failed.\n" unless defined $result;