A finite while loop succeded:
var g := 5; while (g) g -= 1;
I'm steadily moving forward.
Next I'll fix my compiling which still doesn't support the 'if' conditional statement.
#programming #languageprogramming #doitmyself
Now I see that it's too hard to both execute and compile at the same time, so my #assembly is still in bits and pieces, but it slowly takes some shape.
In the mean time I continue with the 'while' loop.
#assembly #doitmyself #languageprogramming #programming #cpp
It was a lot of work to convert the std::vector to mmap(), but it's done now! Now I have a little problem with con/destruction, as is often the case in #cpp: when pushing smth to the stack I need to use the placement new:
sp --; new (sp) Expression{...};
Otherwise operator= tries to destruct the dummy-initialized std::string inside Expression.
And also I need to destruct Expression if I don't want memory leaks from the constructed std::string.
#cpp #programming #languageprogramming #doitmyself #diy
Should I use a kernel-handled memory arena for my language's stack now, or later?
I will need it any way, when #compiling to #assembly.
I mean using MAP_GROWSDOWN and MAP_STACK flags for mmap(2) syscall.
[1/2] #programming #languageprogramming #doitmyself #diy #askfedi
#compiling #assembly #programming #languageprogramming #doitmyself #diy #askfedi
Local variables done!
And also I'm entering the 3rd phase of my source structure: I'm breaking smaller, single-purpose functions out of my main loop. It makes the code clear and allowes to call these fcns from different parts of my program. And it's another step to make an interpreted language compilable... ;)
#programming #languageprogramming #doitmyself #diy
The next thing in my interpreted #programming language will be local variables, since the 'if' works. I can either leave the object definition on the interpreter's stack or have them defined outside the stack, associated with the block in which they're defined.
#programming #languageprogramming #diy #doitmyself
@rmgr Nice. I'm also programming my language. It has classical in-order operations, so my stack is a bit more hidden from the user (ok, actually programmer), but still I love my stack. It solves all my problems and is both easier too use and more efficient than recursivity. Recursive solutions use the machine code stack which I can't control as much as the structure I've designed myself for this perticular purpose.
Good luck! Have fun!
#programming #software #languageprogramming #diy #doitmyself
#programming #software #languageprogramming #diy #doitmyself