Class: InterMine::PathQuery::LogicParser
- Inherits:
-
Object
- Object
- InterMine::PathQuery::LogicParser
- Defined in:
- lib/intermine/query.rb
Class Attribute Summary collapse
-
.ops ⇒ Object
Returns the value of attribute ops.
-
.precedence ⇒ Object
Returns the value of attribute precedence.
Instance Method Summary collapse
-
#initialize(query) ⇒ LogicParser
constructor
A new instance of LogicParser.
- #parse_logic(str) ⇒ Object
Constructor Details
#initialize(query) ⇒ LogicParser
Returns a new instance of LogicParser.
1354 1355 1356 |
# File 'lib/intermine/query.rb', line 1354 def initialize(query) @query = query end |
Class Attribute Details
.ops ⇒ Object
Returns the value of attribute ops.
1335 1336 1337 |
# File 'lib/intermine/query.rb', line 1335 def ops @ops end |
.precedence ⇒ Object
Returns the value of attribute precedence.
1335 1336 1337 |
# File 'lib/intermine/query.rb', line 1335 def precedence @precedence end |
Instance Method Details
#parse_logic(str) ⇒ Object
1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 |
# File 'lib/intermine/query.rb', line 1358 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 |