Closed Slapparoo closed 3 months ago
Thanks for the feedback!
That's an interesting bug with the 1+1;
it shouldn't explode like you say, but also I'm not sure what it should do. When I get to optimising the compiler it would get optimised away and nothing would happen. Thus I'm quite happy with it erroring out for the moment as it is in essence a NOP
.
With U64 a = 99;
yes, this is because the value is lingering in RAX
and "global scripting" is actually an initiliaser function; mainFn
that is run in main:
(you can see this by running hcc -S U0 Exit(I64 exit_code);
should be used instead for a consistent and stable exit code.
I'm still very actively working on this project and there are somethings that need to be done before trying to do a walk through. When I've got to that I'll update the documentation and also make some more developer oriented documentation as to how this compiler works. The code presently, in my view, is fairly well separated. There is a lexer in lexer.c
for creating all of the tokens an ast.c
file which houses all of the ast's (can be viewed with hcc -ast parser.c
is a simple recursive decent parser looking ahead by 1, I split this to a couple of files which I'm not sure was a good idea. Then x86.c
recurses through the AST outputting a temporary text file which is fed into gcc
to assemble in main.c
. Those are the core files, the rest are datastructures and utilities.
Thanks! I'm still working on this, using it as a learning project and part of my master's thesis, so I need to maintain control until that's completed. I've released it in it's current state as it is fairly usable. There are some aspects of it like writing an optimiser, ARM support, a linker, maybe class methods etc... will be things I'll be implementing. As a consequence of these objectives large parts will get completely re-written.
I appreciate your suggestion for a walkthrough and your willingness to contribute. Better documentation and tasks for contributors will come, but it's a bit premature now as significant changes are expected in the medium term.
I hope your Masters goes well, the work you have done so far is great.
Please don't optimise it out its such a good feature in templeOS, where you can use the CLI as a calculator (amongst other things)
I'll start by saying great work.
One thing I have found is when doing 'scripting' with math constants i'e
1+1;
Its gets a compile error
parser.c:1365:ParseToplevelDef line 1: Identifier expected: got TK_PUNCT +
not an error but a great feature is that if I compile and run
U64 a = 99;
in bashecho $?
== 99 which is really good, I assume whatever is in RAX on exit is what the apps return code will be in bash. So I guess what ever the result is if it remains in RAX on exit that would be great for shell integration.Also I found your channel on twitch, living on the other side of the world I doubt I will ever catch a live stream, but I would be interested if you could do a code walk through, basically going through all the source for the compiler?
I am happy to chip in a bit and help where I can, if you wanted to set up some tasks that can be picked from, I would be happy to pick some up.