Commit Graph

43 Commits

Author SHA1 Message Date
r4
a706ea6a3f disallow use of declared variable in declaration expression 2021-12-28 12:11:04 +01:00
r4
0b2741f73f allow newline-padding of one-line if and else bodies 2021-12-26 19:23:42 +01:00
r4
cda56d5b9c allow for one-line if and else bodies without {} 2021-12-26 19:18:52 +01:00
r4
46e7487cad remove expression parser code redundancy 2021-12-26 15:06:33 +01:00
r4
18d6e7b7df add 'not equal' operator 2021-12-26 12:19:54 +01:00
r4
1f47b5e16c fix float precision loss bug 2021-12-26 11:59:01 +01:00
r4
dfe1ac90e8 add getln() function and calculator example
Runtime-allocated strings currently always leak memory, I will
definitely have to fix that.
2021-12-26 11:36:52 +01:00
r4
d8b470f0eb rename print() to putln() 2021-12-26 10:55:31 +01:00
r4
cf93109f1e IR optimization
IR optimization currently very basic, in fact it probably doesn't even
improve performance measurably.
2021-12-25 23:01:18 +01:00
r4
850dafbbc9 move preprocessor args into CPPFLAGS 2021-12-25 22:32:16 +01:00
r4
803368a264 remove unnecessary include 2021-12-25 14:10:53 +01:00
r4
b4c369e1d9 add sleep() function and improve Windows support
I could only test Windows support by compiling with gcc MinGW-w64 and
running with Wine.
2021-12-25 14:06:20 +01:00
r4
dd67a1bf5d reorganize examples 2021-12-25 12:45:27 +01:00
r4
b58810e822 better error messages 2021-12-25 12:32:52 +01:00
r4
f02dae603d unify printing + add basic strings 2021-12-25 12:16:06 +01:00
r4
92c4c5c991 Merge branch 'master' of https://git.nobrain.org/r4/lang 2021-12-23 22:26:55 +01:00
r4
9bd4d4e0c4 support for builtin functions with 0 args 2021-12-23 22:25:41 +01:00
r4
bb75b78a36 Update 'README.md' 2021-12-23 22:05:43 +01:00
r4
ca232fbf6a add mandelbrot example 2021-12-23 21:44:59 +01:00
r4
6bdc4e3210 add logical or and logical and 2021-12-23 21:42:09 +01:00
r4
d67008cfbf add char literals 2021-12-23 21:26:53 +01:00
r4
a0842424ec print not in IR 2021-12-23 21:08:01 +01:00
r4
84785dc3cf add boolean logic 2021-12-23 21:06:49 +01:00
r4
d185396a1c rename arith to binary 2021-12-23 20:10:02 +01:00
r4
97e8e32ebc add if and else, and fix nested loops (hopefully) 2021-12-23 19:58:00 +01:00
r4
ef63742015 reduce mallocs when calling functions 2021-12-23 17:00:57 +01:00
r4
7ae9ddaee9 multi-line expressions 2021-12-23 16:51:10 +01:00
r4
298883939b rewrite expression parser with parentheses 2021-12-23 15:56:12 +01:00
r4
052e78bf2e add pi example 2021-12-22 17:40:54 +01:00
r4
d7860fdac0 add VM 2021-12-22 17:23:24 +01:00
r4
5dd15ce9f1 add builtin functions 2021-12-22 16:09:52 +01:00
r4
41a5dba208 replace malloc with xmalloc 2021-12-22 13:10:00 +01:00
r4
b80e5a9c4e formatting 2021-12-22 12:57:14 +01:00
r4
e7f4773cba make while loop parsing more elegant
It is now possible to parse parts of the program and save the IR for
later addition. This is currently used for while loops but will also make other
control flow elements easier to implement in the future.
2021-12-22 12:52:16 +01:00
r4
a8be4540b1 fix segfault
So basically, I used i++ on a linked list instead of i->next. As if that
wasn't bad enough on its own, it even managed to somehow still work in the 2
test scenarios I gave it. Regardless, it is now fixed.
2021-12-21 18:38:52 +01:00
r4
9f339ed44d make while loops more efficient and improve expression parsing 2021-12-21 17:09:03 +01:00
r4
10d436107c very basic while loop 2021-12-21 15:02:53 +01:00
r4
61d5661b96 fix memory leak on error 2021-12-21 14:04:50 +01:00
r4
005309d1eb IR jmp and scopes 2021-12-21 13:59:08 +01:00
r4
6080901842 catch missing expression 2021-12-21 11:55:53 +01:00
r4
63af3e907b add assignment operator and unify memory pools
The unification of memory pools also fixed some memory leaks and
hopefully reduced the mallocs of identifier strings significantly by
giving them the same pool as the token stream.
2021-12-21 11:40:49 +01:00
r4
21694f98ac init 2021-12-21 01:18:22 +01:00
r4
ab1887c28d Initial commit 2021-12-21 01:16:55 +01:00