Class: RegularExpression::Bytecode::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/regular_expression/bytecode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



143
144
145
146
# File 'lib/regular_expression/bytecode.rb', line 143

def initialize
  @insns = []
  @labels = {}
end

Instance Attribute Details

#insnsObject (readonly)



140
141
142
# File 'lib/regular_expression/bytecode.rb', line 140

def insns
  @insns
end

#labelsObject (readonly)

Hash[Symbol, Integer]



141
142
143
# File 'lib/regular_expression/bytecode.rb', line 141

def labels
  @labels
end

Instance Method Details

#buildObject



156
157
158
# File 'lib/regular_expression/bytecode.rb', line 156

def build
  Compiled.new(insns, labels)
end

#mark_label(label) ⇒ Object



148
149
150
# File 'lib/regular_expression/bytecode.rb', line 148

def mark_label(label)
  labels[label] = insns.size
end

#push(*new_insns) ⇒ Object



152
153
154
# File 'lib/regular_expression/bytecode.rb', line 152

def push(*new_insns)
  insns.push(*new_insns)
end