Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

This is the expr example adapted for error capturing.

The goal is to parse simple arithmetic expressions like "1 + 2 * 3" and convert an expression like that into a parse tree. The parse tree generated uses an enum that's similar to the ArithmeticExpression enum described in Recursive Enumerations in the Swift documentation.

The parse tree is printed out in prefix notation in a lisp-like format.

This example uses error capturing to:

  • Collect multiple errors in one pass
  • Give clear error messages
  • Create a partial parse tree when there are errors