Trouble with the unicorn


I know how learning of complex subject is supposed to work, but it’s not happening for me right now.

You’re supposed to mimic someone who knows how to do it, slowly gaining small insights into why they are doing something this way or that. And hopefully eventually you kind of daydream or sleep on it, and it all clicks together into overall comprehension. I guess criticism could accelerate it dramatically if you can get someone to see what you do and tell you what they think about it.

For a while now I’m trying to understand how proper lexer and parser generators work. Specifically, flex and bison.

I ended up buying this book:

Introduction to Compiler Construction with UNIX

It is also available online.

I got stuck dead very early, on page 11. I just don’t get what a formulation and position marker is. I can’t quite grep states in .output file from running bison -v on your grammar (pages 9-10). I don’t understand trees related to LL and LR parsing (pages 6-8). I think this is somehow related to deconstructing input string left to right or right to left, but I’m not sure.

I wish I had someone to chat about this. Potential benefits of using flex/bison or similar tools are really impressive. Instead or rolling your own hand crafted parser, you generate it and avoid stupid bugs and unnecessary code bloat.

It is infuriating being unable to understand how stuff works… I know I’ll get a huge satisfaction if I’ll eventually get it, but hope is slim at this point.