Class: InterMine::PathQuery::LogicParser

Inherits:
Object
  • Object
show all
Defined in:
lib/intermine/query.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ LogicParser

Returns a new instance of LogicParser.



1472
1473
1474
# File 'lib/intermine/query.rb', line 1472

def initialize(query)
    @query = query
end

Class Attribute Details

.opsObject

Returns the value of attribute ops.



1453
1454
1455
# File 'lib/intermine/query.rb', line 1453

def ops
  @ops
end

.precedenceObject

Returns the value of attribute precedence.



1453
1454
1455
# File 'lib/intermine/query.rb', line 1453

def precedence
  @precedence
end

Instance Method Details

#parse_logic(str) ⇒ Object



1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
# File 'lib/intermine/query.rb', line 1476

def parse_logic(str)
    tokens = str.upcase.split(/(?:\s+|\b)/).map do |x| 
        LogicParser.ops.fetch(x, x.split(//))
    end
    tokens.flatten!

    check_syntax(tokens)
    postfix_tokens = infix_to_postfix(tokens)
    ast = postfix_to_tree(postfix_tokens)
    return ast
end