grammar LogicalQueryParser
rule exp sp* exp:(logic_exp / paren_exp / literal_exp / literal) sp* <ExpNode> end rule logic_exp lexp:(paren_exp / literal_exp / literal) logic:(and / or) rexp:exp <LogicExpNode> end rule paren_exp negative:not* lparen exp rparen rexp:exp* <ParenExpNode> end rule literal_exp literal sp+ exp <LiteralExpNode> end rule literal negative:not* word <LiteralNode> end rule word (quoted_word / unquoted_word) <WordNode> end rule quoted_word '"' ('\"' / !'"' .)* '"' end rule unquoted_word atom+ end rule lparen '(' <LParenNode> end rule rparen ')' <RParenNode> end rule and sp+ and_ope sp+ <AndNode> end rule or sp+ or_ope sp+ <OrNode> end rule not (not_ope sp+ / not_sym sp*) <NotNode> end rule and_ope 'AND' / 'and' / '&&' / '&' end rule or_ope 'OR' / 'or' / '||' / '|' end rule not_ope 'NOT' / 'not' end rule not_sym '-' / '-' / '-' end rule sp ' ' / ' ' end rule atom !(lparen / rparen /and_ope / or_ope / not_ope / not_sym / sp) . end
end