Sha256: 0cacdd997601755007e6e81414f619228f4f6e15f5ab4e9bd85678ebf6b79376

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

grammar SearchCopGrammar
  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

3 entries across 3 versions & 1 rubygems

Version Path
search_cop-1.0.2 lib/search_cop_grammar.treetop
search_cop-1.0.1 lib/search_cop_grammar.treetop
search_cop-1.0.0 lib/search_cop_grammar.treetop