403Webshell
Server IP : 103.119.228.120  /  Your IP : 3.12.34.192
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /usr/local/share/perl5/DBIx/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/local/share/perl5/DBIx/MyParsePP.pm
package DBIx::MyParsePP;
use strict;

use DBIx::MyParsePP::Lexer;
use DBIx::MyParsePP::Parser;
use DBIx::MyParsePP::Query;


our $VERSION = '0.50';

use constant MYPARSEPP_YAPP			=> 0;
use constant MYPARSEPP_CHARSET			=> 1;
use constant MYPARSEPP_VERSION			=> 2;
use constant MYPARSEPP_SQL_MODE			=> 3;
use constant MYPARSEPP_CLIENT_CAPABILITIES	=> 4;
use constant MYPARSEPP_STMT_PREPARE_MODE	=> 5;

my %args = (
	charset		=> MYPARSEPP_CHARSET,
	version		=> MYPARSEPP_VERSION,
	sql_mode	=> MYPARSEPP_SQL_MODE,
	client_capabilities	=> MYPARSEPP_CLIENT_CAPABILITIES,
	stmt_prepare_mode	=> MYPARSEPP_STMT_PREPARE_MODE
);

1;

sub new {
	my $class = shift;
	my $parser = bless ([], $class );

        my $max_arg = (scalar(@_) / 2) - 1;

        foreach my $i (0..$max_arg) {
                if (exists $args{$_[$i * 2]}) {
                        $parser->[$args{$_[$i * 2]}] = $_[$i * 2 + 1];
                } else {
                        warn("Unkown argument '$_[$i * 2]' to DBIx::MyParsePP->new()");
                }
        }

	my $yapp = DBIx::MyParsePP::Parser->new();
	$parser->[MYPARSEPP_YAPP] = $yapp;
	return $parser;
}

sub parse {
	my ($parser, $string) = @_;

	my $lexer = DBIx::MyParsePP::Lexer->new(
		string => $string,
		charset => $parser->[MYPARSEPP_CHARSET],
		version	 => $parser->[MYPARSEPP_VERSION],
		sql_mode => $parser->[MYPARSEPP_SQL_MODE],
		client_capabilities => $parser->[MYPARSEPP_CLIENT_CAPABILITIES],
		stmt_prepare_mode => $parser->[MYPARSEPP_CLIENT_CAPABILITIES]
	);
		
	my $query = DBIx::MyParsePP::Query->new(
		lexer => $lexer
	);

	my $yapp = $parser->[MYPARSEPP_YAPP];
	my $result = $yapp->YYParse( yylex => sub { $lexer->yylex() }, yyerror => sub { $parser->error(@_, $query) } );

	if (defined $result) {
		$query->setRoot($result->[0]);
	}

	return $query;
}

sub error {
	my ($parser, $yapp, $query) = @_;
	$query->setActual($yapp->YYCurval);
	$query->setExpected($yapp->YYExpect);
}

1;

__END__

=head1 NAME

DBIx::MyParsePP - Pure-perl SQL parser based on MySQL grammar and lexer

=head1 SYNOPSIS

  use DBIx::MyParsePP;
  use Data::Dumper;

  my $parser = DBIx::MyParsePP->new();

  my $query = $parser->parse("SELECT 1");

  print Dumper $query;
  print $query->toString();

=head1 DESCRIPTION

C<DBIx::MyParsePP> is a pure-perl SQL parser that implements the MySQL grammar and lexer.
The grammar was automatically converted from the original C<sql_yacc.yy> file by removing all
the C code. The lexer comes from C<sql_lex.cc>, completely translated in Perl almost verbatim.

The grammar is converted into Perl form using L<Parse::Yapp>.

=head1 CONSTRUCTOR

C<charset>, C<version>, C<sql_mode>, C<client_capabilities> and C<stmt_prepare_mode> can be passed
as arguments to the constructor. Please C<use DBIx::MyParsePP::Lexer> to bring in the required constants
and see L<DBIx::MyParsePP::Lexer> for information.

=head1 METHODS

C<DBIx::MyParsePP> provides C<parse()> which takes the string to be parsed.
The result is a L<DBIx::MyParsePP::Query> object which contains the result from the parsing.

Queries can be reconstructed back into SQL by calling the C<toString()> method.

=head1 SPECIAL CONSIDERATIONS

The file containing the grammar C<lib/DBIx/MyParsePP/Parser.pm> is about 5 megabytes in size
and takes a while to load. Compex statements take a while to parse, e.g. the first Twins query
from the MySQL manual can only be parsed at a speed of few queries per second per 1GHz of CPU. If
you require a full-speed parsing solution, please take a look at L<DBIx::MyParse>, which requires
a GCC compiler and produces more concise parse trees.

The parse trees produced by C<DBIx::MyParsePP> contain one leaf for every grammar rule that has been
matched, even rules that serve no useful purpose. Therefore, parsing event simple statements such
as C<SELECT 1> produce trees dozens of levels deep. Please exercise caution when walking those trees
recursively. The L<DBIx::MyParsePP::Rule> module contains the C<extract()> and C<shrink()> methods
which are useful for dealing with the inherent complexity of the MySQL grammar.

=head1 USING GRAMMARS FROM OTHER MYSQL VERSIONS

The package by default parses strings using the grammar from MySQL version 5.0.45. If you wish to use
the grammar from a different version, you can use the C<bin/myconvpp.pl> script to prepare the grammar:

	$ perl bin/myconvpp.pl --

=head1 SEE ALSO

For Yacc grammars, please see the Bison manual at:

	http://www.gnu.org/software/bison

For generating Yacc parsers in Perl, please see:

	http://search.cpan.org/~fdesar

For a full-speed C++-based parser that generates nicer parse trees, please see L<DBIx::MyParse>

=head1 AUTHOR

Philip Stoev, E<lt>philip@stoev.orgE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2007 by Philip Stoev

This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public Licence as specified in
the README and LICENCE files.

Please note that this module contains code copyright by MySQL AB released under
the GNU General Public Licence, and not the GNU Lesser General Public Licence.
Using this code for commercial purposes may require purchasing a licence from MySQL AB.

The Parse::Yapp module and its related modules and shell scripts are copyright (c)
1998-2001 Francois Desarmenien, France. All rights reserved.

=cut

Youez - 2016 - github.com/yon3zu
LinuXploit