2. Plan for the next 40 mins
1. Walk through creating a Parsing Expression Grammar
and scannerless predictive recursive descent parser
for a subset of print_r output.
2. Talk about why anyone would want to do such a
thing.
Source Code: https://bit.ly/dpc14rdp
10. âMartin Fowler
ââŠitâs a technique that isn't as widely known as it
should be. Many people are under the impression
that using it is quite hard. I think that this fear often
comes from the fact that Syntax- Directed
Translation is usually described in the context of
parsing a general-purpose languageâwhich
introduces a lot of complexities that you don't face
with a DSL.â
11. V1 - An empty array
Source Code: https://bit.ly/dpc14rdp
42. â Steve Yegge, Rich Programmer Food
âIf you don't know how parsing works, you'll do it
badly with regular expressions, or if you don't know
those, then with hand-rolled state machines that are
thousands of lines of incomprehensible code that
doesn't actually work.â
48. Useful applications Iâve seen
REST API with CQL querying (MediaMosa.org)
Migrating wiki content
Parsing log ïŹles
Parsing obscure speciïŹcations (ARF)
Concise conïŹguration ïŹles
Domain SpeciïŹc Languages
49. âMartin Fowler, Domain SpeciïŹc Languages
âa DSL is a front-end to a library providing a different
style of manipulation to the command-query API.
â
50. Rules for building a parser
Consider using an existing parser.
Consider porting one from another language.
Consider XML or the new XMLs: JSON / YAML
Consider working around it.
Then and only then consider building your own
parser
52. Letâs build a parser!
http://protalk.me/dpcradio-lets-build-a-parser
53. Thank you for your time and attention!
Questions?
Tweet to @relaxnow
Rate @ https://joind.in/10859
Slides @ https://joind.in/10859
Code @ https://bit.ly/dpc14rdp