File: token.rb

package info (click to toggle)
ruby-regexp-parser 2.11.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,092 kB
  • sloc: ruby: 6,891; makefile: 6; sh: 3
file content (47 lines) | stat: -rw-r--r-- 1,177 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

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

    module Literal
      All = %i[literal].freeze
      Type = :literal
    end

    module FreeSpace
      All  = %i[comment whitespace].freeze
      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_relative 'token/anchor'
require_relative 'token/assertion'
require_relative 'token/backreference'
require_relative 'token/posix_class'
require_relative 'token/character_set'
require_relative 'token/character_type'
require_relative 'token/conditional'
require_relative 'token/escape'
require_relative 'token/group'
require_relative 'token/keep'
require_relative 'token/meta'
require_relative 'token/quantifier'
require_relative 'token/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
    All   = Map.values.flatten.uniq.sort.freeze
    Types = Map.keys.freeze
  end
end