Sha256: 4586da34f69b790fe1a284b6a3cdaee23c9bd186255c5a400c976647d749d7ba

Contents?: true

Size: 1.66 KB

Versions: 24

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

module Unparser
  # All unparser constants maybe included in other libraries.
  module Constants

    # All unary operators of the ruby language
    UNARY_OPERATORS = %i[
      ! ~ -@ +@
    ].to_set.freeze

    # All binary operators of the ruby language
    BINARY_OPERATORS = %i[
      + - * / & | && || << >> ==
      === != <= < <=> > >= =~ !~ ^
      ** %
    ].to_set.freeze

    # Keywords
    K_DO       = 'do'
    K_DEF      = 'def'
    K_END      = 'end'
    K_BEGIN    = 'begin'
    K_CASE     = 'case'
    K_CLASS    = 'class'
    K_SELF     = 'self'
    K_ENSURE   = 'ensure'
    K_DEFINE   = 'define'
    K_MODULE   = 'module'
    K_RESCUE   = 'rescue'
    K_RETURN   = 'return'
    K_UNDEF    = 'undef'
    K_DEFINED  = 'defined?'
    K_PREEXE   = 'BEGIN'
    K_POSTEXE  = 'END'
    K_SUPER    = 'super'
    K_BREAK    = 'break'
    K_RETRY    = 'retry'
    K_REDO     = 'redo'
    K_NEXT     = 'next'
    K_FALSE    = 'false'
    K_TRUE     = 'true'
    K_IF       = 'if'
    K_AND      = 'and'
    K_ALIAS    = 'alias'
    K_ELSE     = 'else'
    K_ELSIF    = 'elsif'
    K_FOR      = 'for'
    K_NIL      = 'nil'
    K_NOT      = 'not'
    K_IN       = 'in'
    K_OR       = 'or'
    K_UNLESS   = 'unless'
    K_WHEN     = 'when'
    K_WHILE    = 'while'
    K_UNTIL    = 'until'
    K_YIELD    = 'yield'
    K_ENCODING = '__ENCODING__'
    K_EEND     = '__END__'
    K_FILE     = '__FILE__'
    K_THEN     = 'then'

    KEYWORDS = constants.each_with_object([]) do |name, keywords|
      value = const_get(name).freeze
      next unless name.to_s.start_with?('K_')

      keywords << value.to_sym
    end.to_set.freeze

  end # Constants
end # Unparser

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
unparser-0.6.15 lib/unparser/constants.rb
unparser-0.6.14 lib/unparser/constants.rb
unparser-0.6.13 lib/unparser/constants.rb
unparser-0.6.12 lib/unparser/constants.rb
unparser-0.6.10 lib/unparser/constants.rb
unparser-0.6.9 lib/unparser/constants.rb
unparser-0.6.8 lib/unparser/constants.rb
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/unparser-0.6.7/lib/unparser/constants.rb
unparser-0.6.7 lib/unparser/constants.rb
unparser-0.6.6 lib/unparser/constants.rb
unparser-0.6.5 lib/unparser/constants.rb
unparser-0.6.4 lib/unparser/constants.rb
unparser-0.6.3 lib/unparser/constants.rb
unparser-0.6.2 lib/unparser/constants.rb
unparser-0.6.1 lib/unparser/constants.rb
unparser-0.6.0 lib/unparser/constants.rb
unparser-0.5.7 lib/unparser/constants.rb
unparser-0.5.6 lib/unparser/constants.rb
unparser-0.5.5 lib/unparser/constants.rb
unparser-0.5.4 lib/unparser/constants.rb