The first look of the interpretor
-
@toxibunny thanks for the kind words if you want to have a deeper understanding feel free to contact me
-
This is a very interesting project you have here. I too am working on a similar project. May I ask your method of approach? Are you translating your code to the FUZE4 language? Or are you building a Virtual Machine that will run your code?
-
@LucasJG25 so you go trough the entire code and then you can call fuze code. I mean i didnt finished it quite well
-
So then you are interpreting to fuze code. I see, i chose to compile mine to bytecode. Which is then run on the vm.
-
@LucasJG25 I mean you can go trough the code and then decide what to do without building an vm over it. Because a vm takes runtime. As i said with every abstraction layer you take away runtime
-
@LucasJG25 how do you built the lexer ?
-
The lexer only has a couple of functions. Scan the source code, check each character char by char, combine characters to form keywords that it recognizes and if it encounters a character it does not recognize throw an error, the lexer also needs to look ahead without consuming the character or moving the scanner. Then spit out tokens which can be keywords or terminals (single characters).
I have a small Recursive Descent Parser that I recently made in FUZE4 where I used a lexer to scan a string containing math expressions such as "4+5-2+5"
Here's the program: NXVWBDND9KHopefully this helps. And if you want more info. I'd suggest looking up BNF (Backus Naur Form), I use this for parsing and creating a Recursive Descent Parser, also check out crafting interpreters which can be found on google.
-
@LucasJG25 how do you deal with saving variables do you make them in 2 arrays
One is name
And one is valueAnd the postion is equal
-
Well, my method wouldn't really be of any use since I'm focusing on a vm implementation. You see if I were to make a Python interpreter I'd compile it to my vm's assembly code. So for example
Python:
var = 1My assembly code:
var:
.word #0x1main:
LDA (var)So that's how I would do it in my case. This delves into code generation which is the last step of a compiler.
-
Thats interesting
-
@LucasJG25 thanks I am trying to understand your code I downloaded your program
-
@petermeisenstein Nice, no problem at all. I'm also currently working on the assembler for the VM which I already made in FUZE. I can post the download code for it when I'm done.
-
So this is the concept for my new programming language everything seperated by line i just write the interpretor in python and then maybe in fuze
Translation:
Great Man
You are so cool
I mean this for real
-
No problem. Glad I could help.
-
This were just example texts but you are real cool dude.
So why i choose a programming language where i have to interprete everything line by line
?Because its making writing the parser much more easier
-
Interesting. I'm actually wrtiing the same thing in FUZE. Where the user can only write one line of code at a time.
-
With this code you declare a variable called a
With the value 100And after this you print Hello There
The end keyword is for stoping endless loops its more for the interpretor
-
@LucasJG25 I dont want to go through an entire input and then deciding what its actual is
-
I see. That's an interesting way to parser your code.
-
I need to go now. But it was nice talking with you. Keep me updated on your progress. It would be nice to see more.