filter: expression end_of_file { $return = $item[1] } | { $Persist::Filter::errors .= "ERROR: Could not parse filter.\n"; foreach (@{$thisparser->{errors}}) { $Persist::Filter::errors .= "ERROR Line $_->[1]: $_->[0]\n"; } $thisparser->{errors} = undef; } end_of_file: /^\Z/ expression: comparison logical_operator expression { $return = new Persist::Filter::Junction(@item{qw(comparison logical_operator expression)}) } | comparison | /not/i expression { $return = new Persist::Filter::Not(lc($item[1]), $item{expression}) } | comparison: first_operand comparison_operator second_operand { $return = new Persist::Filter::Comparison(@item{qw(first_operand comparison_operator second_operand)}) } | '(' expression ')' { $return = $item{expression} } | first_operand: operand second_operand: operand operand: identifier | literal | placeholder logical_operator: /and/i { $return = lc($item[1]) } | /or/i { $return = lc($item[1]) } comparison_operator: '=' | '<>' | /<=?/ | />=?/ | /(?:not\s+)?i?like/i { $item[1] =~ s/\s+/ /; $return = lc($item[1]) } identifier: table_name '.' column_name { $return = new Persist::Filter::Identifier("$item{table_name}.$item{column_name}") } | integer '.' column_name { $return = new Persist::Filter::Identifier("$item{table_name}.$item{column_name}") } | column_name { $return = new Persist::Filter::Identifier($item{column_name}) } | table_name: name column_name: name literal: string { $return = new Persist::Filter::String($item{string}) } | number { $return = new Persist::Filter::Number($item{number}) } placeholder: '?' { $return = new Persist::Filter::Placeholder('?') } name: /[a-z_][a-z0-9_]*/i string: "'" character(s) "'" { $return = "'".(join '', @{$item{'character(s)'}})."'" } | integer: /\d+/ number: /[+-]?[0-9]*\.[0-9]+(?:e[+-]?[0-9]+)?/i { $return = lc($item[1]) } | /[+-]?[0-9]+\.?(?:e[+-]?[0-9]+)?/i { $return = lc($item[1]) } character: "\\\\'" { $return = "\\\\'" } | /[^']/