# # Author:: Seth Falcon () # Copyright:: Copyright (c) 2010-2011 Opscode, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # grammar Lucene rule body (expression / space)* end rule expression operation / group / field / field_range / term / string end rule term keyword valid_letter+ / !keyword !"?" valid_letter end rule field field_name ":" (term/string/group) end rule field_range field_name ":" "[" range_value " TO " range_value "]" / field_name ":" "{" range_value " TO " range_value "}" end rule field_name !keyword valid_letter+ end rule range_value valid_letter+ / "*" end rule group space? '(' body ')' space? end rule operation binary_op / unary_op / fuzzy_op / boost_op end rule unary_op not_op / required_op / prohibited_op end rule binary_op (group / field / field_range / term) space? boolean_operator space+ body end rule boolean_operator and_operator / or_operator end rule and_operator 'AND' / '&&' end rule or_operator 'OR' / '||' end rule not_op not_operator space (group / field / field_range / term / string) / bang_operator space? (group / field / field_range / term / string) end rule not_operator 'NOT' end rule bang_operator '!' end rule required_op !valid_letter required_operator (term/string) / required_operator (term/string) end rule required_operator '+' end rule prohibited_op !valid_letter prohibited_operator (field/field_range/term/string) end rule prohibited_operator '-' end rule boost_op (term/string) '^' fuzzy_param end rule fuzzy_op (term/string) '~' fuzzy_param? (space / !valid_letter) end rule fuzzy_param [0-9] '.'? [0-9] / [0-9]+ end rule string '"' term (space term)* '"' end rule keyword 'AND' / 'OR' / 'NOT' end rule valid_letter start_letter+ ([a-zA-Z0-9@*?_.-] / '\\' special_char)* end rule start_letter [a-zA-Z0-9@._*] / '\\' special_char end rule end_letter [a-zA-Z0-9*?_.] / '\\' special_char end rule special_char [-+&|!(){}\[\]^"~*?:\\] end rule space [\s]+ end end