Class: Strling::Core::IRQuant

Inherits:
IROp
  • Object
show all
Defined in:
lib/strling/core/ir.rb

Overview

Represents a quantifier (repetition operator) in the IR.

Specifies how many times a pattern element should match.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(child, min, max, mode) ⇒ IRQuant

Returns a new instance of IRQuant.

Parameters:

  • child (IROp)

    The child node being quantified

  • min (Integer)

    The minimum number of matches

  • max (Integer, String)

    The maximum number of matches

  • mode (String)

    The quantifier mode



233
234
235
236
237
238
# File 'lib/strling/core/ir.rb', line 233

def initialize(child, min, max, mode)
  @child = child
  @min = min
  @max = max
  @mode = mode
end

Instance Attribute Details

#childIROp

Returns The child node being quantified.

Returns:

  • (IROp)

    The child node being quantified



218
219
220
# File 'lib/strling/core/ir.rb', line 218

def child
  @child
end

#maxInteger, String

Returns The maximum number of matches (“Inf” for unbounded).

Returns:

  • (Integer, String)

    The maximum number of matches (“Inf” for unbounded)



224
225
226
# File 'lib/strling/core/ir.rb', line 224

def max
  @max
end

#minInteger

Returns The minimum number of matches.

Returns:

  • (Integer)

    The minimum number of matches



221
222
223
# File 'lib/strling/core/ir.rb', line 221

def min
  @min
end

#modeString

Returns The quantifier mode: “Greedy”, “Lazy”, or “Possessive”.

Returns:

  • (String)

    The quantifier mode: “Greedy”, “Lazy”, or “Possessive”



227
228
229
# File 'lib/strling/core/ir.rb', line 227

def mode
  @mode
end

Instance Method Details

#to_dictObject



240
241
242
243
244
245
246
247
248
# File 'lib/strling/core/ir.rb', line 240

def to_dict
  {
    'ir' => 'Quant',
    'child' => child.to_dict,
    'min' => min,
    'max' => max,
    'mode' => mode
  }
end