Better error state selection heuristic

Signed-off-by: Casey Dahlin <casey.dahlin@gmail.com>
Add tests for other types of error recovery

These don't pass yet, since we can't yet build AST nodes for errors, though the
difficult bits should work.

Signed-off-by: Casey Dahlin <casey.dahlin@gmail.com>
Add error constructors

In addition to rules, we can now provide error constructors, which are used to
create new error terminals that we can insert into the stream to recover
errors.

Signed-off-by: Casey Dahlin <casey.dahlin@gmail.com>
Decouple rule class from parsetree

The Rule class now takes ready-made lists of produce and consume symbols, and a
consume method that is anonymous and requires no container. This greatly
decouples it from ParseTree.

Signed-off-by: Casey Dahlin <casey.dahlin@gmail.com>
Factor out EPState.derive

Signed-off-by: Casey Dahlin <casey.dahlin@gmail.com>
Implement error constructors

We now have a way of calling back to the original class when we want to create
a synthetic token to construct an error.

Signed-off-by: Casey Dahlin <casey.dahlin@gmail.com>
Remove type parameter from tokens

type() is slow, but that's our baggage. No need to make the interface weird.

Signed-off-by: Casey Dahlin <casey.dahlin@gmail.com>