Skip to content

Commit

Permalink
Merge pull request #57 from ydah/andor
Browse files Browse the repository at this point in the history
Implement And/Or Node locations
  • Loading branch information
yui-knk authored Oct 2, 2024
2 parents a9aab84 + efd798b commit d829112
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
24 changes: 12 additions & 12 deletions lib/ast_to_prism/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1176,25 +1176,25 @@ def convert_node(node, block: nil)
)
when :AND
nd_1st, nd_2nd = node.children
loc, operator_loc = node.locations

# (source, left, right, operator_loc, location)
Prism::AndNode.new(
source,
convert_node(nd_1st),
convert_node(nd_2nd),
null_location,
location(node)
source, # source
convert_node(nd_1st), # left
convert_node(nd_2nd), # right
location(operator_loc), # operator_loc
location(loc), # location
)
when :OR
nd_1st, nd_2nd = node.children
loc, operator_loc = node.locations

# (source, left, right, operator_loc, location)
Prism::OrNode.new(
source,
convert_node(nd_1st),
convert_node(nd_2nd),
null_location,
location(node)
source, # source
convert_node(nd_1st), # left
convert_node(nd_2nd), # right
location(operator_loc), # operator_loc
location(loc), # location
)
when :MASGN
not_supported(node)
Expand Down
8 changes: 0 additions & 8 deletions spec/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -897,28 +897,20 @@ def test_code(code)

describe "and" do
it "tests" do
pending "operator_loc is not supported"

test_code("1 && 2")
end

it "tests" do
pending "operator_loc is not supported"

test_code("1 and 2")
end
end

describe "or" do
it "tests" do
pending "operator_loc is not supported"

test_code("1 || 2")
end

it "tests" do
pending "operator_loc is not supported"

test_code("1 or 2")
end
end
Expand Down

0 comments on commit d829112

Please sign in to comment.