Module: Ibex::NormalizeParameterEbnfLowering

Included in:
Normalizer
Defined in:
lib/ibex/normalize/parameter_ebnf_lowering.rb,
sig/ibex/normalize/parameter_ebnf_lowering.rbs

Overview

Resumable EBNF lowering used inside specialized parameter alternatives.

Instance Method Summary collapse

Instance Method Details

#finish_parameter_group_alternative(frame, helper, item, length) ⇒ void

This method returns an undefined value.

RBS:

  • (Hash[Symbol, untyped] frame, String helper, Frontend::AST::Group item, Integer length) -> void

Parameters:



63
64
65
66
67
# File 'lib/ibex/normalize/parameter_ebnf_lowering.rb', line 63

def finish_parameter_group_alternative(frame, helper, item, length)
  # @type self: Normalizer
  rhs = frame.fetch(:values).pop(length)
  add_group_production(helper, rhs, item)
end

#finish_parameter_separated_list(frame, item) ⇒ void

This method returns an undefined value.

RBS:

  • (Hash[Symbol, untyped] frame, Frontend::AST::SeparatedList item) -> void

Parameters:



35
36
37
38
39
40
# File 'lib/ibex/normalize/parameter_ebnf_lowering.rb', line 35

def finish_parameter_separated_list(frame, item)
  # @type self: Normalizer
  separator = frame.fetch(:values).pop
  base = frame.fetch(:values).pop
  frame.fetch(:values) << build_separated_list(item, base, separator)
end

#finish_parameter_suffix(frame, item) ⇒ void

This method returns an undefined value.

RBS:

  • (Hash[Symbol, untyped] frame, Frontend::AST::Optional | Frontend::AST::Star | Frontend::AST::Plus item) -> void

Parameters:



16
17
18
19
20
21
22
23
24
25
# File 'lib/ibex/normalize/parameter_ebnf_lowering.rb', line 16

def finish_parameter_suffix(frame, item)
  # @type self: Normalizer
  base = frame.fetch(:values).pop
  helper = case item
           when Frontend::AST::Optional then build_optional(item, base)
           when Frontend::AST::Star then build_star(item, base)
           when Frontend::AST::Plus then build_plus(item, base)
           end
  frame.fetch(:values) << helper
end

#lower_parameter_group(frame, item) ⇒ void

This method returns an undefined value.

RBS:

  • (Hash[Symbol, untyped] frame, Frontend::AST::Group item) -> void

Parameters:



43
44
45
46
47
48
49
50
51
52
# File 'lib/ibex/normalize/parameter_ebnf_lowering.rb', line 43

def lower_parameter_group(frame, item)
  # @type self: Normalizer
  reject_group_named_references(item)
  helper = new_helper("group", item.loc)
  operations = frame.fetch(:operations)
  operations << [:value, helper]
  item.alternatives.reverse_each do |alternative|
    operations << [:group_alternative, helper, item, alternative]
  end
end

#lower_parameter_separated_list(frame, item) ⇒ void

This method returns an undefined value.

RBS:

  • (Hash[Symbol, untyped] frame, Frontend::AST::SeparatedList item) -> void

Parameters:



28
29
30
31
32
# File 'lib/ibex/normalize/parameter_ebnf_lowering.rb', line 28

def lower_parameter_separated_list(frame, item)
  frame.fetch(:operations).push(
    [:finish_separated, item], [:item, item.separator], [:item, item.item]
  )
end

#lower_parameter_suffix(frame, item) ⇒ void

This method returns an undefined value.

RBS:

  • (Hash[Symbol, untyped] frame, Frontend::AST::Optional | Frontend::AST::Star | Frontend::AST::Plus item) -> void

Parameters:



10
11
12
# File 'lib/ibex/normalize/parameter_ebnf_lowering.rb', line 10

def lower_parameter_suffix(frame, item)
  frame.fetch(:operations).push([:finish_suffix, item], [:item, item.item])
end

#start_parameter_group_alternative(frame, helper, item, alternative) ⇒ void

This method returns an undefined value.

RBS:

  • (Hash[Symbol, untyped] frame, String helper, Frontend::AST::Group item, Array[Frontend::AST::item] alternative) -> void

Parameters:

  • frame (Hash[Symbol, untyped])
  • helper (String)
  • item (Frontend::AST::Group)
  • alternative (Array[Frontend::AST::item])


56
57
58
59
60
# File 'lib/ibex/normalize/parameter_ebnf_lowering.rb', line 56

def start_parameter_group_alternative(frame, helper, item, alternative)
  operations = frame.fetch(:operations)
  operations << [:finish_group_alternative, helper, item, alternative.length]
  alternative.reverse_each { |child| operations << [:item, child] }
end