Skip to content

Commit 0fec596

Browse files
committed
Update readme and documentation
1 parent 915a5d7 commit 0fec596

File tree

4 files changed

+58
-50
lines changed

4 files changed

+58
-50
lines changed

README.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MLang
22

3-
MLang is my strictly typed programming language with full type inference that compiles to LLVM. The language uses a custom recursive descent parser as the front-end and targets LLVM JIT as the backend. The project is tested with the google test framework. This is a multiplatform project targeting both Linux and Windows.
3+
MLang is my strictly typed programming language with full type inference that compiles to a custom byte code. This project is hand crafted with zero dependencies. The language uses a custom recursive descent parser as the front-end and targets a custom byte code vm as the backend. This is a multiplatform project targeting both Linux and Windows.
44

55
This language is build solely for fun and educational purposes, so maybe you should not use this in production 🐴
66

@@ -22,12 +22,11 @@ You can download the executables for Windows and Linux in the [release section](
2222
- [x] Linux support
2323
- [x] Windows support
2424
- [x] Error reporting
25-
- [ ] Heap allocation
25+
- [x] Structs (on the heap)
26+
- [x] C-calls (FFI) to dynamic libraries
2627
- [ ] Arrays
27-
- [ ] Pointers
2828
- [ ] String type
2929
- [ ] Printing
30-
- [ ] Structs
3130
- [ ] Closures
3231

3332
## Examples
@@ -82,6 +81,37 @@ let x = 3 + 10 + 6 / 3 - 2 * 5;
8281
ret x; # is 5
8382
```
8483

84+
```
85+
# FFI to dynamic c libraries (libtest.so)
86+
let mul = extern test::mul(a: Int, b: Int): Int;
87+
let result = mul(5, 3);
88+
```
89+
90+
```
91+
# Structs
92+
93+
struct Point {
94+
let x: Int;
95+
let y: Int;
96+
}
97+
98+
struct Line {
99+
let begin: Point;
100+
let someInt: Int;
101+
let end: Point;
102+
}
103+
104+
let l: Line;
105+
l.begin.x = 3;
106+
l.begin.y = 4;
107+
108+
l.end.x = 8;
109+
l.end.y = 9;
110+
111+
ret l.begin.x + l.end.y;
112+
```
113+
114+
85115
## Error reporting
86116

87117
Following you find an example on how parsing errors are reported to the user
@@ -99,9 +129,8 @@ Consider adding a semicolon to the end of the statement
99129

100130
## Dependencies
101131

102-
- LLVM
103-
- GTest
132+
None
104133

105134
## Getting started
106135

107-
You can find an installation guide in [INSTALL.md](/INSTALL.md)
136+
If you want to build this yourself, refere to this guide [INSTALL.md](/INSTALL.md)

TODO.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Roadmap
22

3-
- Pointer, Alloc, Free
4-
5-
- Array
6-
7-
- Structs
8-
3+
- Arrays
94
- Function overloading (name, number of parameters, type of parameters)
10-
11-
- Vector
12-
13-
- String / Printing
14-
5+
- Floats
6+
- Strings
7+
- C-Strings
8+
- terminal IO
9+
- file IO
1510
- Fix recursion example. Get return type of non recursive
1611
return and use as override. Ignore recursive return.
17-
12+
- Member functions for structs
13+
- Garbage collection for heap objects (structs)
14+
- Blob type (for raw memory)
15+
alloc8(size), get(blob, idx), set(blob, idx)
16+
synatx sugar for get, set with []
17+
(for arrays, strings, maps)

src/executer/ExternalFunctions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void Arguments::clear() {
4040

4141
#ifdef WIN // Windows
4242

43+
// TODO: Implement for windows with LoadLibrary and GetProcAddress
44+
4345
ExternalFunctions::ExternalFunctions() = default;
4446

4547
size_t ExternalFunctions::add(const std::string& library, const std::string& functionName) {

src/mains/Tests.cpp

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -280,46 +280,23 @@ void suiteTestfiles(){
280280
testFile("mfiles/type_annotation.m");
281281
testFile("mfiles/struct.m");
282282
testFile("mfiles/struct_nested.m");
283-
284-
// TODO: Blob
285-
// testFile("mfiles/blob.m");
286-
287-
// TODO: Extern functions
288283
testFile("mfiles/extern.m");
289-
}
290284

291-
int main() {
292-
suiteTestfiles();
293-
testLibrary();
294-
testExecutorData();
295-
// Structs:
296-
// member functions for structs
297-
298-
// Garbage collection
299-
300-
// blob type (alloc8(size), get(blob, idx), set(blob, idx)):
285+
// TODO: blob type (alloc8(size), get(blob, idx), set(blob, idx)):
301286
// synatx sugar for get, set with []
302-
303-
// Use blob and struct to implement:
304-
// arrays
305-
// strings
306-
// maps?
307-
308-
// C-Strings / strings
309-
310-
// c ffi, interop (dlopen / dlsym) and (LoadLibrary / GetProcAddress):
311-
// terminal IO
312-
// file IO
313-
314-
// Other types:
315-
// floats
316-
// bools
287+
// testFile("mfiles/blob.m");
317288

318289
// TODO: Type inference not working for recursive functions
319290
// We should skip recursive calls and find the terminating return.
320291
// Assume that type for the recursive calls and see if this passes
321292
// without conflicts.
322293
// testFile("mfiles/recursion.m");
294+
}
295+
296+
int main() {
297+
suiteTestfiles();
298+
testLibrary();
299+
testExecutorData();
323300

324301
return 0;
325302
}

0 commit comments

Comments
 (0)