Skip to content

Commit

Permalink
Fix termination node. Distinction between a variable const and a digi…
Browse files Browse the repository at this point in the history
…t cause term(-1) to be incorrectly interpreted.

FINE := -1
.term(FINE)
interprets fine, but
.term(-1)
wasn't working.
  • Loading branch information
kobbled committed Jul 20, 2021
1 parent 7863548 commit d610dca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/tp_plus/nodes/termination_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def eval(context)

case @valuex
when DigitNode
s += "#{@valuex.eval(context)}"
val = @valuex.eval(context)
if val[0] == "(" # negative
s = "FINE"
else
s += "#{val}"
end
when VarNode
if @valuex.constant?
val = @valuex.eval(context)
Expand Down
4 changes: 3 additions & 1 deletion test/tp_plus/test_interpreter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,8 @@ def test_motion_arc
arc_move.to(p3).at(200, 'mm/s').term(100)
arc_move.to(p4).at(200, 'mm/s').term(100)
arc_move.to(p5).at(200, 'mm/s').term(FINE)
linear_move.to(p6).at(200, 'mm/s').term(FINE)")
linear_move.to(p6).at(200, 'mm/s').term(FINE)
linear_move.to(p6).at(200, 'mm/s').term(-1)")

assert_prog " ;\n" +
" ;\n" +
Expand All @@ -1909,6 +1910,7 @@ def test_motion_arc
"A P[3:p3] 200mm/sec CNT100 ;\n" +
"A P[4:p4] 200mm/sec CNT100 ;\n" +
"A P[5:p5] 200mm/sec FINE ;\n" +
"L P[6:p6] 200mm/sec FINE ;\n" +
"L P[6:p6] 200mm/sec FINE ;\n"
end

Expand Down

0 comments on commit d610dca

Please sign in to comment.