Hands-on: Functional Parsers in Scala


Details
In this hands-on session we will implement a simple parser combinator library from scratch.
In a short introduction we will explain what parser are, why they are useful, and how they can naturally be viewed as functions. When we start coding together, we will define basic parsers and combine them into more powerful parsers by using the composition mechanisms of functional programming.
At the the end we will be able to build a parser for arithmetic expressions such as this:
((1) ) * (2+( ((3 ))) (4+ ( ( ( 5 )) + 6 )) ( ((7 * 8 ) ) )+ 9 )
We will develop this in a TDD (as in test-driven) fashion. But don't worry, the tests have already been written for you. :)
Takeaways:
- Understand what parser combinators are
- Learn how to apply one of the most powerful concepts of functional programming: composition
- Develop an easier access to other battle tested parser libraries
- Have fun!
Prerequisites:
- Please bring a laptop with a working Scala development environment. If you don't have a working Scala environment, check out our intro to Scala: https://github.com/scaladus/scala-kickstart
- Git
Repository Link:
https://github.com/battermann/parser-combinators-scala-hands-on
Introduction Slides:
https://www.dropbox.com/s/un6jyosk3u417vh/Functional-Parsers.pdf?dl=0

Hands-on: Functional Parsers in Scala