Class: Marker

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

Overview

class Marker

Constant Summary collapse

OPT =
1
RPT =
2
@@opt =

include Utils

/\[~([^\[\]]*)~\]/
@@rpt =
/\{~([^\[\]]*)~}/
@@match_regex =
Regexp.union(@@opt, @@rpt)

Class Method Summary collapse

Class Method Details

.gen(segment) ⇒ Object



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/ez7gen/structure_parser.rb', line 291

def self.gen(segment)
  marker = nil

  mtch = segment.match(@@match_regex)
  return nil if(!mtch)# done if nothing to match

  # seg = (mtch[Marker:OPT])?mtch[Marker:OPT]:mtch[Marker:RPT]
  if(mtch[Marker::OPT])
    marker = OptionalGroup.new(mtch[Marker::OPT])
    # # check for optional repeating
    if(repeatingSubMarker = Marker.gen(mtch[Marker::OPT]))
     marker= marker.clear.push(repeatingSubMarker)
    end
  elsif(mtch[Marker::RPT])
    marker = RepeatingGroup.new(mtch[Marker::RPT])
  end
  return marker
end

.gen1(segment) ⇒ Object

decided that segment has subgroups



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/ez7gen/structure_parser.rb', line 260

def self.gen1(segment)
  marker = nil

  # 1 no match - just to cover bases
  marker = whatGroup?(segment)
  return nil if(!marker)# done if nothing to match

  # if(mtch[Marker::OPT])# 2 optional
  #   marker = OptionalGroup.new(mtch[Marker::OPT])
  #   # # check for optional repeating
  # elsif(mtch[Marker::RPT])# 3 repeating
  #   marker = RepeatingGroup.new(mtch[Marker::RPT])
  # end

  # 3 repeating

  # 4 if optional check for optional-repeating

    # if(mtch[Marker::OPT])
    #   marker = OptionalGroup.new(mtch[Marker::OPT])
    #   # # check for optional repeating
    #   if(repeatingSubMarker = Marker.gen(mtch[Marker::OPT]))
    #    marker= marker.clear.push(repeatingSubMarker)
    #   end
    # elsif(mtch[Marker::RPT])
    #   marker = RepeatingGroup.new(mtch[Marker::RPT])
    # end
    return marker

end

.mark(group, prnths) ⇒ Object

def self.match_for_complex_group(segment)

mtch = segment.match(@@match_regex)

end



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

def self.mark(group, prnths)
    group = prnths.clone().insert(1,group)
end

.whatGroup?(segment) ⇒ Boolean

Returns:

  • (Boolean)


318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/ez7gen/structure_parser.rb', line 318

def self.whatGroup?(segment)
  group = nil
  mtch = segment.match(@@match_regex)
  return group if(!mtch)# done if nothing to match

  if(mtch[Marker::OPT])
     OptionalGroup.new()
   elsif(mtch[Marker::RPT])
     RepeatingGroup.new()
  end

end