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