News for hackers. Stuff that matters.
Re:Parser generators vs. handwritten parsers: surveying majo... by chrisseaton on Saturday August 21, 2021 @05:18PM (#28260663)
But it's still one extra language to learn, for in practice no benefit.
Re:Parser generators vs. handwritten parsers: surveying majo... by Zababa on Saturday August 21, 2021 @05:52PM (#28260894)
Copy/pasting the grammar of a language and using a library will be faster to do than any hand-written implementation, so I don't agree that there are no benefits.
Re:Parser generators vs. handwritten parsers: surveying majo... by chrisseaton on Saturday August 21, 2021 @05:54PM (#28260908)
But you can't do that because in practice these grammars have lots of imperative action code inserted all over the place because the parser generator's model fundamentally doesn't match the language class you're parsing and it needs to be worked around.

For example I work with a parser definition that's supposedly shared between C and Java, but it's a massive nightmare because it's 50% imperative actions.

Re:Parser generators vs. handwritten parsers: surveying majo... by Zababa on Saturday August 21, 2021 @06:03PM (#28260964)
That depends on the language you're trying to parse. If it has a LL or LR grammar, it'll work well. If it's something else that can't be described with something like that or something less powerful, you're going to have a bad time.
Re:Parser generators vs. handwritten parsers: surveying majo... by chrisseaton on Saturday August 21, 2021 @06:04PM (#28260978)
> That depends on the language you're trying to parse.

Yes... but most practical languages do not have simple LL or LR grammars. Hence this blog post and discussion and these problems.

Re:Parser generators vs. handwritten parsers: surveying majo... by Zababa on Saturday August 21, 2021 @07:02PM (#28261340)
That's not true. You can have a LL or LR grammar, and use a hand-written parser to get better speed, better error reporting, any number of reasons really. Java is LL(1), but javac seem to use a hand-written recursive descent parser. Now that I think about it, Java being omitted is weird.
Re:Parser generators vs. handwritten parsers: surveying majo... by UncleEntity on Saturday August 21, 2021 @08:49PM (#28261959)
> Java is LL(1)...

Java hasn't ever been able to be parsed with one token look ahead, the earlier versions had a section on how to modify the grammar to be LALR(1)[0] but it was dropped in later versions of the specification -- probably due to added features which made it unfeasible like generic classes.

It's actually quite a good resource since they explain the reasons why the parser needs to have more than one token to figure out what's going on.

[0] http://titanium.cs.berkeley.edu/doc/java-langspec-1.0/19.doc...

Re:Parser generators vs. handwritten parsers: surveying majo... by chrisseaton on Saturday August 21, 2021 @07:37PM (#28261587)
What’s not true?

I said ‘most’ not ‘all’, and nobody here said the only reason to hand-write a parser was context sensitivity.