Parse::BooleanLogic

Parser of boolean expressions
Download

Parse::BooleanLogic Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Ruslan Zakirov and Robert Spier
  • Publisher web site:
  • http://search.cpan.org/~ruz/

Parse::BooleanLogic Tags


Parse::BooleanLogic Description

Parser of boolean expressions Parse::BooleanLogic is a Perl module, a quite fast parser for boolean expressions. Originally it's been writen for Request Tracker to parse SQL like expressions and it's still capable, but it can be used to parse other boolean logic sentences with OPERANDs joined using binary OPERATORs and grouped and nested using parentheses (OPEN_PAREN and CLOSE_PAREN).Operand is not qualified strictly what makes parser flexible enough to parse different things, for example: # SQL like expressions (task.status = "new" OR task.status = "open") AND task.owner_id = 123 # Google like search syntax used in Gmail and other service subject:"some text" (from:me OR to:me) label:todo !label:done # Binary boolean logic expressions (a | b) & (c | d)You can change literals used for boolean operators and parens. Read more about this in description of constructor's arguments.SYNOPSIS use Parse::BooleanLogic; use Data::Dumper; my $parser = Parse::BooleanLogic->new( operators => ); my $tree = $parser->as_array( 'label:parser subject:"boolean logic"' ); print Dumper($tree); $parser = new Parse::BooleanLogic; $tree = $parser->as_array( 'x = 10' ); print Dumper($tree); $tree = $parser->as_array( 'x = 10 OR (x > 20 AND x < 30)' ); print Dumper($tree); # custom parsing using callbacks $parser->parse( string => 'x = 10 OR (x > 20 AND x < 30)', callback => { open_paren => sub { ... }, operator => sub { ... }, operand => sub { ... }, close_paren => sub { ... }, error => sub { ... }, }, ); Requirements: · Perl


Parse::BooleanLogic Related Software