DBIx::MyParsePP::Query
DBIx::MyParsePP::QuerUser Contributed Perl DocumentaDBIx::MyParsePP::Query(3)
NAME
DBIx::MyParsePP::Query - Query produced by DBIx::MyParsePP
SYNOPSIS
use DBIx::MyParsePP;
my $parser = DBIx::MyParsePP->new();
my $query = $parser->parse("SELECT 1");
if (not defined $query->root()) {
print "Error at pos ".$query->pos()", line ".$pos->line()."\n";
} else {
print "Query was ".$query->toString();
}
METHODS
"getLexer()" returns the DBIx::MyParsePP::Lexer object for the string
"getRoot()" returns a DBIx::MYParsePP::Rule object representing the
root of the parse tree
"toString()" walks the parse tree reconstructs the query using the
individual tokens.
"tokens()" and "getTokens()" returns a reference to an array contain-
ing all tokens parsed as DBIx::MyParsePP::Token objects. If the pars-
ing failed, the list contains all tokens up to the failure point.
ERROR HANDLING
On error, "getRoot()" will return "undef". You can call the following
methods to determine the error:
"getExpected()" returns a list of tokens the parser expected to find,
whereas "getActual()" returns the actual token name that was encoun-
tered which caused the error. Please note that "getActual()" returns a
DBIx::MyParsePP::Token object, whereas "getExpected()" returns a list
of strings, containing just the token types.
"getLine()" returns the line number where the error occured. "get-
Pos()" returns the character position where the error occured, count-
ing from the beginning of the string, not the begining of the line.
"getTokens()" can be used to reconstruct the query as it was up to the
failure point.
UTILITY FUNCTIONS
"getSelectItems()", "getFrom()", "getWhere()", "getGroupBy()",
"getOrderBy()", "getHaving()" return the respective parts of the parse
tree as a DBIx::MyParsePP::Rule object. Depending on the query, the
part of the tree that is being returned may look differently, e.g.
"getFrom()" will return widely different things depending on how many
tables are in the "FROM" clause, whether there are joins or sub-
queries. You can then use "shrink()" and "extract()" on the return
value to further narrow down on the part of the query you are inter-
ested in.
perl v5.8.8 2007-08-17 DBIx::MyParsePP::Query(3)