Re:Rich Programmer Food (2007)
by qwertyuiop924 on Tuesday May 24, 2016 @08:54AM
(#11761123)
...And unless you read the dragon book, you won't know how to write a recursive-descent parser. As for nested grammar, I think MPC supports that the best of the three, but even then, the support probably isn't the best. I haven't really checked though.
If you want this kind of composability, use PEG-based tools.
Same for the error messages and error recovery.
Re:Rich Programmer Food (2007)
by qwertyuiop924 on Tuesday May 24, 2016 @08:55AM
(#11761128)
Wait a sec. Since MPC is a Parser Combinator library, wouldn't it have the composability?
Yes, you're right - did not even notice MPC in the list, was commenting on Yacc and alike.
Re:Rich Programmer Food (2007)
by qwertyuiop924 on Tuesday May 24, 2016 @11:25AM
(#11762307)
Yeah. I wasn't commenting on specifically YACC and Lex, just compiler toolkits with good documentations. And MPC has some of the best documentation out there. Also, Build Your Own Lisp is amazing.
For instance in a lot of cases what you really want is to convert a grammar to some reasonable abstract syntax tree and I've found often you have to write a lot of code into those frameworks to do that, whereas you ought to be able to write something declarative that generates the AST objects and the translation code.
Another problem is a lack of composability. Particularly in DSL creation it would be desirable to "cut and paste" grammars into each other; it's very possible to embed SQL into a language like C, Java, or such -- you ought to be able to embed one parser in another but generally it is not easy.
Also there is the problem of error message generation, which is bad enough when you do are doing things that are "easy with yacc" but when you are doing hardcore transpilation of some kind, the error messages are often completely incomprehensible. This is a big factor in any kind of "rules engine" built around an existing language; error handling is disastrously bad in Drools, for instance -- you might think homoiconicity would improve matters with Clara in Clojure but it really doesn't.