`{n}` repeats an element an exact number of times. The trick is to expand it into pieces you already know how to match, so the matcher needs no new code.
Parse `x{n}` into n copies of the element.
{n} is a counted quantifier: a{3} matches exactly three as. Like the shorthand
classes, it is best handled by desugaring at parse time - a{3} becomes
Concat[a, a, a], three copies of the atom you just parsed. The matcher never learns
a new trick; it just sees a longer concatenation. The anchored ^a{3}$ in the spec
is there to make the count exact: without anchors, Match searches, so a{3} would
find three as inside a longer run.
Parsing the suffix is the fresh part: after an atom, a { opens a count, you read
the digits, and a } closes it. Keep the number handy - tomorrow you extend the same
suffix parser to {n,m} and {n,}, where a comma introduces a range of allowed
counts instead of a single fixed one.
// Parse the {n} suffix after an atom, then desugar:// x{3} -> Concat[x, x, x]// Emit n copies of the atom you just parsed. No new matcher case.