NAME

DDC::Query::Parser - pure-perl DDC query parser, top-level [DEPRECATED]

SYNOPSIS

##========================================================================
## PRELIMINARIES

use DDC::Query::Parser;

##========================================================================
## Constructors etc.

$qp = $CLASS_OR_OBJ->new(%args);
undef = $qp->free();
$qp = $qp->getClosures();

##========================================================================
## API: Input selection

undef = $qp->reset();
$qp = $qp->from($which,$src, %opts);
$qp = $qp->fromFile($filename_or_handle,%opts);
$qp = $qp->fromFh($fh,%opts);
$qp = $qp->fromString($str,%opts);

##========================================================================
## API: High-level Parsing

$query_or_undef = $qp->parse(string=>$str);
$query_or_undef = $qp->yyparse();

##========================================================================
## Query Generation API: Mid-level: generic

$q = $parser->newq($class,%args);
$qf = $parser->newf($class,%args);
\&yylex_sub = $qp->_yylex_sub();
\&yyerror_sub = $qp->_yyerror_sub();

DESCRIPTION

The DDC::Parser module provides pure-perl wrapper classes for parsing DDC queries. Its use is deprecated in favor of the DDC::XS::CQueryCompiler module providing direct access to the underlying C++ libraries.

Constructors etc.

new
$qp = $CLASS_OR_OBJ->new(%args);

Abstract constructor; you should probably call free() before destroying the object to be safe.

object structure, %args:

{
 ##-- Status flags
 error => $current_errstr, ##-- false indicates no error
 ##-- parsed data
 #query  => $query,          ##-- most recently parsed query, a DDC::Query object
 #filters => \@filters,      ##-- query filters
 ##-- Underlying lexer/parser pair
 lexer  => $yylexer,   ##-- a DDC::YYLexer object
 parser => $yyparser,  ##-- a DDC::YYParser object
 yydebug => $mask,     ##-- yydebug value
 ##-- Closures
 yylex    => \&yylex,   ##-- yapp-friendly lexer sub
 yyerror  => \&yyerror, ##-- yapp-friendly parser sub
}
free
undef = $qp->free();
  • clears $qp itself, as well as $qp->{parser}{USER}

  • makes $qp subsequently useless, but destroyable

getClosures
$qp = $qp->getClosures();

compiles lexer & parser closures

API: Input selection

reset
undef = $qp->reset();

reset all parse-relevant data structures

from
$qp = $qp->from($which,$src, %opts);
  • wraps $qp->{lexer}->from()

  • $which is one of qw(fh file string)

  • $src is the actual source (default: 'string')

  • %opts may contain (src=>$name)

fromFile
$qp = $qp->fromFile($filename_or_handle,%opts);

wraps $qp->{lexer}->fromFile()

fromFh
$qp = $qp->fromFh($fh,%opts);

wraps $qp->{lexer}->fromFh()

fromString
$qp = $qp->fromString($str,%opts);
$qp = $qp->fromString(\$str,%opts);

wraps $qp->{lexer}->fromString()

API: High-level Parsing

parse
$query_or_undef = $qp->parse(string=>$str);
$query_or_undef = $qp->parse(string=>\$str)
$query_or_undef = $qp->parse(file=>$filename)
$query_or_undef = $qp->parse(fh=>$handle)
yyparse
$query_or_undef = $qp->yyparse();

parses from currently selected input source; no reset or error catching

Query Generation API: Mid-level: generic

newq
$q = $parser->newq($class,%args);

wrapper for DDC::Query->new(class=>$class,%args); called by yapp parser

newf
$qf = $parser->newf($class,%args);

wrapper for DDC::Query::Filter->new(class=>$class,%args); called by yapp parser

_yylex_sub
\&yylex_sub = $qp->_yylex_sub();

returns a Parse::Yapp-friendly lexer subroutine

_yyerror_sub
\&yyerror_sub = $qp->_yyerror_sub();

returns error subroutine for the underlying Yapp parser

ACKNOWLEDGEMENTS

perl by Larry Wall.

AUTHOR

Bryan Jurish <moocow@cpan.org>

COPYRIGHT

Copyright (c) 2011-2015, Bryan Jurish. All rights reserved.

This package is free software. You may redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

perl(1)