A parser! what a joy :)
Basically a stack machine wrapped in some boilerplate. A neat trick for part 2 is to simply reverse the order of the stack and count that instead of actually adding the rest.