Sha256: abeb45a043218b21859cc3a3efee8eb0cb4cc45012cb8765ba2a5d14f05586c8

Contents?: true

Size: 1.67 KB

Versions: 13

Compression:

Stored size: 1.67 KB

Contents

module Opal
  REGEXP_START = RUBY_ENGINE == 'opal' ? '^' : '\A'.freeze
  REGEXP_END = RUBY_ENGINE == 'opal' ? '$' : '\z'.freeze

  # Unicode characters in ranges
  # \u0001 - \u002F (blank unicode characters + space + !"#$%&'()*+,-./ chars)
  # \u003A - \u0040 (:;<=>?@ chars)
  # \u005B - \u005E ([\]^ chars)
  # \u0060          (` char)
  # \u007B - \u007F ({|}~ chars})
  # are not allowed to be used in identifier in the beggining or middle of its name
  FORBIDDEN_STARTING_IDENTIFIER_CHARS = "\\u0001-\\u002F\\u003A-\\u0040\\u005B-\\u005E\\u0060\\u007B-\\u007F"

  # Unicode characters in ranges
  # \u0001 - \u0020 (blank unicode characters + space)
  # \u0022 - \u002F ("#$%&'()*+,-./ chars)
  # \u003A - \u003E (:;<=> chars)
  # \u0040          (@ char)
  # \u005B - \u005E ([\]^ chars)
  # \u0060          (` char)
  # \u007B - \u007F ({|}~ chars})
  # are not allowed to be used in identifier in the end of its name
  # In fact, FORBIDDEN_STARTING_IDENTIFIER_CHARS = FORBIDDEN_ENDING_IDENTIFIER_CHARS + \u0021 ('?') + \u003F ('!')
  FORBIDDEN_ENDING_IDENTIFIER_CHARS   = "\\u0001-\\u0020\\u0022-\\u002F\\u003A-\\u003E\\u0040\\u005B-\\u005E\\u0060\\u007B-\\u007F"
  INLINE_IDENTIFIER_REGEXP = Regexp.new("[^#{FORBIDDEN_STARTING_IDENTIFIER_CHARS}]*[^#{FORBIDDEN_ENDING_IDENTIFIER_CHARS}]")

  # For constants rules are pretty much the same, but ':' is allowed and '?!' are not.
  # Plus it may start with a '::' which indicates that the constant comes from toplevel.
  FORBIDDEN_CONST_NAME_CHARS = "\\u0001-\\u0020\\u0021-\\u002F\\u003B-\\u003F\\u0040\\u005B-\\u005E\\u0060\\u007B-\\u007F"
  CONST_NAME_REGEXP = Regexp.new("#{REGEXP_START}(::)?[A-Z][^#{FORBIDDEN_CONST_NAME_CHARS}]*#{REGEXP_END}")
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
opal-0.10.6 lib/opal/regexp_anchors.rb
opal-0.10.6.beta lib/opal/regexp_anchors.rb
opal-0.10.5 lib/opal/regexp_anchors.rb
opal-0.10.4 lib/opal/regexp_anchors.rb
opal-0.10.3 lib/opal/regexp_anchors.rb
opal-0.10.2 lib/opal/regexp_anchors.rb
opal-0.10.1 lib/opal/regexp_anchors.rb
opal-0.10.0 lib/opal/regexp_anchors.rb
opal-0.10.0.rc2 lib/opal/regexp_anchors.rb
opal-0.10.0.rc1 lib/opal/regexp_anchors.rb
opal-0.10.0.beta5 lib/opal/regexp_anchors.rb
opal-0.10.0.beta4 lib/opal/regexp_anchors.rb
opal-0.10.0.beta3 lib/opal/regexp_anchors.rb