Sha256: cda6c4f09bdbf853f51d31eafa8f08e5459c5d0015db6d6831b9560a1ac26ed5

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logical_query_parser-0.3.2 lib/logical_query_parser.treetop
logical_query_parser-0.3.1 lib/logical_query_parser.treetop
logical_query_parser-0.3.0 lib/logical_query_parser.treetop