Class: RedParse::BeginNode
- Includes:
- HasRescue
- Defined in:
- lib/redparse/node.rb,
lib/redparse/ripper.rb,
lib/redparse/ReduceWithsFor_RedParse_1_9.rb,
lib/redparse/ReduceWithsFor_RedParse_1_8.rb
Constant Summary
Constants included from FlattenedIvars
FlattenedIvars::EXCLUDED_IVARS
Instance Attribute Summary collapse
-
#after_comma ⇒ Object
Returns the value of attribute after_comma.
-
#after_equals ⇒ Object
Returns the value of attribute after_equals.
-
#empty_else ⇒ Object
readonly
Returns the value of attribute empty_else.
-
#empty_ensure ⇒ Object
readonly
Returns the value of attribute empty_ensure.
Attributes inherited from Node
#endline, #errors, #offset, #parent, #startline
Attributes included from Stackable::Meta
#boolean_identity_params, #identity_params
Instance Method Summary collapse
- #begin_parsetree(o) ⇒ Object
- #image ⇒ Object
-
#initialize(*args) ⇒ BeginNode
constructor
A new instance of BeginNode.
- #lvalue ⇒ Object
- #non_empty ⇒ Object
- #op? ⇒ Boolean
- #parsetree(o) ⇒ Object
- #reducer_ident ⇒ Object
- #rescue_parsetree(o) ⇒ Object
- #rip(p) ⇒ Object
- #special_conditions! ⇒ Object
- #to_lisp ⇒ Object
-
#unparse(o = default_unparse_options) ⇒ Object
attr_accessor :lvalue.
Methods included from HasRescue
#parsetree_and_rescues, #unparse_and_rescues
Methods inherited from ValueNode
Methods inherited from Node
#+, #+@, #==, [], #[]=, #add_parent_links!, #args_rip, #classic_inspect, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #force_stmt_list_rip, #initialize_ivars, inline_symbols, #inspect, #lhs_unparse, #linerange, #lvars_defined_in, #merge_replacement_session, namelist, #negate, #original_brackets_assign, param_names, #parsetrees, #pretty_print, #prohibit_fixup, #replace_ivars_and_self, #replace_value, #rfind, #rfind_all, #rgrep, #rip_and_rescues, #rip_explode!, #short_inspect, #stmts_rip, #to_parsetree, #to_parsetree_and_warnings, #to_ruby, #to_s, #unary, #walk, #xform_tree!
Methods included from Stackable::Meta
#build_exemplars, #enumerate_exemplars, #identity_param
Methods included from FlattenedIvars
#flattened_ivars, #flattened_ivars_equal?
Methods included from Stackable
Constructor Details
#initialize(*args) ⇒ BeginNode
Returns a new instance of BeginNode.
2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 |
# File 'lib/redparse/node.rb', line 2140 def initialize(*args) @offset=args.first.offset @empty_ensure=@empty_else=@op_rescue=nil body,rescues,else_,ensure_=*args[1...-1] rescues.extend ListInNode if else_ else_=else_.val or @empty_else=true end if ensure_ ensure_=ensure_.val or @empty_ensure=true end replace [body,rescues,else_,ensure_] end |
Instance Attribute Details
#after_comma ⇒ Object
Returns the value of attribute after_comma.
2160 2161 2162 |
# File 'lib/redparse/node.rb', line 2160 def after_comma @after_comma end |
#after_equals ⇒ Object
Returns the value of attribute after_equals.
2160 2161 2162 |
# File 'lib/redparse/node.rb', line 2160 def after_equals @after_equals end |
#empty_else ⇒ Object (readonly)
Returns the value of attribute empty_else.
2159 2160 2161 |
# File 'lib/redparse/node.rb', line 2159 def empty_else @empty_else end |
#empty_ensure ⇒ Object (readonly)
Returns the value of attribute empty_ensure.
2159 2160 2161 |
# File 'lib/redparse/node.rb', line 2159 def empty_ensure @empty_ensure end |
Instance Method Details
#begin_parsetree(o) ⇒ Object
2203 2204 2205 2206 2207 2208 2209 |
# File 'lib/redparse/node.rb', line 2203 def begin_parsetree(o) #body,rescues,else_,ensure_=*self needbegin=(rescues&&!rescues.empty?) || ensure_ || @empty_ensure result=parsetree(o) needbegin and result=[:begin, result] unless result.first==:begin result end |
#image ⇒ Object
2164 |
# File 'lib/redparse/node.rb', line 2164 def image; '(begin)' end |
#lvalue ⇒ Object
2211 2212 2213 |
# File 'lib/redparse/node.rb', line 2211 def lvalue return nil end |
#non_empty ⇒ Object
2168 2169 2170 |
# File 'lib/redparse/node.rb', line 2168 def non_empty rescues.size > 0 or !!ensures or body end |
#op? ⇒ Boolean
2154 |
# File 'lib/redparse/node.rb', line 2154 def op?; false end |
#parsetree(o) ⇒ Object
2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 |
# File 'lib/redparse/node.rb', line 2179 def parsetree(o) result=parsetree_and_rescues(o) =begin should be something like this: limit=o[:quirks] ? 1 : result.size (0...limit).each{|i| result[i,1]=result[i][1..-1] if Array===result[i] and result[i][0]==:block } =end if o[:ruby187] and result.first==:begin result=result[1] else result=[:begin,result] unless result==[:nil]#||result.first==:begin end return result end |
#reducer_ident ⇒ Object
17430 17431 17432 |
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17430 def reducer_ident :BeginNode end |
#rescue_parsetree(o) ⇒ Object
2197 2198 2199 2200 2201 |
# File 'lib/redparse/node.rb', line 2197 def rescue_parsetree o result=parsetree o result.first==:begin and result=result.last unless o[:ruby187] result end |
#rip(p) ⇒ Object
318 319 320 |
# File 'lib/redparse/ripper.rb', line 318 def rip p p.on_begin rip_and_rescues(p) end |
#special_conditions! ⇒ Object
2166 |
# File 'lib/redparse/node.rb', line 2166 def special_conditions!; nil end |
#to_lisp ⇒ Object
2174 2175 2176 2177 |
# File 'lib/redparse/node.rb', line 2174 def to_lisp huh #what about rescues, else, ensure? body.to_lisp end |
#unparse(o = default_unparse_options) ⇒ Object
attr_accessor :lvalue
2216 2217 2218 2219 2220 |
# File 'lib/redparse/node.rb', line 2216 def unparse(o=) result="begin " result+=unparse_and_rescues(o) result+=";end" end |