Sha256: eada1358bea1056602975f4c6bd8ed3126a3e3c95a437fea35362b3ff9fbeb5e

Contents?: true

Size: 1.2 KB

Versions: 6827

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Parser
  # Context of parsing that is represented by a stack of scopes.
  #
  # Supported states:
  # + :class - in the class body (class A; end)
  # + :module - in the module body (module M; end)
  # + :sclass - in the singleton class body (class << obj; end)
  # + :def - in the method body (def m; end)
  # + :defs - in the singleton method body (def self.m; end)
  # + :def_open_args - in the arglist of the method definition
  #                    keep in mind that it's set **only** after reducing the first argument,
  #                    if you need to handle the first argument check `lex_state == expr_fname`
  # + :block - in the block body (tap {})
  # + :lambda - in the lambda body (-> {})
  #
  class Context
    FLAGS = %i[
      in_defined
      in_kwarg
      in_argdef
      in_def
      in_class
      in_block
      in_lambda
    ]

    def initialize
      reset
    end

    def reset
      @in_defined = false
      @in_kwarg = false
      @in_argdef = false
      @in_def = false
      @in_class = false
      @in_block = false
      @in_lambda = false
    end

    attr_accessor(*FLAGS)

    def in_dynamic_block?
      in_block || in_lambda
    end
  end
end

Version data entries

6,827 entries across 6,821 versions & 34 rubygems

Version Path
avalara_sdk-24.12.2 vendor/bundle/ruby/2.7.0/gems/parser-3.1.2.0/lib/parser/context.rb
cybrid_api_bank_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_organization_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_id_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_bank_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_id_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_organization_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
ory-client-1.16.1 vendor/bundle/ruby/3.1.0/gems/parser-3.3.6.0/lib/parser/context.rb
ory-client-1.16.0 vendor/bundle/ruby/3.1.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_bank_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_organization_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_id_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_bank_ruby-0.123.142 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_id_ruby-0.123.142 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_organization_ruby-0.123.142 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_bank_ruby-0.123.140 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_id_ruby-0.123.140 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_organization_ruby-0.123.140 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_bank_ruby-0.123.139 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb
cybrid_api_id_ruby-0.123.139 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/context.rb