Sugar.jl
Sugar coating Julia's many ASTs
Install / Use
/learn @SimonDanisch/Sugar.jlREADME
Sugar
Library for working with ASTs, Lambdas and lowered code.
Most important function:
using Sugar
function controlflow_1(a, b)
if a == 10
x = if b == 22
7
else
8
end
for i=1:100
x += i
x -= 77
if i == 77
continue
elseif i == 99
break
end
end
return x
else
return 77
end
end
Sugar.sugared(controlflow_1, (Int, Int), code_lowered)
This will return:
quote
NewvarNode(:(_4))
if _2 == 10
if _3 == 22
_7 = 7
else
_7 = 8
end
_4 = _7
SSAValue(0) = (Main.colon)(1,100)
_5 = (Base.start)(SSAValue(0))
while !((Base.done)(SSAValue(0),_5))
SSAValue(1) = (Base.next)(SSAValue(0),_5)
_6 = (Core.getfield)(SSAValue(1),1)
_5 = (Core.getfield)(SSAValue(1),2)
_4 = _4 + _6
_4 = _4 - 77
if _6 == 77
continue
end
if _6 == 99
break
end
end
return _4
end
return 77
end
There are all sorts of functions to e.g. remove the Slots etc. More documentation for other functionality will follow!
Installation:
Pkg.add("Sugar")
Related Skills
node-connect
344.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
99.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
