D2lang
D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
Install / Use
/learn @dplassgit/D2langREADME
d2lang
D2 (d2lang) is a strongly-typed, statically-typed, (mostly) type-inferred compiled language. Its syntax draws from C, Java and Python.
The D2 compiler currently compiles to X64 assembly language only. It uses
nasm and gcc to assemble and link, respectively, to Windows executables.
There are hooks to support other architectures; the intermediate language is (mostly) target-agnostic and a 8085 backend is partially implemented.
See the overview for a more comprehensive description of the types, control structures, operators and statements in D2.
NOTE: D2 is not related in ANY way to "The D Programming Language" except by coincidence of name.
<tt>A <a href="http://www.plasstech.com/a-plass-program">PLASS</a> Program</tt>
Contributing
See the contributor's guide.
Installing
The first 4 are required:
Running Tests
Run bazel test ... from the root directory.
Running the compiler
See docs/running.md.
Caveats
Only compiles to Intel x64. Only links against the Windows version of the gcc
C Runtime Library. Can only use nasm and gcc.
There are various bugs.
Language sample
Canonical hello world:
println "Hello world"
// Ported from toy (http://www.graysage.com/cg/Compilers/Toy/hanoi.toy)
PEGS = ["", "left", "center", "right"]
printPeg: proc(peg: int) {
print PEGS[peg]
}
hanoi: proc(n: int, fromPeg: int, usingPeg: int, toPeg: int) {
if n != 0 {
hanoi(n - 1, fromPeg, toPeg, usingPeg)
print "Move disk from "
printPeg(fromPeg)
print " peg to "
printPeg(toPeg)
println " peg"
hanoi(n - 1, usingPeg, fromPeg, toPeg)
}
}
n = 5 // defines global
hanoi(n, 1, 2, 3)
See more samples
Why did I build D2?
See docs/history
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate 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
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
