parsica
parsica copied to clipboard
Learning Parsica
In response to @mathiasverraes ' tweet here:
I think the documentation is very useful and developer-friendly already. I thought of a couple of things that might be improved:
- For most developers I think the closest thing to parsing that they already know and understand is regular expressions. At times, as a user of this library I felt like "if I could just use a regex, I'd be done already". Still, I wanted to do the right thing, and I kept looking for similar concepts and found them, like
atLeastOne
,zeroOrMore
,between
. In terms of documentation, I think it would be really helpful if there would be a page that shows some simple regexes and then shows and explains the alternative using parsers. - I think it will be interesting to have a chapter that shows alternatives for different parsers that achieve the same thing, or how some some parsers are shortcuts of others.
- The parts of the documentation that say "TODO" should be removed because they aren't useful for the reader, only for the writer/maintainer.
- The JSON parser is a great source for learning material, and I think it may deserve a full explanation in the documentation.
- It's very confusing that some parsers are marked as
@deprecated
; they are not in fact deprecated, it just seems they are not tested. As a user of the library it makes you feel somewhat bad about using these parsers, even though there's no alternative.
Great work on the type annotations by the way, those are really helpful, and I think it's amazing that this is now possible in PHP today.
Thanks a lot for this awesome library! It was a nice thing to dive in and get to know.
shows some simple regexes and then shows and explains the alternative using parsers
Excellent idea. The obvious difference is that combinators for complex parsers are more readable and writable (after paying the learning cost).
One major but more subtle difference between combinators and regexes (and grammars and tokenisers) is that with the combinators, you parse and build your final data structures in one step. The docs could reflect that.
Agreed with all the other remarks as well, and mea culpa for the @deprecated, that's entirely on me. I was going to clean that all up before the 0.5 release :-S
Thanks for putting in the effort of giving feedback, much appreciated!
Much appreciated indeed! I will look into it a bit more when some time frees up. My daughter was born this week! 🍼👶
My daughter was born this week! baby_bottlebaby
Ah, great news, congratulations!
It remains an extremely cool tool that I'll keep using, regardless of when you'll have time to work on performance or other issues. I'll probably blog about it at some point as well.