Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dplassgit/d2lang
D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
https://github.com/dplassgit/d2lang
compiler language programming-language
Last synced: 24 days ago
JSON representation
D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
- Host: GitHub
- URL: https://github.com/dplassgit/d2lang
- Owner: dplassgit
- License: mit
- Created: 2021-05-02T21:15:25.000Z (over 3 years ago)
- Default Branch: trunk
- Last Pushed: 2024-05-22T23:59:23.000Z (8 months ago)
- Last Synced: 2024-05-23T00:22:20.605Z (8 months ago)
- Topics: compiler, language, programming-language
- Language: Java
- Homepage:
- Size: 15.1 MB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 47
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# d2lang
D2 (d2lang) is a strongly-typed, statically-typed, inferred-type 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](docs/overview.md) 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"](https://dlang.org/)
except by coincidence of name.**A PLASS Program
## Contributing
See the [contributor's guide](CONTRIBUTING.md).
### Installing
The following 4 are required:
1. [bazel](https://github.com/bazelbuild/bazel)
2. [nasm](https://www.nasm.us/)
3. [gcc](https://gcc.gnu.org/install/binaries.html)
4. Java 11 or higher
5. Optional: Eclipse and git bash shell (mingw64)
### Running Tests
Run `bazel test ...` from the root directory.
## Running the compiler
See [docs/running.md](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](https://github.com/dplassgit/d2lang/labels/bug).
## Language sample
Canonical hello world:
```
println "Hello world"
```[Tower of Hanoi](samples/hanoi.d)
```
// 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](samples)
## Why did I build D2?
See [docs/history](docs/history.md)