Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    The first look of the interpretor

    Work In Progress
    9
    79
    13829
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      LucasJG25 last edited by

      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: NXVWBDND9K

      Hopefully 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.

      P 2 Replies Last reply Reply Quote 2
      • P
        petermeisenstein F @LucasJG25 last edited by

        @LucasJG25 how do you deal with saving variables do you make them in 2 arrays
        One is name
        And one is value

        And the postion is equal

        1 Reply Last reply Reply Quote 0
        • L
          LucasJG25 last edited by

          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 = 1

          My assembly code:
          var:
          .word #0x1

          main:
          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.

          P 1 Reply Last reply Reply Quote 4
          • P
            petermeisenstein F last edited by

            Thats interesting

            1 Reply Last reply Reply Quote 1
            • P
              petermeisenstein F @LucasJG25 last edited by

              @LucasJG25 thanks I am trying to understand your code I downloaded your program

              L 1 Reply Last reply Reply Quote 0
              • L
                LucasJG25 @petermeisenstein last edited by

                @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.

                P 1 Reply Last reply Reply Quote 1
                • P
                  petermeisenstein F @LucasJG25 last edited by

                  @LucasJG25 !15964820676682495057371688133642.jpg

                  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

                  1 Reply Last reply Reply Quote 1
                  • L
                    LucasJG25 last edited by

                    No problem. Glad I could help.

                    P 1 Reply Last reply Reply Quote 0
                    • P
                      petermeisenstein F @LucasJG25 last edited by

                      @LucasJG25

                      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

                      1 Reply Last reply Reply Quote 0
                      • L
                        LucasJG25 last edited by

                        Interesting. I'm actually wrtiing the same thing in FUZE. Where the user can only write one line of code at a time.

                        P 2 Replies Last reply Reply Quote 0
                        • P
                          petermeisenstein F @LucasJG25 last edited by

                          @LucasJG25 !15964832658395516373321992406780.jpg

                          With this code you declare a variable called a
                          With the value 100

                          And after this you print Hello There

                          The end keyword is for stoping endless loops its more for the interpretor

                          1 Reply Last reply Reply Quote 0
                          • P
                            petermeisenstein F @LucasJG25 last edited by

                            @LucasJG25 I dont want to go through an entire input and then deciding what its actual is

                            1 Reply Last reply Reply Quote 0
                            • L
                              LucasJG25 last edited by

                              I see. That's an interesting way to parser your code.

                              1 Reply Last reply Reply Quote 0
                              • L
                                LucasJG25 last edited by

                                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.

                                P 1 Reply Last reply Reply Quote 0
                                • P
                                  petermeisenstein F @LucasJG25 last edited by

                                  @LucasJG25 ok but it will be a long time before this will also made on fuze

                                  1 Reply Last reply Reply Quote 0
                                  • P
                                    petermeisenstein F @LucasJG25 last edited by

                                    This post is deleted!
                                    1 Reply Last reply Reply Quote 0
                                    • P
                                      petermeisenstein F last edited by

                                      Hey Guys its me David
                                      Time has past and I went back to Python.
                                      https://github.com/Davidthemastercoder/Hightodown Thats my current program now.
                                      But when I watched a Video abou regular expressions and infinite state machines i imediatly tried it out in fuze i got a god result with some strange behaviour.
                                      In the moment i am really interested in parsers and lexical analisis.
                                      When I see my code who I have written once i must admit that this code is garbage.
                                      I dont had enough and i still dont have enough knowledge to write a full functional interpretor but I try to teach me things.
                                      SO WHEN will I restart here ?
                                      I am not sure i would need to rewrite a lot of code.
                                      Fuze doesnt make it easy to make lexical analysis but I have seen some wonderful projects from you guys.
                                      Keep what you are doing.
                                      When I understand how Lexical analysis and Tokenizing and Regex and Parsing and so on works and when I am able to do it in python. I will come back to fuze maybe. Thats also a reason why i dont use Things like Regex i mean i tried it out in python but I want to do much my own so that i can come back to fuze and use my code just transfering it to fuze.
                                      Maybe I will implement an own little language with smaller Instruction set.

                                      I wish you a nice day
                                      David

                                      1 Reply Last reply Reply Quote 4
                                      • L
                                        LucasJG25 last edited by LucasJG25

                                        @petermeisenstein Happy you're back!!

                                        I'd like to advise that you take a look at
                                        http://craftinginterpreters.com/#:~:text=Crafting Interpreters A handbook for making programming languages.,gritty details like bytecode representation and garbage collection.

                                        It's going to help you understand the lexer and parser and will also help you understand the different ways to create your interpreter.

                                        I'd also advise you to check out Nand2Tetris as this will also teach you how to build a lexer and parser as well.

                                        https://www.nand2tetris.org/

                                        P 1 Reply Last reply Reply Quote 2
                                        • P
                                          petermeisenstein F @LucasJG25 last edited by

                                          @LucasJG25 Thank you

                                          1 Reply Last reply Reply Quote 1
                                          • First post
                                            Last post