You are browsing as a guest. Sign up (or log in) to start making projects!

RenanLang

  • 7 Devlogs
  • 15 Total hours

An stack-based assembly like language, written in C++

Open comments for this post

1h 47m 40s logged

Devlog 07

FINALLY I DEBBUGED THIS THING

So i was having a weird bug with the Jump instruction. I first thought maybe is endiannes opr something. I passed howurs on the paper trying to understand how the stack would be compressed and decompressed. At the end i searched if the bitwise operations changes with the endiannes. I read that no so all this effort was not applied.

Then i corrected it and it still not working. I debugged with the GNU debugger (GDB) and learned a lot about it. The bug was that in the label mapping i was changing 2 times the byteoffset when expanding a string litteral and the label setting. So i fixed that and it worked just as fine!

I think it is almost ready for shipping. I just need to make some adjustments with security to prevent the user accessing invalid memory. XD

0
0
4
Open comments for this post

4h 8m 21s logged

Devlog 06

IMMM tired :(

I took the tripple of the time i thought i would do. I added the label system to the compiler but i needed to re-write all teh compiling logic. I’ve drawn on the paper 4 times trying to see with a solution to map the bytecode addresses before actually compiling and failed those 4 times.

I asked AI to know how could i implement this and it suggested adding a byteoffset, and then i did that, i’m not happy of needing that.

Now the last things that the language needs to be complete is to improve the error system, improve the code quality, maybe add an opcode to read user input.

0
0
9
Open comments for this post

2h 55m 43s logged

Devlog 05

THIS WAS ANNOYING
I had a lot of headache just writing this lexer. Firstly i thought about studying and it helped, but was confusing what exactly the lexer should take as input and output.

As in modern compilers it is common to have this separation and i want to add this functionality to implement labels i coded it. The code is just awful, the error handling and the finite state machine are kinda bad.

But i think the interface is good enough so in the future i can make this code more mantainable and stuff. I also think i’m understanding more how to read documentation correctly without AI helping me.

Now the app will be able to receive strings instead of manually pushing values.
Hope y’all like it!
(Note: I did not implemented the glue on the compiler. The lexer is isolated by now because i will need to re-write the code generation in order to connect the lexer as the first ‘middleware’ if you can call that way)

0
0
12
Open comments for this post

1h 40m 29s logged

Devlog 04

Added JMP Instructions!
So finally the language is turing complete. It has complete instructions, conditions, loops and so on. But it is a pain to code in this language so i’ll add some syntax sugar such as JMP_LABEL like instructions.

I didn’t added this later because i actually need to refactor the code. The app dont actually know which is the line address that it is compiling and i need to divide responsabilities such as an normal compiler (lexer and parser).

This will took a time but it is nice to see the things working. “Make it work” as said by Kent Beck is complete i just need to make it right and then make it fast.

0
0
21
Open comments for this post

39m 40s logged

Devlog 03

Comments and stack underflow detection!

So i added the comments feature and a stack underflow handling. Firstly i decided to use c++ exceptions because barelly used this c++ feature. But i thought it could be weird as exceptions usually tend to be avoided to performance issues and be more like a feature of C++ and not of my language. So i used AI to question and yes it was a bad decision, so i switched to IF statements. (I asked, the code was not coppied or anything)

Also i am very happy to open cppreference (this absolute monster documentation) and find that substrings searching in C++ are not complicated with iterators 🙏

0
0
39
Open comments for this post

1h 37m 14s logged

Devlog 002

I started to develop the virtual machine! It has no complete commands yet but it can pop and manipulate the stack as it wants. It can interpret the commands PUSH ADD PRINT and HALT.

I am going to suffer a little by handling all edge casesm such as trying to pop the stack even when it is already empty.

I’ll fix this later. As seen on the video, it can sum the numbers. I plan to add the Hello world example (it need to exist!) and adding more functions such as input taking, jumps and loops.

0
0
8
Open comments for this post

2h 17m 40s logged

Devlog 01

Ok! So i was bored in a time so i decided that write a language would be cool. It is a fast project but kinda hard so i started with that in midn

First i opened draw.io just for sketching a liitle architecture,

I wrote:
The CLI usage
The File Reader module (Working as seen on screenshot!)
The basis for the compiler
The Initial OPCODE table

But i still need to write a tokenizer and think better in what opcodes i should implement. I want it to be fast and not really fancy. (The screenshot shows the dump of the main file because i forgot to write an example)

0
0
2

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…