Abstract Syntax Tree & Binary Operations - Programming Language From Scratch

Поділитися
Вставка
  • Опубліковано 17 лис 2024

КОМЕНТАРІ • 59

  • @Llamaful
    @Llamaful 2 роки тому +36

    This is the most exciting thing I’ve ever watched.

  • @NootNooter
    @NootNooter 10 місяців тому +5

    I finally understand precedence properly thanks to this video after many years of trying it myself

  • @lambdadotjoburg
    @lambdadotjoburg 10 місяців тому +4

    THE most important video ever produced on this topic!

  • @Jaxson_lang2
    @Jaxson_lang2 5 місяців тому +1

    I didn't understand anything at all but I followed you coding steps and I can say I have a great start on my coding language! I have never done anything like this before I am a Html5 person and I sometimes use python but never something like this when I ran the language in my power shell I was screaming literally. great tutorial!

  • @kygura
    @kygura 5 місяців тому +2

    This is a top tier computer science channel

    • @tylerlaceby
      @tylerlaceby  5 місяців тому

      You're too kind. Thanks for the kind words.

  • @SuboptimalEng
    @SuboptimalEng 2 роки тому +12

    Really liking the series and the way you explain things, great work 🔥

  • @luiza4142
    @luiza4142 2 роки тому +4

    I really liked the video content! I've been trying to find quality content about creating programming languages in youtube ​​for a few years now, but I couldn't find anything relevant, until a found your channel 🤩🤩🤩

  • @vinii2815
    @vinii2815 7 місяців тому +1

    thanks alot, i was stuck on expression parsing for the past 3 weeks

  • @florianvanbondoc3539
    @florianvanbondoc3539 Рік тому +4

    Amazing, I was wondering how its made!

  • @TheBusinessDude
    @TheBusinessDude 2 роки тому +4

    Guess I'm ready for part 4 lol

  • @tudorpop3579
    @tudorpop3579 Рік тому +3

    nice job! exactly what I was looking for

  • @angelos9800
    @angelos9800 4 місяці тому +1

    This is very interesting - but I have a slight question: I've noticed that at 31:29 you're adding another character in the while condition. Couldn't you just check the *type* of the token instead? If it's a binary operator then you can check that given that all binary operators are on the same level of prescidence we're handling.
    I've done this on my project as I'm going along and everything's working just fine.

    • @tylerlaceby
      @tylerlaceby  4 місяці тому

      The reason we handle this differently is because not all binary operators have the same precedence.
      Addition and Subtraction are lower than Multiplication, Division, and Modulus. However these are all higher precedence than Logical and Relational operators like OR, AND, Equals, Not equals, Less, Greater, and even bitwise or and bitwise and have different precedence.
      This is why it's handled this way. In this series I have made a good amount of fumbles. Some of the code could be more concise and less verbose. Also the approach I used to parsing is very primitive for the purpose of teaching.
      So I would always recommend finding multiple sources and reading source code for a language. I wish I could go into depth in everything but then I would be making 20 hours of videos just on the tokenizer lol.
      Anyway thanks for the comment and j.hooe you enjoy the series. I suggest checking out my more recent series on Pratt parsers and if you want more info lookup
      "Operator Precedence parsers & Pratt parsers". There are many great resources which go much deeper than myself xD.

    • @angelos9800
      @angelos9800 4 місяці тому

      @@tylerlaceby Thank you for the thoughtful response.
      Oh woops you're right, running "12 - 1^2" should output "11" but I get "121." I see, well, that makes sense now. I'll definitely check your new videos out once I'm done with this series. By the way, your series so far has been pretty good actually, I've been following along (using vanilla js and node instead of deno, lol) and while I had to google a few things here and there, I get what it does and I can do basic arithmetic.

  • @thandisibanda677
    @thandisibanda677 Рік тому

    I love this, helps me understand compilers

  • @TrimorphMC
    @TrimorphMC 2 роки тому +3

    the parser has always been the part I procrastinate most on, so I usually use a parser generator cuz it's faster and there's less to procrastinate. Of course, when my language is ready to progress I'll have to write a parser by hand :))

    • @tylerlaceby
      @tylerlaceby  2 роки тому +1

      Yea I’m the other way. I love the parser and procrastinate a lot with the interpreter xD

    • @tylerlaceby
      @tylerlaceby  2 роки тому +1

      However the bytecode generation and vm is really fun even if a bit tricky.

    • @TrimorphMC
      @TrimorphMC 2 роки тому

      @@tylerlaceby Yeah, working with bytes makes me feel very smart

  • @oglothenerd
    @oglothenerd 9 місяців тому +2

    Do I need EOF? Couldn't you just check the length?

    • @tylerlaceby
      @tylerlaceby  9 місяців тому +1

      For this series you could. However there may be reasons to check for EOF when dealing with multiple levels of lookahead

    • @oglothenerd
      @oglothenerd 8 місяців тому +1

      @@tylerlaceby Yeah, nevermind, I wrote a parser and I see how an EOF token is useful. It essentially allows me to always have a token to eat or get.

  • @Yellowcat98
    @Yellowcat98 3 місяці тому +1

    noticed that parsefloat isnt defined anywhere?
    edit:
    i later found out that its a js/ts function while i'm using c++ and std::stof is the equivalent

    • @tylerlaceby
      @tylerlaceby  3 місяці тому +1

      Yes there are a few functions in the global JavaScript scope which we may use. parseFloat and parseInt are amongst the most common. But I don't think there are many others I use.

  • @aakarshanraj1176
    @aakarshanraj1176 10 місяців тому

    that was really informative!

  • @rodrigofernandes6449
    @rodrigofernandes6449 Рік тому +2

    Will you cover how to make a transpiler? I want to make something like a vue file but transpile it to native web components. Any clue?

    • @tylerlaceby
      @tylerlaceby  Рік тому +1

      No plan on doing so. However I would suggest first taking a language like vue and translating it into JavaScript. Pick one feature and start there.
      If you start with one thing at a time it should become a bit easier. You can also use existing parsers and tools for JavaScript and HTML/ CSS parsers.

  • @ferhoodler
    @ferhoodler 8 днів тому

    Just asking is it good practice to use both snake case and camelcase ?? Or stick with one .

  • @r50142
    @r50142 Рік тому +1

    Invite link to the discord has expired. Also I suggest you also make a matrix room.

    • @tylerlaceby
      @tylerlaceby  Рік тому

      What’s a matrix room. Also I’ll fix the link ASAP. Thanks 🙏

  • @JPhantomYT
    @JPhantomYT Рік тому

    When testing my repl, I type in 10 but I keep getting this "Unexpected token found during parsing! { type: 7, value: "EndOfFile" }"

    • @tylerlaceby
      @tylerlaceby  Рік тому

      I can’t say as I don’t know how the logic was changed. I suggest comparing the differences in your code to mine.
      Feel free to join the discord server and post the code and your error in there and I can help

  • @rokasmuningis6840
    @rokasmuningis6840 7 місяців тому +1

    Just thought you might want to know - github link is outdated :) username is wrong (it's okay in later videos though)

  • @Bl0xxy
    @Bl0xxy 11 місяців тому +1

    damn i'm looking for a c++ tutorial. anybody finding one?

  • @rosan2160
    @rosan2160 7 місяців тому +1

    Github link is no longer working : (

    • @tylerlaceby
      @tylerlaceby  7 місяців тому +1

      Sorry about that.
      It’s GitHub.com/tlaceby

  • @parzer0
    @parzer0 2 роки тому +2

    This was a dope ass video!

    • @tylerlaceby
      @tylerlaceby  2 роки тому

      Haha glad you found it helpful

  • @lowercasebtwalso
    @lowercasebtwalso Рік тому +3

    vscode theme?

  • @artwork-studios
    @artwork-studios Рік тому +1

    i cant get source code 😅

  • @davidgari3240
    @davidgari3240 Рік тому +3

    I understand most of this, but every time he says "like so" or "simply" --- DRINK !

  • @11youngone11fj
    @11youngone11fj 6 місяців тому

    Deno is not working

  • @BGDMusic
    @BGDMusic 11 місяців тому +1

    ouch my brain
    good video tho

  • @about2mount
    @about2mount 10 місяців тому

    I have no clue what you are attempting without using C or C++ haha. No offence but you're heart is into it heavy duty.
    The whole point of having a Lexer is to make a syntax parse-able for and by the strtok() function in C or C++ to sequence calls to this function to split syntax strings into tokens, which are sequences of contiguous characters separated by any of the characters that are part of delimiters.
    A lexer takes a syntax and breaks it down by placing spaces between every special character and by grouping and preserving all keywords, user defined variable names, user defined strings. numeric mathematical groupings and does all of it for strtok() to work.
    Now by naming of all double characters(i.e. ==, !=, ++, --, = etc.) in order for a strtok()Token Stream in the C Languages to be able to parse everything in a more organized way. You must do the following:
    Doubles are defined so that they become one single token for each pair as example == would become EQEQ or ++ would become INCR for increment operator. Single characterss are easily managed by doing this also such as "=" as EQUAL, "(" as LPAREN, ")" as RPAREN etc.
    Precedence, States and Logical Orders are not for a Lexer to perform, they are for the Parser and are achieved by using Temporary State Switches(which are temporary variables) that store a type-defined numeric definition for look-a-head's to generate conditionally all the rules for your precedence, states and logical orders in you're new computer language.
    Node Traversals are only a fancy name and definition for managing Stately Switches and is all they are. So your managing basically optcode-states for the following which all have rules.
    Targets
    Definitions
    Assignments
    Terms(conditional if's else's)
    Operators
    Expressions
    Example of use:
    int
    --operater state--
    typedef optstate { MULT=1, DIV=2, ADD=4, SUB=5, etc. }
    --precedence state--
    typedef precstate { LPAREN=1, RPAREN=2, }
    if(tok[i]=="(" && tok[i+1]) {
    precstate=LPAREN;
    }
    You have the right heart and brains, so why not learn C or C++ and do this the correct way because all your doing is throwing out Organized Despair to those who follow you in blindness causing them to fall off the proverbial cliff of despair.
    You have the brains so do it son. Thanks and delete this as soon as you read it.

    • @tylerlaceby
      @tylerlaceby  10 місяців тому +1

      I use c & cpp for my own compiler actually. The point of this series is to teach the basics in a was to understand way.
      Just as we teach mathematics or any other topic In CS with a much more high level view than reality entails.
      Thanks for your input and enthusiasm however I will remain doing what I’m doing.