The prior code constructed the location of nonterminal maches out of
the the state of the stream after parsing. This isn't right for a few
reasons:
1. It doesn't get starting location correctly.
2. It doesn't behave when the non-terminal production did not
actually consume tokens for its parse.
This patch modifies the parsers to also pass along a
"last-consumed-token"; it, along with a few other changes, provides
the parsers enough information to accurately construct the locations,
even when no tokens have been consumed during the parse. We
synthesize a sentinel last-consumed-token token to take location from
the head of the stream.
original commit: 6e21e34ec7c7a3e9cf23a3f24bfafd6155e1f14a
if there already was one that I didn't find). Also fixed syntax
error raising procedure.
closes PR 12859
original commit: c0b928c758cc64b7b902fbe38838d31a3c1bc008