Chapter 16. Lexing and Parsing

In this chapter, you take a closer look at lexing and parsing, topics introduced briefly in Chapter 9 and 11. In particular, the chapter introduces the lexer and parser generators, fslex and fsyacc, that come with the F# distribution. A typical scenario when these techniques and tools can come in handy is the following:

  • You want to read user-readable input that has a well-defined syntax.

  • You have a type (often an abstract syntax tree [AST] type) to represent this input.

The typical task is to parse the user input into your internal representation by breaking down the input string into a sequence of tokens (a process called lexical analysis) and then constructing an instance of your internal representation based on a ...

Get Expert F# 2.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.