mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 08:28:31 +00:00
Change return of SkipPastLikelyEnd to be last consumed token (#3493)
This approach means the parse subtree includes the full token range consumed. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
1 parent
1addf10054
commit
6067ca3f49
28 files changed
+72
-94
No files matched your search
@@ -52,19 +52,12 @@ static auto TryHandleEndOrPackagingDecl(Context& context) -> bool {
|
||||
static auto FinishAndSkipInvalidDecl(Context& context, int32_t subtree_start)
|
||||
-> void {
|
||||
auto cursor = *context.position();
|
||||
// Consume to the next `;` or end of line. We ignore the return value since
|
||||
// we only care how much was consumed, not whether it ended with a `;`.
|
||||
// TODO: adjust the return of SkipPastLikelyEnd or create a new function
|
||||
// to avoid going through these hoops.
|
||||
context.SkipPastLikelyEnd(cursor);
|
||||
// Set `iter` to the last token consumed, one before the current position.
|
||||
auto iter = context.position();
|
||||
--iter;
|
||||
// Output an invalid parse subtree including everything up to the last token
|
||||
// consumed.
|
||||
// Output an invalid parse subtree including everything up to the next `;`
|
||||
// or end of line.
|
||||
context.ReplacePlaceholderNode(subtree_start, NodeKind::InvalidParseStart,
|
||||
cursor, /*has_error=*/true);
|
||||
context.AddNode(NodeKind::InvalidParseSubtree, *iter, subtree_start,
|
||||
context.AddNode(NodeKind::InvalidParseSubtree,
|
||||
context.SkipPastLikelyEnd(cursor), subtree_start,
|
||||
/*has_error=*/true);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user