Part 01: Tutorial on lex/yacc

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ก.พ. 2025

ความคิดเห็น • 116

  • @katiearriaga2147
    @katiearriaga2147 8 ปีที่แล้ว +34

    These videos have been the most helpful resource I've found on the internet on this topic. I'll be using flex and bison for the first time and this has been really helpful to get me started! Thanks a lot!

    • @dhruvtandel6342
      @dhruvtandel6342 5 ปีที่แล้ว +1

      thanks for your valuable insights . Much appreciated

  • @TBurbeck
    @TBurbeck 9 ปีที่แล้ว +2

    Been looking ages for a good tutorial about lex- fantasic and well worth the watch.

  • @MakerMark
    @MakerMark 8 ปีที่แล้ว +70

    This is some of the hardest stuff I've tried to wrap my brain around for a long time...Still gives me nightmares :)

    • @AsquareM
      @AsquareM 7 ปีที่แล้ว +5

      I still don't understand it

  • @JonathanEngelsma
    @JonathanEngelsma  12 ปีที่แล้ว +61

    Please note that if you are using flex, you need to add the line "%option nounput yylineno" to the first section of your lex input file to get the yylineno to print correctly. (without the quotes!)

  • @stevehyuga9216
    @stevehyuga9216 8 ปีที่แล้ว +1

    Great tutorial dude. The best is that you used Flex alone without Bison, it makes the whole thing clear in what Flex really does.

  • @ankitrathi6462
    @ankitrathi6462 9 ปีที่แล้ว +2

    A classic video SIR ! Really Amazing.
    This lex tutorial actually brushed up so many concepts.
    The sequence of regular expressions, the choice of defined constants and their use in TWO DIMENSIONAL char array ...... i actully got to learn so much from this video :) .

  • @DharshanaMuthtettugoda
    @DharshanaMuthtettugoda 11 ปีที่แล้ว +2

    This tutorial set really helped me to complete my Compiler Construction mini project in the university. Thank you so much.

  • @StiegeNZ
    @StiegeNZ 11 ปีที่แล้ว +2

    Found the solution, using flex so required flag -lfl , may be worth mentioning to other learners, cheers for the vid!

  • @awvalenti
    @awvalenti 8 ปีที่แล้ว +4

    Clarified a lot to me! Will help me in my homework. Thank you!

  • @ANCIENTASTRONAUT
    @ANCIENTASTRONAUT 9 ปีที่แล้ว

    thanks for the upload. great video for being introduced to this tool

  • @DejiAdegbite
    @DejiAdegbite 5 ปีที่แล้ว

    Nice. Simple and straight forward

  • @dannyrose42
    @dannyrose42 8 ปีที่แล้ว

    Great video! Thank you so much for taking the time and posting.

  • @AnupiyaNugaliyadde
    @AnupiyaNugaliyadde 11 ปีที่แล้ว +1

    Thank you so much Jonathan. I really appreciate this. I really learnt lex very quickly.
    My gratitude.

  • @MuratBinerbay
    @MuratBinerbay 10 ปีที่แล้ว

    thanks man me and my project group loved your video!

  • @MrMurtaX
    @MrMurtaX 11 ปีที่แล้ว +1

    That's great. I really liked your explanations, very simple and focused. Thanks a lot.

  • @raymondyoo5461
    @raymondyoo5461 7 ปีที่แล้ว

    Thank you very much. It was really straightforward, clear and helpful

  • @ryandavis7506
    @ryandavis7506 7 ปีที่แล้ว

    This is EXACTLY what I was looking for! Thanks for the vivid illustration and walk-through #thumbsup #greatpost #youdarealCSmvp

  • @nirmalbabu9570
    @nirmalbabu9570 5 ปีที่แล้ว

    Very well explained. Loved it

  • @rajni5604
    @rajni5604 11 ปีที่แล้ว

    Awesome... pictorial view of this concept is really great

  • @marcosricardooliveira3790
    @marcosricardooliveira3790 8 ปีที่แล้ว +1

    Very good video!
    So helpful, thank you for it!

  • @EvanHu01
    @EvanHu01 11 ปีที่แล้ว +1

    This is really cool. I think I will need some time to learn it. I have a project, which will automatically generate unit testing code for java programs. So I think I need to parse the source code first. And this will be a good start. Thanks. :)

  • @chris10056
    @chris10056 9 ปีที่แล้ว +1

    awesome video! this saved my butt for my class!

  • @soumyagayen3709
    @soumyagayen3709 9 ปีที่แล้ว +1

    Simple enough to build upon. Thank you

  • @thabisanisibanda6930
    @thabisanisibanda6930 7 ปีที่แล้ว

    Thank you bro, may GOD bless you this tutorial really helped me

  • @shrimpboyho
    @shrimpboyho 11 ปีที่แล้ว

    Amazing. Such a great tutorial!!!

  • @Occel0t575
    @Occel0t575 9 ปีที่แล้ว +1

    Thank you sir, this is going to help me for my lectures

  • @dmitryponyatov2158
    @dmitryponyatov2158 7 ปีที่แล้ว +4

    20:38 I use %option noyywrap yylineno to disable wrap and enable line counting (need for error reporting)

  • @SankarP
    @SankarP 9 ปีที่แล้ว +1

    Very nice video. Thanks.

  • @JonathanEngelsma
    @JonathanEngelsma  11 ปีที่แล้ว +1

    Hello Shailesh, I use Screenflow on the Mac.

  • @CJBurkey
    @CJBurkey 6 ปีที่แล้ว

    The first and only HD video on lexing with either Yacc or JFlex, from what I can see

  • @DharshanaMuthtettugoda
    @DharshanaMuthtettugoda 11 ปีที่แล้ว

    This tutorial set really helped me to complete my Compiler Construction mini project in the university. Thank you so much. By the way can you upload another tutorial upto Code Generation part. Windows platform is preferred.

  • @kamoroso94
    @kamoroso94 6 ปีที่แล้ว +1

    The line number was incorrect at 30:00. How do you fix that?

  • @lord7os1
    @lord7os1 8 ปีที่แล้ว +1

    thank you for the best explanation

  • @rickyjoebobby1
    @rickyjoebobby1 5 ปีที่แล้ว +5

    omg, 7:50 pretty much says "if a, then b output" LOOOL with gods help i might get this computer science degree

  • @kylep7503
    @kylep7503 6 ปีที่แล้ว

    Thank you. You explained this great

  • @randypitcherii
    @randypitcherii 9 ปีที่แล้ว +1

    Great video! Thank you

  • @whitebird365
    @whitebird365 5 ปีที่แล้ว +2

    Thank you.. But isn't there a mistake in the last execution in the error message? The message said the error is in the 1st line but actually it's in the 4th line!

  • @aruntmj
    @aruntmj 11 ปีที่แล้ว

    wonderful explanation

  • @Mark_Dan
    @Mark_Dan 5 ปีที่แล้ว

    HELP !!! 26:18 fatal error: PERMISSION DENIED on myscanner.h and myscanner.c
    I'm using Windows 10 but running it on an Ubuntu kernel [ gcc --version (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0] and flex 2.6.4
    Actually, I'm facing 2 problems. The first one is at trying to enter lex myscanner.l, it says "lex: can't open myscanner.l"... I tried so many things that I saw on the internet, and some of those worked, but I can't reply the process, that is, I can't create another file.l and start again
    The second is the shown (permission denied). This, I tried so hard and couldn't find a solution, please help me! I need to make a C-modified compiler for my course :((

  • @maramyasser6268
    @maramyasser6268 8 ปีที่แล้ว +1

    thank you mr.Jonathan

  • @mohitkumaryadav7530
    @mohitkumaryadav7530 11 ปีที่แล้ว

    thank u very much sir...........u r doing a great job..........

  • @mohibahmed1183
    @mohibahmed1183 8 ปีที่แล้ว +6

    absolutely brilliant! cleared quite a lot of concepts! I've got an issue though - the line numbers do not increment on their own? any explanation why this may be happening?

    • @rbaleksandar
      @rbaleksandar 8 ปีที่แล้ว

      Ah, same here. Found a solution by any chance?

    • @mohibahmed1183
      @mohibahmed1183 8 ปีที่แล้ว

      Nope

    • @calculatoare211c5
      @calculatoare211c5 6 ปีที่แล้ว

      Please note that if you are using flex, you need to add the line "%option nounput yylineno" to the first section of your lex input file to get the yylineno to print correctly. (without the quotes!)

    • @mariusradu3849
      @mariusradu3849 6 ปีที่แล้ว

      Please note that if you are using flex, you need to add the line "%option nounput yylineno" to the first section of your lex input file to get the yylineno to print correctly. (without the quotes!)

  • @nataraja4833
    @nataraja4833 10 ปีที่แล้ว

    good one and thanks for sharing

  • @shaileshdargude3560
    @shaileshdargude3560 11 ปีที่แล้ว

    This was really helpful! BTW, which tool did you use to record this demo/video.?

  • @lerneninverschiedenenforme7513
    @lerneninverschiedenenforme7513 6 ปีที่แล้ว

    Awesome! Thank you!

  • @IliaChikhanov
    @IliaChikhanov 9 ปีที่แล้ว

    Thank you very much! Awesome!

  • @gaming_with_ajey
    @gaming_with_ajey 8 ปีที่แล้ว +1

    This Video was really helpful.... :D

  • @viswanath470
    @viswanath470 12 ปีที่แล้ว

    excited by your typing speed...!!!

  • @dekadebashish
    @dekadebashish 8 ปีที่แล้ว +1

    great video.

  • @kraftwerke
    @kraftwerke 11 ปีที่แล้ว +2

    Excellent video - do you have videos on anyother SW topics

    • @JonathanEngelsma
      @JonathanEngelsma  11 ปีที่แล้ว +2

      @kraftwerke, Thank you for the feedback. There are many other software related tutorials available on my channel. Please subscribe. :-)

    • @rashidnazeer3485
      @rashidnazeer3485 8 ปีที่แล้ว

      executing led program on windows

  • @rachitagarwal3834
    @rachitagarwal3834 6 ปีที่แล้ว +1

    Can you please tell why yylineno always giving 1 as output?

  • @TheCuteworm
    @TheCuteworm 5 ปีที่แล้ว

    lex itself looks powerful parser. is there any popular lex practice?

  • @farantariq4295
    @farantariq4295 8 ปีที่แล้ว

    Very helpful. Thx :)

  • @mynameisGYAN
    @mynameisGYAN 9 ปีที่แล้ว +1

    Great video.. But a doubt... :P
    At time 30:2 output of yylineno is 1 which is incorrect. .
    I tried the code as
    while(ntoken)
    {
    printf(%d %d %s
    ", ntoken, yylineno, yytext);
    ntoken=yylex();
    }
    For each iteration yylineno is 1 only..

    • @rbaleksandar
      @rbaleksandar 8 ปีที่แล้ว

      Found a solution for this by any chance?

    • @georgemelissourgos2958
      @georgemelissourgos2958 7 ปีที่แล้ว +1

      In order to print the correct line using the yylineno field you need to implement its increasement when a linefeed is detected. To do that: 1) Go to your lex file (*.l) 2) add the following line in the first section: "linefeed
      " (without the quotation marks) 3) add the following line in the second section: "
      {linefeed} yylineno++;" (without the quotation marks).

  • @safweneful
    @safweneful 9 ปีที่แล้ว

    Hi, thanks for this informative video, i wanted to ask why don't you enable autoindentation on vim ?

  • @ShivamKumar-vj8oe
    @ShivamKumar-vj8oe 7 ปีที่แล้ว

    Can we add the c program in the lex program if we are using editpluse in Windows?

  • @erdemcalsr8615
    @erdemcalsr8615 7 ปีที่แล้ว

    hey Jonathan,
    Really great video, thaught me a lot.
    Just wanted to ask something though. Is it possible to use string for the header file
    #define TYPE "something"
    OR
    #define INTEGER 'something'
    when I try these, I use in .c file, %s or %c ...

  • @Anon-tj7qb
    @Anon-tj7qb 6 ปีที่แล้ว

    Currently the macro expansions require you to have #define ending with a semicolon with the update library. Doesn't allow for great use of your processor defines as you have to define more. Quite odd.

  • @dmitryponyatov2158
    @dmitryponyatov2158 7 ปีที่แล้ว

    What hints can I use to parse Python tabbed syntax ? It looks like both lex and yacc parts must have some tricks to count spaces, and add

  • @TheCuteworm
    @TheCuteworm 7 ปีที่แล้ว

    Is this yac/lex tool still popular? At which field are their prefered?thanks.

  • @SweatyParadox
    @SweatyParadox 5 ปีที่แล้ว

    johnnyyyy@TheHIVE keep her going buddy

  • @Yashu99g
    @Yashu99g 8 ปีที่แล้ว +3

    What if we write:
    "[a-z]+[a-zA-Z0-9_]* return IDENTIFIER; " ?

  • @TheRealJKJones
    @TheRealJKJones 9 ปีที่แล้ว +1

    Thank you so much.

  • @christosmakris927
    @christosmakris927 11 ปีที่แล้ว

    Hello,
    I followed exactly what you described in your steps but in the end I got 4 times
    myscanner.c (.text+0x49): undefined reference to 'yylineno'
    with the (.text+0x49) varying in each case. This comes up in the linux console.
    In the windows platform (i've set up everything so I can run flex and so use the flex command instead of the lex, everything worked until I got to the same spot. 4 times undefined reference to 'yylineno'.
    What do you suggest?
    Thank you in advance :)

    • @milesdavidsmith
      @milesdavidsmith 10 ปีที่แล้ว

      Did you try banging on the top of it?

    • @christosmakris927
      @christosmakris927 10 ปีที่แล้ว

      Aggelos Troulakis Nai exw ena project pou to paleuw edw kai kati mines. Katexeis?

  • @kevinaud6461
    @kevinaud6461 7 ปีที่แล้ว

    Is there a particular reason you use vi instead of vim? I didn't know people still used vi but to be honest I'm not sure what the actual differences are between the two

  • @apswindall
    @apswindall 7 ปีที่แล้ว

    Is it possible to use Python as an alternative to C when doing this?

  • @rbaleksandar
    @rbaleksandar 8 ปีที่แล้ว

    Thank you for sharing this!
    Everything went fine up until the end...Dang it. I'm getting "Expected an identifier" for the 1099 port number. Also I have noticed that my yylineno always returns 1, which is really strange to say the least. Any advice on how to solve that? Thanks.

    • @rbaleksandar
      @rbaleksandar 8 ปีที่แล้ว

      Ah, line increment problem solved. Someone posted a solution in the comments below.

    • @rbaleksandar
      @rbaleksandar 8 ปีที่แล้ว

      First problem also solved. LOL I had copy-pasted inside the l-file and had "return NAME;" for the case of PORT. :D

  • @Manuel-oe4gv
    @Manuel-oe4gv 9 ปีที่แล้ว

    First thank you for this awesome tutorial.
    But I'm little confuse , I thought that the order that tokens apear (ntoken and vtoken) was a parser task.

  • @shantanudeore6829
    @shantanudeore6829 5 ปีที่แล้ว +3

    19:25 important.

  • @osmantoplica8912
    @osmantoplica8912 6 ปีที่แล้ว

    Does this work for flex and bison, or is the syntax completely different?

  • @ArcoDielhof
    @ArcoDielhof 7 ปีที่แล้ว

    cc lex.yy.c -ll gives error.
    cant find -ll command.... >.<
    not using the -ll gives me more errors, about stuff not being defined. Anyone with an updated version knows what I am doing wrong?

    • @buzzz241
      @buzzz241 7 ปีที่แล้ว +1

      Arco Dielhof Try using -lfl for linking with Flex library - used more often on modern systems.

  • @pablovillalba2816
    @pablovillalba2816 11 ปีที่แล้ว

    I need to make a Turing machine as I can do?

  • @StiegeNZ
    @StiegeNZ 11 ปีที่แล้ว

    I'm getting the following error?
    [stiege@smaug lexanalysis]$ cc lex.yy.c -ll
    /usr/bin/ld: cannot find -ll
    collect2: error: ld returned 1 exit status

    • @sndrb1336
      @sndrb1336 5 ปีที่แล้ว

      I think -ll is for OSX, for linux, use -lfl

  • @ArianaBermudez
    @ArianaBermudez 7 ปีที่แล้ว

    Thank you!

  • @iamthejustin7420
    @iamthejustin7420 5 ปีที่แล้ว

    Can anyone explain to me what the below for loop does and how it works please?
    void tokenize(char *line, char **words, int *nwords)
    {
    *nwords=1;
    for(words[0]=strtok(line," \t
    ");
    (*nwords

  • @mightwilder
    @mightwilder 6 ปีที่แล้ว

    BEST!

  • @lord7os1
    @lord7os1 8 ปีที่แล้ว

    how can i do that in SWIFT please ??

  • @friaamarwa9353
    @friaamarwa9353 9 ปีที่แล้ว

    Plz where can i find the code .?

    • @rbaleksandar
      @rbaleksandar 8 ปีที่แล้ว

      All the code is put in the video. How hard can it be to write it while watching? It's not like you can't pause the video if it's too fast... ;)

    • @friaamarwa9353
      @friaamarwa9353 8 ปีที่แล้ว +1

      Thank you :))

  • @mmilerngruppe
    @mmilerngruppe 9 ปีที่แล้ว

    thank you!

  • @radwaashraf5402
    @radwaashraf5402 11 ปีที่แล้ว

    Thank you :)

  • @vash47
    @vash47 10 ปีที่แล้ว

    nice man

  • @ariamahlouji7781
    @ariamahlouji7781 6 ปีที่แล้ว

    The only problem that I faced was explaining in LINUX.

  • @dmitryponyatov2158
    @dmitryponyatov2158 7 ปีที่แล้ว

    26:18 its time to use make

  • @orangefreezepops
    @orangefreezepops 5 ปีที่แล้ว +1

    29:10 he types “kkk” very fast before copying the error message 👀

  • @zacheagan9581
    @zacheagan9581 8 ปีที่แล้ว +1

    How do you type so fast 0-0

  • @sanket144
    @sanket144 5 ปีที่แล้ว +1

    for errors for -ll use -lfl

  • @yesanton
    @yesanton 11 ปีที่แล้ว

    he's speeding up the video on those sections

  • @cubotar
    @cubotar 11 ปีที่แล้ว +1

    it's -lfl instead of -ll

  • @stephenkamenar
    @stephenkamenar 11 ปีที่แล้ว

    It's fast-forwarded xD

  • @lyes6033
    @lyes6033 7 ปีที่แล้ว

    my teacher told us to build a pascal compiler without teaching us lex or anything just some mathematical logic BS

  • @douchemanjr4738
    @douchemanjr4738 8 ปีที่แล้ว +1

    Great video, a little too slow though.

  • @palomacoronahuerta
    @palomacoronahuerta 11 ปีที่แล้ว

    Español!! :C

  • @phuccon
    @phuccon 11 ปีที่แล้ว

    no last viewer :)

  • @stevebucsh1681
    @stevebucsh1681 12 ปีที่แล้ว

    17th viewer?

  • @varandz
    @varandz 12 ปีที่แล้ว

    First viewer

  • @bartreijmer2440
    @bartreijmer2440 8 ปีที่แล้ว +1

    Thanks a lot!