
Flex & bison
by John R. Levine · first published 2009
11mentions
3recommended by
11HN commenters
2013–2024first – last mentioned
27% recommend73% neutral
Affiliate links. As an Amazon Associate I earn from qualifying purchases.





Going by OP's description, Flex and Bison appear to be well suited for what he/she intends to do. There is a bit of a learning curve, but I think it's well worth it. I have been working with both for a few years now and find them very flexible.…
on “Ask HN: Good Resources to Learn and Implement a Parser (Compiler)” ↗…article for someone like Walter Bright. Just some basic recommendations, but nothing practical? No links to books, parsers, implementations? The easiest start would be "Compiler Construction using Flex and Bison" by Anthony A. Aaby, available as free pdf, and for adding LLVM to the mix the link would be: http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/ There needs much more to be said, e.g. links to…
on “So you want to write your own language?” ↗…I admit that there are often better options out there these days, I'm just saying that some of these complaints about Flex / Bison may be a bit outdated. Multiple grammars are fine, you just instruct Flex and Bison to use static or add prefixes. No worries about ODR or LTO. If your build system can't handle generated code, that's an indictment of your build system. I know that's a bit harsh, but there are plenty…
on “C++ Compile Time Parser Generator” ↗I've been thinking about writing my own programming language for some time. This to gain a deeper understanding of how programming languages, and by extent, computers work. I've bought the Flex and Bison book by John Levine to have a resource on parsing and lexing. I have come to realize however, that writing a complete language like Java, Python, Ruby, from bottom to the top, is of course not a small…
on “Ask HN: What's a starting point for learning how to write programming languages?” ↗"Jargon", perhaps. "Never been in use by authors"? Not so. The current "international economy edition" of Aho, et al uses "lexing" 29 times, according to the search function on Amazon. Flex & Bison by John Levine (O'Reilly and Associates) uses "lexing" 38 times. And so on.
on “Turing Award goes to Aho and Ullman” ↗…the professor to give us the option of using a parser generator for the next phase (DML) since the point of the class wasn't parsing context free grammars and more focused on executing the SQL. I used Flex and Bison since the project was in C. Getting up and running and understanding how the tools have to be set up with different options was a bit tricky, but after that, my parser was up and running in about two…
on “Show HN: A work-in-progress C compiler from scratch” ↗I actually skipped the course, but grabbed my used copy from the old Powell's Tech before it closed, as well as the O'Reilly Flex and Bison book. It felt like I had the nuclear reactor manual! I also got really into writing interpreters, mainly in Ruby, after reading probably too many ICFP papers on the subject (and even shipped one to solve…
on “Create Your Own Programming Language” ↗The author writes his own experiences, and they are directly opposite of the "Compiler Construction using Flex and Bison." And he explains why. I also remember Stroustrup's story where once he wanted to develop C++ he got well meant advices to use lex and yacc, and he claims that he much later realized that much better…
on “So you want to write your own language?” ↗…all, Go's parser only parses Go. You want to generate go files from something other than Go? Edit: Now that I've written and read what I've written I realized I was confused. Nevermind! I still prefer Flex and Bison over Lex and Yacc.
on “Go generate” ↗Writing a compiler was part of the undergraduate compsci curriculum back where I did it. I still have vague memories of ancient tools like Flex and Bison (and I’m puzzled that the author seems to be hand-rolling code rather than use existing tooling).
on “Writing a Compiler is Surprisingly Easy (part 1)” ↗…Compilers course I took. A table based state machine is literally the textbook algorithm for parsing these classes of languages, and implementing them has been almost entirely automated by tools like Flex and Bison since the 80s.
on “Wc2: Investigates optimizing 'wc', the Unix word count program” ↗