multistart: fix IELR computations
commit70ee8c77a8287612c038b9a6f14f6f3b38281bfc
authorAkim Demaille <akim.demaille@gmail.com>
Sun, 8 Nov 2020 12:30:14 +0000 (8 13:30 +0100)
committerAkim Demaille <akim.demaille@gmail.com>
Tue, 10 Nov 2020 06:08:07 +0000 (10 07:08 +0100)
treeddd61fcca4aaa9614b75dc80145cbaa3a4882c5e
parente9a43ed4ae9c9c4d6f4e250e4f929ac9602d7452
multistart: fix IELR computations

IELR needs to rule out the successors of the kernel items of the
initial state (`$accept: input • $end`).  In the case of multistart,
this condition must be expressed differently: the mere item index does
not suffice.

* src/ielr.c (ielr_item_has_lookahead, ielr_compute_lookaheads): Don't
rely on the item index to check whether is_successor_of_initial_item.
It is certainly more costly than just checking the item index, but (i)
we need to compute the rule anyway, so it's not very much more costly,
and (ii) in ielr_item_has_lookahead, this situation is actually
impossible, so an optimizing compiler reading the assertions should
actually avoid this computation.
src/ielr.c