X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser.pm;h=f720e616945fc409d49ca723a2f04f40fa0de4b4;hb=711e98e05d847d52ff915cdacd43693035411ac3;hp=29e7a2d056e80e70ebc74f5782f4e5fb26bdde93;hpb=16dc997057306c2b93d146478b7b20830d3b5d80;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser.pm b/lib/SQL/Translator/Parser.pm index 29e7a2d..f720e61 100644 --- a/lib/SQL/Translator/Parser.pm +++ b/lib/SQL/Translator/Parser.pm @@ -1,66 +1,72 @@ package SQL::Translator::Parser; -#----------------------------------------------------- -# $Id: Parser.pm,v 1.1.1.1 2002-03-01 02:26:25 kycl4rk Exp $ +# ---------------------------------------------------------------------- +# $Id: Parser.pm,v 1.9 2004-02-09 23:04:26 kycl4rk Exp $ +# ---------------------------------------------------------------------- +# Copyright (C) 2002-4 SQLFairy Authors # -# File : SQL/Translator/Parser.pm -# Programmer : Ken Y. Clark, kclark@logsoft.com -# Created : 2002/02/27 -# Purpose : base object for parsers -#----------------------------------------------------- +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA +# ---------------------------------------------------------------------- use strict; use vars qw( $VERSION ); -$VERSION = (qw$Revision: 1.1.1.1 $)[-1]; - -use Parse::RecDescent; -use SQL::Translator; -use base qw[ SQL::Translator ]; +$VERSION = sprintf "%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/; -sub parse { -# -# Override this method if you intend not to use Parse::RecDescent -# - my $self = shift; - return $self->parser->file( shift() ); -} - -sub parser { - my $self = shift; - unless ( $self->{'parser'} ) { - $self->{'parser'} = Parse::RecDescent->new( $self->grammar ); - } - return $self->{'parser'}; -} +sub parse { "" } 1; -#----------------------------------------------------- +# ---------------------------------------------------------------------- # Enough! or Too much. # William Blake -#----------------------------------------------------- +# ---------------------------------------------------------------------- + +=pod =head1 NAME -SQL::Translator::Parser - base object for parsers +SQL::Translator::Parser - describes how to write a parser + +=head1 DESCRIPTION -=head1 SYNOPSIS +Parser modules that get invoked by SQL::Translator need to implement a +single function: B. This function will be called by the +SQL::Translator instance as $class::parse($tr, $data_as_string), where +$tr is a SQL::Translator instance. Other than that, the classes are +free to define any helper functions, or use any design pattern +internally that make the most sense. - package SQL::Translator::Parser::Foo; - use SQL::Translator::Parser; - use base( 'SQL::Translator::Parser' ); - 1; +When the parser has determined what exists, it will communicate the +structure to the producer through the SQL::Translator::Schema object. +This object can be retrieved from the translator (the first argument +pass to B) by calling the B method: -=head1 DESCRIPTION + my $schema = $tr->schema; -Blah blah blah. +The Schema object has methods for adding tables, fields, indices, etc. +For more information, consult the docs for SQL::Translator::Schema and +its related modules. For examples of how this works, examine the +source code for existing SQL::Translator::Parser::* modules. -=head1 AUTHOR +=head1 AUTHORS -Ken Y. Clark, kclark@logsoft.com +Ken Y. Clark, Ekclark@cpan.org, +darren chamberlain Edarren@cpan.orgE. =head1 SEE ALSO -perl(1). +perl(1), SQL::Translator, SQL::Translator::Schema. =cut