Making a COMPILER FROM SCRATCH in C | 001

Поделиться
HTML-код
  • Опубликовано: 21 окт 2024
  • Take a look as we begin working on a compiler. In a few hours, we get a basic, efficient lexer up and running, and begin to mock out the parsing stage. This is the start of a long compiler design playlist -- Watch live at / lens_r
    Source code: github.com/Len...
    Discord: / discord
    Donate: www.paypal.com...

Комментарии • 72

  • @z1adahmed
    @z1adahmed 13 дней назад +1

    i liked the brainstorming and how you think out loud with us

  • @coffeemaddan
    @coffeemaddan 2 года назад +35

    Well, there goes my weekend! I'll be following this avidly to see where it goes. Love the live coding, it's bringing back my memories of C, pointers and all the rest of it. Thanks for taking the time to post to RUclips, this lower level stuff keeps my interest in programming alive. I'd really enjoy seeing your compiler output the x86/64 assembly, but let's see... :)

  • @rodrigoelias1987
    @rodrigoelias1987 2 месяца назад +3

    The most impressive thing on this video is how this guy can hold his will of overengineer or overthink something. If it was me doing this live, I would be wondering how to implement automatic semicolon insertion without even deciding if the language would use semicolons to begin with.

  • @hackereports1128
    @hackereports1128 2 года назад +13

    Damn, RUclips recommendations be too accurate. Been thinking about doing something like this for a while. Will follow this series. Thanks

  • @chri-k
    @chri-k 3 месяца назад +4

    This might be quite useful!
    I'm currently also making a compiler in C and thus far the hardest part has been deciding on a good data structure to hold types.

  • @Pi7on
    @Pi7on 2 года назад +11

    First video of yours I watch.
    Your video style looks like a mix of tsoding and kling lol.
    I'm definitely gonna binge this series.

  • @_ab_6490
    @_ab_6490 Год назад +21

    I can't believe I watched three hours without skipping
    I did not feel bored, I hope that you will explain the C language, because the way you explain is wonderful
    I am not a native English speaker. I am from an Arab country. If you see any wrong word or my sentence is incorrect, I apologize for that.

    • @Lensr
      @Lensr  Год назад +13

      No need to apologize! Your English is much better than my Arabic :p
      I'm so glad you enjoyed!!
      If you have any specific questions, the discord is always available 👍

    • @_ab_6490
      @_ab_6490 Год назад +5

      @@Lensr In the last video, your pronunciation of the Arabic letters was correct👍

  • @darcgames6375
    @darcgames6375 4 месяца назад +13

    The fact that it took you so long to properly get the file size was painful because it took me just as long and you remonded me of that horrible time 😂😂

  • @_slier
    @_slier 2 года назад +12

    thumbs up just for the intro .. anyway really informative video.. really shed some light on how to construct compiler

    • @Lensr
      @Lensr  2 года назад +2

      I'm really glad you enjoyed! Thanks for watching :^)

  • @madcc09
    @madcc09 11 месяцев назад +4

    Awesome! Im following along in Assembly.

  • @mrinalyadav4261
    @mrinalyadav4261 2 месяца назад

    I am following your video, to make my first compiler(first project in c). Somewhere you said don't do copy pasta, but idk from where to begin with, so i thought i should watch your stream, i am learning a lot. after watching you make it, i will make sure after this i will make my own compiler.

  • @derektan6987
    @derektan6987 Год назад +5

    I may not be working on a compiler anytime soon, but this video inspired this CS student to chip at a first toy JSON parser in C (WIP). Funky thing is, I learned the hard way that circular references with header guards cause a mess of undefined typedefs... but that's another story. Thank you for the video, just subbed. 👍
    Update: it finally parses nested structures, yay!

  • @hinzster
    @hinzster Год назад +4

    77:23 - as I read somewhere many many years ago: My biggest Perl mistake was trying to learn Perl. Now I am punishing myself for this horrid mistake by trying to learn Perl.

  • @codeiscool5367
    @codeiscool5367 2 года назад +7

    thank you for making this video

  • @codintrika6005
    @codintrika6005 2 года назад +2

    Thank you sir for providing this tutorial I will like you to continue please

  • @san_lowkey
    @san_lowkey 10 месяцев назад

    great content ma man, it shows how much ur enjoying this.

  • @lucasa8710
    @lucasa8710 2 года назад +3

    I really like to create compilers even though I've never had created one LOL

  • @javierreyesg
    @javierreyesg Год назад +1

    Which program is used in 0:16 as replacement for the "ls" command? I have seen some options, but none seem to have this table formatting...

    • @ryzechdev
      @ryzechdev 5 месяцев назад +1

      That’s just nushell, built into it

  • @ОрехЧебуреков
    @ОрехЧебуреков Год назад +2

    Why would RUclips reccomend me this one? Hmm... Anyway, thank you very much for this video! Looks very professional lol

    • @Lensr
      @Lensr  Год назад

      Not sure, haha. The algorithm giveth and the algorithm taketh away 🤣
      Either way, hope you enjoy :P

  • @lane1313
    @lane1313 2 года назад +5

    Have you made a similar series using C++? If so, I think that'd be really cool. Also, I'd like to recommend D to you. D's a low level language as well, but with a GC. However, D's GC has been optimized fantastically to the point where it virtually makes no noticeable impact. It offers many things that as a long(er) time C++ programmer, I've began to move over to D. I have not seen very many posts (videos or writeups) on people who've documented compiler dev with D from scratch, although that is a heavy usage of D. I think if you looked into D, you'd see many similarities with C, and conveniences C++ does not offer.

  • @ariel_monaco
    @ariel_monaco Год назад +1

    5:04 are you really? Here flying with vim airlines since 1990. Favorite animal: Bison. Flex ad eternum

  • @p00laris
    @p00laris 3 месяца назад

    I think I’m a bit late, but I really love your contents ❤❤❤❤

  • @AbhinavPatel-cp8ep
    @AbhinavPatel-cp8ep Год назад

    Really the best 👨‍🏫📓tutorial

  • @AhmadAlMutawa_abunoor
    @AhmadAlMutawa_abunoor 4 месяца назад

    Can you please indicate what program you install onto Windows to make it respond to linux commands (i.e.: ls, mkdir), also it lists files into a headed table. That would be a lot helpful.
    Advanced thanks.

    • @AhmadAlMutawa_abunoor
      @AhmadAlMutawa_abunoor 4 месяца назад

      I already am aware about git bash for windows, but that does not list files into a table. So you must be using a different thing.

    • @philosophia5577
      @philosophia5577 3 месяца назад

      WSL

  • @alexanderthorbrugge6489
    @alexanderthorbrugge6489 2 года назад +4

    awesome👍🏻

  • @andrewsodyssey5753
    @andrewsodyssey5753 Год назад +2

    Great video dude

    • @Lensr
      @Lensr  Год назад

      Thank you!!

  • @duality4y
    @duality4y 21 день назад

    my compiler is called C2 because it is the second iteration of my Compiler xD

  • @Lorem_the_Ipsum
    @Lorem_the_Ipsum 4 месяца назад +1

    Now write a compiler in Moo

  • @harischandio4519
    @harischandio4519 Год назад +1

    subscribing just for the intro zxdddddddddddd

  • @epicujjwal
    @epicujjwal Год назад +1

    cool stuff

    • @Lensr
      @Lensr  Год назад

      I really appreciate it 🤟

  • @avg_user-dd2yb
    @avg_user-dd2yb 2 года назад +1

    You are a god.

  • @AlexanderEndless
    @AlexanderEndless 6 дней назад

    Are you saying mygit or maggot?

  • @AndrieMC
    @AndrieMC 11 месяцев назад +1

    you remind me of tsoding !

  • @SirRayleigh
    @SirRayleigh 2 года назад +2

    Bro Have me as your top fans, i demand that!

  • @shikharjain3536
    @shikharjain3536 11 месяцев назад

    hi. i am late too party!! But will yu ever shift the code to LLVM . i.e using llvm to build this compiler (generating clang AST and then applying llvm middleend opt/maybe write your own)?

  • @SkyDeathMKMT2
    @SkyDeathMKMT2 Год назад +1

    How did you make your windows terminal look like that?

    • @Lensr
      @Lensr  Год назад +1

      Nushell + Windows Terminal

    • @SkyDeathMKMT2
      @SkyDeathMKMT2 Год назад

      @@Lensr What settings do you use to make it look that way?

    • @human-hi3jt
      @human-hi3jt Год назад

      @@SkyDeathMKMT2 hes using emacs as a text editor if thats what you are asking about

  • @GnuChanOS
    @GnuChanOS 11 месяцев назад +1

    what if c,python,go,lua in same compiler :D

  • @Bl0xxy
    @Bl0xxy 5 месяцев назад

    now make a compiler IN scratch 😈

  • @CSharpGuy46-c7g
    @CSharpGuy46-c7g 9 месяцев назад

    If you have a touch sreen and tap on the progress bar, not on the button. * | *
    ------

  • @Nohope__
    @Nohope__ 7 месяцев назад +1

    thank you so much great stuff but GOSH your'e code is dirtyyyyy

    • @Lensr
      @Lensr  7 месяцев назад

      You can't spell "your"; I'm not worried about what idiots think.

    • @Nohope__
      @Nohope__ 7 месяцев назад +1

      I didn't really mean to offend you, I was just criticising have some capacity!@@Lensr

  • @20dareason09
    @20dareason09 Год назад +2

    `typedef struct struct_name { ... } struct_name;`
    can be written as.
    `typedef struct { ... } struct_name;`
    where `{ ... }` can be viewed as an "anonymous struct", saving a few key strokes and repetition.

    • @xKaihatsu
      @xKaihatsu Год назад +1

      I write it as typedef struct S { ... } S; because it's easier to use within debuggers.

    • @20dareason09
      @20dareason09 Год назад

      @@xKaihatsu That is a very valid and useful way to keep using it. I did not see that.

  • @Howtodo-oz2du
    @Howtodo-oz2du 11 месяцев назад

    Do you have a discord account?

  • @РодионЧаускин
    @РодионЧаускин 13 дней назад

    Clark James Lewis John Jackson Donna

  • @5cover
    @5cover 2 месяца назад

    Amazing content, but tell me: you complain about Microsoft so much, so why use Windows? Espicially since you seem to have a got an unix-like terminal thing going on, and you're using emacs.

  • @zweitekonto9654
    @zweitekonto9654 Год назад +2

    voice too low. Had to wear those ugly earbuds

    • @Lensr
      @Lensr  Год назад +1

      🤣🤣🤣

  • @xarcaz
    @xarcaz Год назад

    Emacs? Gross.

  • @HAAAAAA614
    @HAAAAAA614 7 месяцев назад

    Professional Yapper. This entire thing could have been less than an hour if you didn't randomly start yapping about things not related to compilers. You should change the title so it's not misleading

    • @Lensr
      @Lensr  6 месяцев назад +7

      It's a VOD, the point of the stream was to entertain the people watching it---not entitled assholes like you who feel so deserving of education for free that you leave embarrassing comments like this. You'll notice I don't stream anymore and a lot of it is because of people like you who are so unbelievably short-sighted and selfish. SMD, window-licker

    • @Max-hn9ib
      @Max-hn9ib 6 месяцев назад +4

      @@Lensr You need to come back. You're an incredibly talented teacher and have a great personality. Just don't ever read the comments. You know you're on the right track by checking out the like to dislike ratio.

  • @swagatbaruah522
    @swagatbaruah522 Год назад

    Hey man, I'm right now at 19:27 I'm following u in my windows machine, but I'm getting the following cmake error. Could you please help me out:
    W:\fromScratch\compiler\yt_01
    λ cmake -G Ninja -B bld -DCMAKE_BUILD_TYPE=Release
    -- Configuring done (0.1s)
    -- Generating done (0.0s)
    -- Build files have been written to: W:/fromScratch/compiler/yt_01/bld
    W:\fromScratch\compiler\yt_01
    λ cmake --build bld
    [1/2] Building C object CMakeFiles/func.dir/src/main.c.obj
    FAILED: CMakeFiles/func.dir/src/main.c.obj
    C:/ProgramData/chocolatey/bin/ccache.exe C:\PROGRA~1\LLVM\bin\clang.exe -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -MD -MT CMakeFiles/func.dir/src/main.c.obj -MF CMakeFiles\func.dir\src\main.c.obj.d -o CMakeFiles/func.dir/src/main.c.obj -c W:/fromScratch/compiler/yt_01/src/main.c
    ninja: build stopped: subcommand failed.

    • @madcc09
      @madcc09 11 месяцев назад

      just dont use cmake.