NAME
DBIx::MyParsePP::Rule - Access individual elements from the DBIx::MyParsePP parse tree
SYNOPSIS
use DBIx::MyParsePP;
use DBIx::MyParsePP::Rule;
my $parser = DBIx::MyParsePP->new();
my $query = $parser->parse("SELECT 1"); # $query is a DBIx::MyParsePP::Rule object
print $query->name(); # prints 'query', the top-level grammar rule
my @arguments = $query->arguments(); #
print $arguments[0]->name(); # prints 'verb_clause', the second-level rule
print ref($arguments[1]); # prints 'DBIx::MyParsePP::Token'
print $arguments[1]->type(); # prints END_OF_INPUT
print [[[$query->arguments()]->[0]->arguments()]->[0]->arguments()]->[0]->name(); # Prints 'select'
DESCRIPTION
DBIx::MyParsePP uses the sql_yacc.yy
grammar from the MySQL source to parse SQL strings. A parse tree is produced which contains one branch for every rule encountered during parsing. This means that very deep trees can be produced where only certain branches are important.
METHODS
new($rule_name, @arguments)
constructs a new rule
name()
and getName()
returns the name of the rule
arguments()
and getArguments()
return (as array) the right-side items that were matched for that rule
asString()
converts the parse tree back into SQL by walking the tree and gathering all tokens in sequence.