Class: Cucumber::TagExpressions::Parser
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-tag-expressions-4.1.0/lib/cucumber/tag_expressions/parser.rb
Overview
Ruby tag expression parser
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse(infix_expression) ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-tag-expressions-4.1.0/lib/cucumber/tag_expressions/parser.rb', line 7 def initialize @expressions = [] @operators = [] @operator_types = { 'or' => { type: :binary_operator, precedence: 0, assoc: :left }, 'and' => { type: :binary_operator, precedence: 1, assoc: :left }, 'not' => { type: :unary_operator, precedence: 2, assoc: :right }, ')' => { type: :close_paren, precedence: -1 }, '(' => { type: :open_paren, precedence: 1 } } end |
Instance Method Details
#parse(infix_expression) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-tag-expressions-4.1.0/lib/cucumber/tag_expressions/parser.rb', line 20 def parse(infix_expression) process_tokens!(infix_expression) while @operators.any? raise 'Syntax error. Unmatched (' if @operators.last == '(' push_expression(pop(@operators)) end expression = pop(@expressions) @expressions.empty? ? expression : raise('Not empty') end |