Sha256: 918c54493e8766ee620f717730ec33f382bf7cbe958be9e250d7718442217280

Contents?: true

Size: 1.32 KB

Versions: 24

Compression:

Stored size: 1.32 KB

Contents

# Define the base module and the simplest of tokens.
module Regexp::Syntax
  module Token
    Map = {}

    module Literal
      All = [:literal]
      Type = :literal
    end

    module FreeSpace
      All  = [:comment, :whitespace]
      Type = :free_space
    end

    Map[FreeSpace::Type] = FreeSpace::All
    Map[Literal::Type]   = Literal::All
  end
end


# Load all the token files, they will populate the Map constant.
require 'regexp_parser/syntax/tokens/anchor'
require 'regexp_parser/syntax/tokens/assertion'
require 'regexp_parser/syntax/tokens/backref'
require 'regexp_parser/syntax/tokens/character_set'
require 'regexp_parser/syntax/tokens/character_type'
require 'regexp_parser/syntax/tokens/conditional'
require 'regexp_parser/syntax/tokens/escape'
require 'regexp_parser/syntax/tokens/group'
require 'regexp_parser/syntax/tokens/keep'
require 'regexp_parser/syntax/tokens/meta'
require 'regexp_parser/syntax/tokens/quantifier'
require 'regexp_parser/syntax/tokens/unicode_property'


# After loading all the tokens the map is full. Extract all tokens and types
# into the All and Types constants.
module Regexp::Syntax
  module Token
    if RUBY_VERSION >= '1.9'
      All = Map.map {|k,v| v}.flatten.uniq.sort
    else
      All = Map.map {|k,v| v}.flatten.uniq
    end

    Types = Map.keys

    All.freeze
    Types.freeze
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
regexp_parser-0.5.0 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.13 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.12 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.11 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.10 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.9 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.8 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.7 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.6 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.5 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.4 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.3 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.2 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.1 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.4.0 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.3.6 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.3.5 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.3.4 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.3.3 lib/regexp_parser/syntax/tokens.rb
regexp_parser-0.3.2 lib/regexp_parser/syntax/tokens.rb