Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oakfang/demilang
A basic attempt at a haskell-interpreted language
https://github.com/oakfang/demilang
Last synced: 20 days ago
JSON representation
A basic attempt at a haskell-interpreted language
- Host: GitHub
- URL: https://github.com/oakfang/demilang
- Owner: oakfang
- License: mit
- Created: 2016-05-18T14:46:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-05-29T15:45:09.000Z (over 8 years ago)
- Last Synced: 2024-11-09T18:19:26.243Z (3 months ago)
- Language: Haskell
- Size: 37.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DemiLang
A basic attempt at a haskell-interpreted language## Building
```
git clone ...
cabal install
cabal build
alias demi=./dist/build/demi/demi.exe # used on windows GitBash
```## Usage
```
Usage:
demi.exe parse -- print AST symbols (use for exec)
demi.exe (run) -- parse and run the file on the fly
demi.exe exec -- run a pre-parsed AST symbols file
demi.exe -- run demi in stdin interpreter mode
```## Modules
You can import modules relative to the importing modules, like so:```go
// main.dm
import "foo.dm"; // this imports the file "foo.dm" from the same directory main.dm is
```You can also install demiurges (Demi packages) using (urge)(https://github.com/oakfang/urge),
running `urge install /`.Importing demiurges is done using this syntax (assuming the demiurge's name is Math, for example):
```python
import Math;
```Notice the lack of path and extension. This will import /urges/Math/main.dm.
*Note:* this time, the starting directory is the one you run `demi` from.
## Creating Demiurges
A demiurge is a github repo containing at the very list 2 files:- `main.dm` contains the file to be imported.
- `urge.json` is a JSON file containing at the very least a `name` property (in the above example, its value is `"Math"`), and maybe `deps`, which is a list of string in the format /`. These dependencies will be installed along with your demiurge.Done. Now anyone can install your demiurge!
## Demo code
```c
/*
Currently, stdlib contains:
print(ARG) => prints to stdout
read("int") => read an integer from stdin
read("bool") => read a boolean from stdin
read("str") => read a string from stdin
*/greet = fn(name) {
.print("Hello, " + name + "!");
};opFn = fn(x, op, y) {
if op == "+" return=x + y
else if op == "-" return=x - y
else if op == "*" return=x * y
else if op == "/" return=x / y
else {
.print("Unsupported operator")
}
};.greet("world");
.print("Enter first number:");
a = read("int");.print("Enter operator (+, -, *, /)");
op = read("str");.print("Enter second number:");
b = read("int");
.print(opFn(a, op, b));
```