Skip to content
HomeVideosBooks
AllTopicsTrends
BlogsPodcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    Cover of Flex & bison

    Flex & bison

    John R. Levine · 2009

    ProgrammingComputer ScienceSystems & OS
    Open LibraryAmazon
    Stats for nerds
    3recommend
    11mentions
    11people
    2013–2024years
    27% recommend73% neutral

    Mentions per year

    2013201520172019202120232024

    What Hacker News says

    1. massinstallFeb 2022
      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.

      FYI, Bison supports parsers using either LALR(1) (Look-Ahead Left-to-Right with 1 token lookahead) [https://en.wikipedia.org/wiki/LALR_parser] or GLR (generalized Left-To-Right) [https://en.wikipedia.org/wiki/GLR_parser].

      O'Reilly's book "flex & bison" by John Levine is a helpful reference. [https://www.amazon.com/flex-bison-Text-Processing-Tools/dp/0...]

      thread
    2. klodolphDec 2021
      Flex / Bison are manageable if you spend a bit of extra time reading the manual. 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 of build systems which can handle generated code and cross-compile just fine. Flex and Bison work fine on Windows.

      thread
    3. rurbanFeb 2014
      Surprisingly shadow 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 such languages which were written in a day and are not necessarily lisp or scheme. That would be too easy.

      thread
    4. GrantMoyerJun 2024
      > The algorithm is known as an "asynchronous state-machine parser". It's a technique for parsing that you don't learn in college.

      The mapping from regular and context free languages to state machines and their table-based implementations was covered in depth in the 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.

      thread
    5. mr_toadNov 2023
      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).
      thread
    6. jjiceAug 2021
      This is just an anecdote, but I had to write a SQL DDL and DML parser during my last semester. I wrote the DDL parser by hand, and it wasn't as bad as I expected, but it was time consuming. I managed to convince 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 hours, compared to probably four times that for the hand written DDL. Our DML subset was also much larger and more complex than our DDL, so I was very happy with the development speed increase.

      I had this idea that using a parser generator was slow and wasteful since many modern tutorials online write them by hand and speak against parser generators (possibly because there isn't a catch all for all languages). Turns out dev speed is way more important to me up front, because in the case that I notice parsing speed actually being an issue I should be happy that my MVP has gotten enough use.

      It's also nice because a lexer and parser can be pretty easily black-boxed and swapped out for your hand written, just keep the AST and API the same and you should be good.

      All that said, that's personal preferences and writing the parser by hand is definitely good experience and more extensible, especially for error handling. Nice work!

      thread

    Related

    Cover of Advanced programming in the Unix environment
    2008–2025

    Advanced programming in the Unix environment

    W. Richard Stevens
    100 recommend · 153
    Cover of Linkers and loaders
    2008–2026

    Linkers and loaders

    John R. Levine
    29 recommend · 45
    Cover of Code Complete
    2007–2026

    Code Complete

    Steve McConnell
    393 recommend · 894
    Cover of Concepts, techniques, and models of computer programming
    2007–2026

    Concepts, techniques, and models of computer programming

    Peter Van Roy
    70 recommend · 133
    Cover of Software Design for Flexibility
    2020–2026

    Software Design for Flexibility

    Chris Hanson
    8 recommend · 32
    Cover of The art of computer programming
    2007–2026

    The art of computer programming

    Donald Knuth
    336 recommend · 1,799
    Cover of Programming from the Ground Up
    2009–2026

    Programming from the Ground Up

    Jonathan Bartlett
    36 recommend · 56
    Software FoundationsBenjamin C. Pierce
    2011–2026

    Software Foundations

    Benjamin C. Pierce
    58 recommend · 77