daviwil.com
Technology, Creativity, and Life

Parsing Text with Combinators - F# Part 5

Join the discussion by commenting on the YouTube page for this video!

In this episode we start building a set of parser combinators which can parse the adventure game's text commands in a functional way. We'll also cover topics like recursive descent parsers, left-associativity, and F#'s range operator.

You can download the code for this episode at https://github.com/thedevaspect/aspect-fsharp

Sections:

  • What is a combinator? [0:26]
  • Recursive Descent Parser [0:44]
  • Defining Command Structure [3:35]
  • Defining 'expectChar' [4:51]
  • Decomposing a List [5:38]
  • The 'or' combinator [10:45]
  • Left-associative operators [15:04]
  • The 'choice' combinator [15:44]
  • The 'anyOf' combinator [17:40]
  • The range operator [19:06]
  • The 'and' combinator [20:02]
  • Defining 'expectString' [25:02]
  • Defining the Parser Type [28:21]
  • Defining 'runParser' [32:48]
  • Defining 'sequenceParsers' [39:46]
  • Tail Recursion [40:31]
  • The 'map' combinator [46:04]
  • The 'apply' combinator [48:45]
  • The 'return' combinator [51:13]
  • The 'lift' combinator [52:40]

Links: