2 Parsers with Choice

Most grammars are not completely static—usually, there is an element of choice. For example, when parsing a boolean, a valid value is true or false. Even more complicated, when parsing a list of elements, a valid input might be any number of booleans, all next to one another. To handle these kinds of grammars, a parser can be provided with multiple paths, each of which are valid.

    2.1 Providing multiple paths

      2.1.1 Parsing ambiguous grammars

      2.1.2 Backtracking with caution

    2.2 Parsing sequences