Skip to content

Commit

Permalink
Lua writer: Convert not (x == y) to x ~= y
Browse files Browse the repository at this point in the history
  • Loading branch information
minoki committed Sep 9, 2024
1 parent 3bc588a commit 720b4a1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/lua-syntax.sml
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,32 @@ struct
@ Fragment (" " ^ luaop ^ " ") :: paren prec exp2
}
end
| doExp
(LuaSyntax.UnaryExp
(LuaSyntax.NOT, LuaSyntax.BinExp (LuaSyntax.EQUAL, exp1, exp2))) =
let
val exp1 = doExp exp1
val exp2 = doExp exp2
val prec = 10
in
{ prec = prec
, exp = paren prec exp1 @ Fragment " ~= " :: paren (prec - 1) exp2
}
end
| doExp
(LuaSyntax.UnaryExp
( LuaSyntax.NOT
, LuaSyntax.BinExp (LuaSyntax.NOTEQUAL, exp1, exp2)
)) =
let
val exp1 = doExp exp1
val exp2 = doExp exp2
val prec = 10
in
{ prec = prec
, exp = paren prec exp1 @ Fragment " == " :: paren (prec - 1) exp2
}
end
| doExp (LuaSyntax.UnaryExp (unOp, exp)) =
let
val unOp =
Expand Down

0 comments on commit 720b4a1

Please sign in to comment.