Class: RLSM::RegExp::PrimExp

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

Instance Method Summary collapse

Constructor Details

#initialize(parent, str) ⇒ PrimExp

Returns a new instance of PrimExp.



225
226
227
228
229
230
231
232
233
234
# File 'lib/rlsm_regexp.rb', line 225

def initialize(parent, str)
  @parent = parent
  if str == '&' or str == ['&']
    @content = '&'
    @null = true
  else
    @content = str.reject { |c| c == '&' }
    @null = false
  end
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


266
267
268
# File 'lib/rlsm_regexp.rb', line 266

def empty?
  @content == '' or @content == []
end

#firstObject



240
241
242
# File 'lib/rlsm_regexp.rb', line 240

def first
  @null ? [] : @content[0,1]
end

#followObject



248
249
250
251
252
253
254
255
256
# File 'lib/rlsm_regexp.rb', line 248

def follow
  res = []

  (1...@content.length).each do |i|
    res << [@content[i-1,1], @content[i,1]]
  end

  res
end

#lambda?Boolean

Returns:

  • (Boolean)


262
263
264
# File 'lib/rlsm_regexp.rb', line 262

def lambda?
  @null
end

#lastObject



244
245
246
# File 'lib/rlsm_regexp.rb', line 244

def last
  @null ? [] : @content[-1,1]
end

#null?Boolean

Returns:

  • (Boolean)


236
237
238
# File 'lib/rlsm_regexp.rb', line 236

def null?
  @null
end

#to_sObject



258
259
260
# File 'lib/rlsm_regexp.rb', line 258

def to_s
  @content.to_s
end