parse (Randexp::Parser)

    # File lib/randexp/parser.rb, line 3
        def self.parse(source)
          case
          when source =~ /^(.*)(\*|\*\?|\+|\+\?|\?)$/ && balanced?($1, $2)
            parse_quantified($1, $2.to_sym)                                 # ends with *, +, or ?: /(..)?/
          when source =~ /^(.*)\{(\d+)\,(\d+)\}$/ && balanced?($1, $2)
            parse_quantified($1, ($2.to_i)..($3.to_i))                      #ends with a range: /(..){..,..}/
          when source =~ /^(.*)\{(\d+)\}$/ && balanced?($1, $2)
            parse_quantified($1, $2.to_i)                                   #ends with a range: /..(..){..}/
          when source =~ /^\((.*)\)\((.*)\)$/ && balanced?($1, $2)
            union(parse($1), parse($2))                                     #balanced union: /(..)(..)/
          when source =~ /^(\(.*\))\|(\(.*\))$/ && balanced?($1, $2)
            intersection(parse($1), parse($2))                              #balanced intersection: /(..)|(..)/
          when source =~ /^(.*)\|(.*)$/ && balanced?($1, $2)
            intersection(parse($1), parse($2))                              #implied intersection: /..|../
          when source =~ /^(.*)\|\((\(.*\))\)$/ && balanced?($1, $2)
            intersection(parse($1), parse($2))                              #unbalanced intersection: /(..)|((...))/
          when source =~ /^(.+)(\(.*\))$/ && balanced?($1, $2)
            union(parse($1), parse($2))                                     #unbalanced union: /...(...)/
          when source =~ /^\((.*)\)$/ && balanced?($1)
            union(parse($1))                                                #explicit group: /(..)/
          when source =~ /^([^()]*)(\(.*\))$/ && balanced?($1, $2)
            union(parse($1), parse($2))                                     #implied group: /..(..)/
          when source =~ /^(.*)\[\:(.*)\:\]$/
            union(parse($1), random($2))                                    #custom random: /[:word:]/
          when source =~ /^(.*)\\([wsdc])$/
            union(parse($1), random($2))                                    #reserved random: /..\w/
          when source =~ /^(.*)\\(.)$/ || source =~ /(.*)(.|\s)$/
            union(parse($1), literal($2))                                   #end with literal or space: /... /
          else
            nil
          end
        end