Sha256: d997f984fd184bcd18ca79d655dcd136a3bab91c6dae4307667806d5798721d0

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

grammar AttrSearchableGrammar
  rule complex_expression
    space? (boolean_expression / expression) space? <ComplexExpression>
  end

  rule boolean_expression
    and_expression
  end

  rule and_expression
    or_expression (space? ('AND' / 'and') space? / space !('OR' / 'or')) complex_expression <AndExpression> / or_expression
  end

  rule or_expression
    expression space? ('OR' / 'or') space? (or_expression / expression) <OrExpression> / expression
  end

  rule expression
    parentheses_expression / not_expression / comparative_expression / anywhere_expression
  end

  rule parentheses_expression
    '(' complex_expression ')' <ParenthesesExpression> 
  end

  rule not_expression
    ('NOT' space / 'not' space / '-') (comparative_expression / anywhere_expression) <NotExpression>
  end

  rule comparative_expression
    simple_column space? comparison_operator space? value <ComparativeExpression>
  end

  rule comparison_operator
    ':' <IncludesOperator> / '=' <EqualOperator> / '!=' <UnequalOperator> / '>=' <GreaterEqualOperator> / '>' <GreaterOperator> / '<=' <LessEqualOperator> / '<' <LessOperator>
  end

  rule anywhere_expression
    ("'" ([^\']* <AnywhereExpression>) "'") / ('"' ([^\"]* <AnywhereExpression>) '"') / [^\s()]+ <AnywhereExpression>
  end

  rule simple_column
    [a-zA-Z0-9_.]+ <Column>
  end

  rule value
    "'" [^\']* "'" <SingleQuotedValue> / '"' [^\"]* '"' <DoubleQuotedValue> / [^\s()]+ <Value>
  end

  rule space
    [\s]+
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
attr_searchable-0.0.7 lib/attr_searchable_grammar.treetop
attr_searchable-0.0.6 lib/attr_searchable_grammar.treetop
attr_searchable-0.0.5 lib/attr_searchable_grammar.treetop
attr_searchable-0.0.4 lib/attr_searchable_grammar.treetop
attr_searchable-0.0.3 lib/attr_searchable_grammar.treetop
attr_searchable-0.0.2 lib/attr_searchable_grammar.treetop
attr_searchable-0.0.1 lib/attr_searchable_grammar.treetop