Class: RLSM::RegExp::Star

Inherits:
Object show all
Defined in:
lib/rlsm_regexp.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, str) ⇒ Star

Returns a new instance of Star.



272
273
274
275
# File 'lib/rlsm_regexp.rb', line 272

def initialize(parent, str)
  @parent = parent
  @child = NodeFactory.new_node(self, str[(0..-2)])
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


314
315
316
# File 'lib/rlsm_regexp.rb', line 314

def empty?
  false
end

#firstObject



281
282
283
# File 'lib/rlsm_regexp.rb', line 281

def first
  @child.first
end

#followObject



289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/rlsm_regexp.rb', line 289

def follow
  res = @child.follow

  #Cross of last and first
  first.each do |f|
    last.each do |l|
      res << [l,f]
    end
  end

  res
end

#lambda?Boolean

Returns:

  • (Boolean)


310
311
312
# File 'lib/rlsm_regexp.rb', line 310

def lambda?
  false
end

#lastObject



285
286
287
# File 'lib/rlsm_regexp.rb', line 285

def last
  @child.last
end

#null?Boolean

Returns:

  • (Boolean)


277
278
279
# File 'lib/rlsm_regexp.rb', line 277

def null?
  true
end

#to_sObject



302
303
304
305
306
307
308
# File 'lib/rlsm_regexp.rb', line 302

def to_s
  if @child.class == PrimExp and @child.to_s.length == 1
    return "#{@child.to_s}*"
  else
    return "(#{@child.to_s})*"
  end
end