TSQL::AST - 'Abstract Syntax Tree' for TSQL.
Version 0.04
Parses Microsoft's Transact SQL dialect of SQL.
This only provides a very 'broad brush' parse of TSQL. It aims to be accurate in what it does parse, but not to provide any great detail. Currently it recursively recognises the major block structure elements of TSQL.
This is still *ALPHA* quality software. It should still be a developer-only release, but I'm getting tired of those. If you've come looking for a full-blown TSQL parser, you're going to leave here very disappointed. Even when finished, this is going to leave most of your SQL unparsed. It's intended to support another piece of work, which is currently only in the planning stage, and will have its development driven from those requirements as they materialise.
Note TSQL::AST is only intended to parse syntactically valid TSQL.
TSQL::AST depends on the following modules:
TSQL::SplitStatement
TSQL::Common::Regexp
Data::Dumper
List::MoreUtils
List::Util
MooseX::Declare
autodie
indirect
version
Ded MedVed, <dedmedved at cpan.org>
<dedmedved at cpan.org>
Please report any bugs or feature requests to bug-tsql-ast at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=TSQL::AST. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-tsql-ast at rt.cpan.org
new
TSQL::AST->new()
It creates and returns a new TSQL::AST object.
parse
$ast->parse( array of sqlfragments )
This is the method which parses the split up SQL code from the original script.
my $sql_splitter = TSQL::SplitStatement->new(); my @statements = $sql_splitter->splitSQL( 'SELECT 1;SELECT 2;' ); my $sql_parser = TSQL::AST->new(); my $ast = $sql_parser->parse( \@statements );
script
$ast->script()
This is the method which retrieves the AST for the script just parsed.
my $sql_splitter = TSQL::SplitStatement->new(); my @statements = $sql_splitter->splitSQL( 'SELECT 1;SELECT 2;' ); my $sql_parser = TSQL::AST->new(); my $ast = $sql_parser->parse( \@statements ); my $script = $ast->script();
No limitations are currently known, as far as the intended usage is concerned. You *are* bound to uncover a large number of problems.
Please report any problematic cases.
You can find documentation for this module with the perldoc command.
perldoc TSQL::AST
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=TSQL::AST
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/TSQL::AST
CPAN Ratings
http://cpanratings.perl.org/d/TSQL::AST
Search CPAN
http://search.cpan.org/dist/TSQL::AST/
None yet.
Copyright 2012 Ded MedVed.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install TSQL::AST::Factory, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TSQL::AST::Factory
CPAN shell
perl -MCPAN -e shell install TSQL::AST::Factory
For more information on module installation, please visit the detailed CPAN module installation guide.