Skip to content

Commit

Permalink
Merge pull request #61 from ydah/breaknextredo
Browse files Browse the repository at this point in the history
Implement Break, Next and Redo Node locations
  • Loading branch information
yui-knk authored Oct 2, 2024
2 parents 753928e + 3f08a5e commit 0d36179
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/ast_to_prism/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1022,21 +1022,23 @@ def convert_node(node, block: nil)
not_expected(node)
when :BREAK
nd_stts, = node.children
loc, keyword_loc = node.locations

Prism::BreakNode.new(
source, # source
convert_stts(nd_stts), # arguments
location(node), # keyword_loc
location(node) # location
location(keyword_loc), # keyword_loc
location(loc) # location
)
when :NEXT
nd_stts, = node.children
loc, keyword_loc = node.locations

Prism::NextNode.new(
source, # source
convert_stts(nd_stts), # arguments
null_location, # keyword_loc
location(node) # location
location(keyword_loc), # keyword_loc
location(loc) # location
)
when :RETURN
nd_stts, = node.children
Expand All @@ -1050,9 +1052,12 @@ def convert_node(node, block: nil)
location(node) # location
)
when :REDO
loc, keyword_loc = node.locations

Prism::RedoNode.new(
source, # source
location(node) # location
source, # source
location(keyword_loc), # keyword_loc
location(loc) # location
)
when :RETRY
Prism::RetryNode.new(
Expand Down

0 comments on commit 0d36179

Please sign in to comment.