pacc logo

Referencing the input

For our next example, let's consider how we could parse a decimal number. We'll start by parsing a single digit, and we already know one way we could do that:

Digit ← "0" → 0 / "1" → 1 / "2" → 2 / "3" → 3 / "4" → 4 /
  "5" → 5 / "6" → 6 / "7" → 7 / "8" → 8 / "9" → 9

This is tedious and error-prone, but it's the best we can do with the matchers we've seen so far. Another matcher available in pacc is the character class: square brackets enclose a set of characters to be matched, so the character class [0123456789] matches a decimal digit.