From 17993103e1ba1d142205eb2e41291edebc0e3a89 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 15:14:35 +0000 Subject: fix(parser): report missing THEN and ')' on the line that needs them Co-Authored-By: Claude Sonnet 5.5 --- include/cps/Parser.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/cps/Parser.h b/include/cps/Parser.h index eff25a5..e710150 100644 --- a/include/cps/Parser.h +++ b/include/cps/Parser.h @@ -19,6 +19,7 @@ class Parser { Lexer &Lex; int CurTok = tok_eof; bool StartsLine = true; + int PrevTokLine = 0; // line of the token before CurTok bool ParsingCaseLabel = false; std::vector CaseBodyDepths; unsigned NumErrors = 0; @@ -33,6 +34,9 @@ class Parser { }; void getNextToken(); + // Line for a diagnostic about a token missing before CurTok: the previous + // line when CurTok starts a new one. + int missingLine() const { return StartsLine ? PrevTokLine : Lex.getLine(); } int GetTokPrecedence(); std::unique_ptr ParseExpression(); -- cgit v1.3.1-4-g156e