News for hackers. Stuff that matters.
Re:GNU Bison 3.3 released by stabbles on Saturday January 26, 2019 @02:06PM (#19007809)
"There are also many smaller improvements, including a fix for a bug which is at least 31 years old."
Re:GNU Bison 3.3 released by benj111 on Saturday January 26, 2019 @02:38PM (#19007983)
Its weird that web pages can succumb to link rot so quickly, apps succumb to bit rot almost as quickly, but a bug will live on.

In a thousand years time will archeologists study us through the bugs left behind in Linux 1300.05 and windows (30)95? Do you think there will still be jobs for Cobol programmers?

Re:GNU Bison 3.3 released by perlgeek on Saturday January 26, 2019 @03:10PM (#19008166)
> but a bug will live on.

Sometimes, yes. But it has also happened often to me that an old bug I was trying to fix was simply gone, either because the error mode has gone away, or the feature that the bug related to has been removed.

Re:GNU Bison 3.3 released by msla on Saturday January 26, 2019 @09:07PM (#19009969)
> But it has also happened often to me that an old bug I was trying to fix was simply gone, either because the error mode has gone away, or the feature that the bug related to has been removed.

And this is why groups like the OpenBSD team and the Linux kernel team are so eager to remove support for old hardware. Removing support for the 80386 cleaned up code which no longer had to have special cases to handle opcodes and features the 80386 doesn't have but later x86 processors do.

Re:GNU Bison 3.3 released by gumby on Saturday January 26, 2019 @03:44PM (#19008376)
It will be the "junk DNA" of the source code -- because of workarounds and baked in assumptions it will be impossible to eradicate.
Re:GNU Bison 3.3 released by indyz on Saturday January 26, 2019 @07:29PM (#19009536)
Something similar is actually a plot point in Vernor Vinge's "A Fire Upon The Deep".
Re:GNU Bison 3.3 released by jimktrains2 on Saturday January 26, 2019 @04:37PM (#19008656)
I wish it were easier to have more target languages. (And that there were more target languages.)

I know the docs say that additions are welcome, but I'm still in my infancy of working out how to :)

Congrats though! I love it when these tried-and-true tools continue to perform and improve!

Re:GNU Bison 3.3 released by jonathankoren on Saturday January 26, 2019 @02:00PM (#19007781)
I always kind of wonder what people use lex and yacc for. 20 years ago I made something to pretty print random C structs, but I have no idea what people do with these tools. Historically, these have been billed as "compiler compilers", and while that's certainly a use case, it never struck me as a very popular use case.
Re:GNU Bison 3.3 released by derefr on Saturday January 26, 2019 @02:30PM (#19007933)
The main advantage, to me, is that the input of Yacc is a (mostly) self-contained, (mostly) declarative representation of the grammar to be parsed. This format is portable between projects.

You can, for example, take Postgres’s SQL syntax parsing “engine” out of Postgres and use it in your own project, because it’s not actually an “engine”, but rather just a Yacc grammar.

Re:GNU Bison 3.3 released by wwright on Saturday January 26, 2019 @07:08PM (#19009437)
How often are yacc/lex grammars actually portable? Truly portable too — usable in different threading contexts, for example.

You say they are declarative. My experience is admittedly very limited, but I would call them anything but declarative. There are declarative elements, but the actual payload of your code is very, very often imperative. (A lot of this is shaped by the API, imo).

I compare this to parser combinators (like parsec) and PEGs (like luapeg and rust-peg). I find these other options are more naturally side-effect free, both internally and externally.

Re:GNU Bison 3.3 released by yanowitz on Saturday January 26, 2019 @02:17PM (#19007866)
They are used to build a number of tools you probably rely on or use regularly, including ruby, golang, bash, MySQL and postgresql.
Re:GNU Bison 3.3 released by CalChris on Saturday January 26, 2019 @05:00PM (#19008781)
golang uses a handwritten recursive decent parser and handwritten lexer.

https://github.com/golang/gofrontend/blob/master/go/parse.cc https://github.com/golang/gofrontend/blob/master/go/lex.cc

I can't think of a single major tool that uses ANTLR or bison. I say that being a huge ANTLR fan. Parser/lexer generators are really easy to use for DSLs but for real languages and tools, they're too heavyweight and constraining.

Re:GNU Bison 3.3 released by lower on Saturday January 26, 2019 @08:00PM (#19009697)
> Parser/lexer generators are really easy to use for DSLs but for real languages and tools, they're too heavyweight and constraining.

Haskell and OCaml are examples of real languages that use parser generators.

GHC: https://github.com/ghc/ghc/blob/master/compiler/parser/Parse...

Ocaml: https://github.com/ocaml/ocaml/blob/trunk/parsing/parser.mly

Re:GNU Bison 3.3 released by gnulinux on Saturday January 26, 2019 @06:52PM (#19009365)
GCC used to use bison. I don't think GCC became a major project recently. But you're correct that recursive descent is more efficient. Not everything is efficiency though (parsers are usually 1% of compile time since they're dirt cheap compared to code generator and especially static analyzer and optimizer). Bison makes parsing extremely simple. I can't see why anyone would use recursive descent unless they're a super major project and need to squeeze every ms.
Re:GNU Bison 3.3 released by wwright on Saturday January 26, 2019 @07:02PM (#19009410)
A big part of why tools move away from Bison and ANTLR isn’t performance, but UX (especially error reporting)
Re:GNU Bison 3.3 released by gnulinux on Saturday January 26, 2019 @08:05PM (#19009712)
In my experience recursive descent doesn't have any better error reporting than Bison or ANTLR. Parser combinators are much better if error reporting is what you're aiming for. Also, for LALR/LR parsers like Bison/ANTLR, the canonical trick is to encode errors in your grammar, which really isn't a huge deal. E.g. in pseudocode

    suite: stmt ';' stmt {/* ok */}
         | one_line_stmt NEWLINE stmt {raise("you need a ';' there buddy");}
         | // other rules
         ;
obviously this won't be useful for every case in general, otherwise why use ';' at all, but in most cases it'll give a helpful error.

Some more powerful parsers like Earley Algorithm have much worse error reporting.

Re:GNU Bison 3.3 released by ksherlock on Saturday January 26, 2019 @11:26PM (#19010340)
context sensitive grammars.
Re:GNU Bison 3.3 released by gnulinux on Saturday January 26, 2019 @11:50PM (#19010386)
You can deal with context sensitive grammars with "lexer trick" or multiple pass parsers.
Re:GNU Bison 3.3 released by grumpydba on Saturday January 26, 2019 @06:12PM (#19009178)
Re:GNU Bison 3.3 released by CamouflagedKiwi on Saturday January 26, 2019 @07:27PM (#19009529)
That's the gccgo frontend; the more usual Go compiler is here: https://github.com/golang/go/tree/master/src/cmd/compile/int...

It's still handwritten though so your point stands.

Re:GNU Bison 3.3 released by rvp-x on Sunday January 27, 2019 @01:57AM (#19010662)
Golang also has its own linker and assembler (going as far as having different notation for asm instructions), it doesn't count in these comparisons.
Re:GNU Bison 3.3 released by tptacek on Saturday January 26, 2019 @05:20PM (#19008900)
PHP appears to. It was the first language that came up in my Github search, and I stopped looking there.
Re:GNU Bison 3.3 released by tptacek on Saturday January 26, 2019 @05:18PM (#19008893)
Re:GNU Bison 3.3 released by cryptonector on Saturday January 26, 2019 @07:16PM (#19009479)
Hand-coding {object code, codecs, parsers, ...} is a disaster. That's why compilers exist. It's also why code generators exist. That's what lex/yacc (flex/bison) are: code generators specialized for generating parsers. They are not compiler-compilers, but tools used in the construction of compilers (and other things that aren't compilers too).
Re:GNU Bison 3.3 released by gnulinux on Saturday January 26, 2019 @02:21PM (#19007887)
You use it when you need a parser or a lexer. Even GCC used to use it (they switched to a recursive descent parser a few years ago). Not sure what's surprising here. Maybe you're not familiar parsers?
Re:GNU Bison 3.3 released by coliveira on Saturday January 26, 2019 @02:42PM (#19008006)
Yacc is a very important part of UNIX because it allows one to create a parser for a language with limited knowledge of parsing. Of course, if a language is very complicated, it is better to create a special purpose parser, but with yacc one can easily create parsers for most simple DSLs.
Re:GNU Bison 3.3 released by chrisseaton on Saturday January 26, 2019 @06:23PM (#19009226)
> Yacc is a very important part of UNIX because it allows one to create a parser for a language with limited knowledge of parsing.

This isn't true. You basically need to know the entire algorithm Yacc uses to use it. What does someone with limited knowledge of parsing do when Yacc tells them this?

    5: reduce/reduce conflict (reduce 3, reduce 4) on c
    state 5
            B : x y .  (3)
            E : x y .  (4)
Re:GNU Bison 3.3 released by gnulinux on Saturday January 26, 2019 @06:58PM (#19009397)
I can't see the problem here. To use stdlib `rand` you need to understand that you should first `srand(seed)` and why, and that that seed needs to be unique for each program. Then, in order to use it correctly (e.g. not in a physics simulation) you should understand it's algorithm. Using programming tools require reading manual, and sometimes understanding algorithms.
Re:GNU Bison 3.3 released by chrisseaton on Saturday January 26, 2019 @07:05PM (#19009425)
> I can't see the problem here.

I didn't say it was a problem.

Re:GNU Bison 3.3 released by yesenadam on Saturday January 26, 2019 @07:01PM (#19009405)
This unfortunately all comes down to what you mean by "basically" and what they meant by "limited".

I think what they said is closer to the truth. I've used flex/bison a few times to create simple languages, and as long as they're parsed correctly, which is quick/easy to roughly check with a REPL (mine were in that form), conflicts can be ignored. Mine worked fine. It was a joy to use - having both flex and bison program windows open, plus bash to run the makefile, I could add a feature and test it within seconds. I'd say I have very limited knowledge of parsing, but read a few flex/bison books, enough to grasp what that message means. It's not necessary to have no conflicts, from what I understand. And it seems you have a more....professional language in mind, like in a commercial situation.

But then again, Yacc/bison isn't very important because it allows etc.... (i.e. that's not the reason it's important)

Re:GNU Bison 3.3 released by coliveira on Saturday January 26, 2019 @06:43PM (#19009328)
One thing is knowing about parsers, another completely different thing is knowing how to implement an efficient parser. This is the difference, e.g., between using a machine learning algorithm and implementing one from scratch.
Re:GNU Bison 3.3 released by tom_ on Saturday January 26, 2019 @09:26PM (#19010037)
They figure it out, I assume? - LR parsing is accountancy, not rocket science. You don't need to be a genius.
Re:GNU Bison 3.3 released by UncleEntity on Saturday January 26, 2019 @07:14PM (#19009462)
Open Shading Language (from Sony) uses it to parse the, umm, shading language.

Pixie (the Renderman renderer) uses two or three bison grammars.

I personally like SQLite's lemon parser generator for my grammar poking arounding when I'm not messing with my C++ Earley parser implementation -- which I can never seem to get working properly with empty rules since the papers on the subject are less than clear.

But I'm probably a bit of a strange one in that I'll spend days getting a random grammar working then drop it for some shiny new thing to play with.

Re:GNU Bison 3.3 released by userbinator on Saturday January 26, 2019 @02:22PM (#19007895)
In the C family of languages all the notable compilers either never used a parser generator and instead simple recursive descent, or moved from using one. It's easier to write, debug, and extend an RD (or table-driver precedence-climbing) parser than work with the (large amounts of) generated code tools like Bison will create.
Re:GNU Bison 3.3 released by x12xc on Saturday January 26, 2019 @03:47PM (#19008396)
In general, I don't think so. It's one thing if you parse a well understood grammar like C. But many people who use recursive descent from the start for a new language or DSL just don't bother about the grammar, and when someone takes a look it is suddenly LL(4) and relies on whatever the hand-written parser does.
Re:GNU Bison 3.3 released by kccqzy on Saturday January 26, 2019 @06:55PM (#19009386)
So what? I personally am a fan of recursive descent parsing for most programming languages, and if it works with recursive descent, why would it be troubling that it's actually an LL(4) grammar?

Now it would only be troubling if the grammar itself is intended to be widely usable across different languages, say JSON or XML. A parser generator really shines because it can generate code to parse this grammar in multiple languages. For programming languages intended to be written by humans, I value things like good error reporting far more.

Re:GNU Bison 3.3 released by ethagnawl on Saturday January 26, 2019 @07:32PM (#19009549)
I'd assumed VimScript was written using Flex/Bison; turns out it's written directly in C: https://github.com/vim/vim/blob/master/src/eval.c
Re:GNU Bison 3.3 released by memling on Saturday January 26, 2019 @07:30PM (#19009540)
I would guess that a lot of your cell data are processed by code generators that use the lex/yacc toolchain. While perhaps they're not commonly used in implementations, they have a large number of deployments.
Re:GNU Bison 3.3 released by dntf0llow on Saturday January 26, 2019 @02:06PM (#19007810)
I mean, they're basically used whenever you need either a lexer or a parser, or both. So yeah, there is quite a number of possible use cases.
Re:GNU Bison 3.3 released by beefhash on Sunday January 27, 2019 @01:57AM (#19010658)
lex and yacc also used by the ircd-hybrid and ircu families of IRCds to parse the configuration files. OpenBSD also uses yacc for configuration files for pf, doas, httpd, etc.
Re:GNU Bison 3.3 released by losvedir on Saturday January 26, 2019 @03:18PM (#19008211)
yecc, the erlang port of yacc, is used by the Elixir parser.
Re:GNU Bison 3.3 released by jeffdavis on Sunday January 27, 2019 @11:57AM (#19012510)
SQL parsers, like postgres and mysql.
Re:GNU Bison 3.3 released by mruts on Saturday January 26, 2019 @11:37PM (#19010360)
I think a lot of people just use parser combinators which I personally find a lot easier to use and much more powerful. Code as data, data aa code, yadda yadda.