aboutsummaryrefslogtreecommitdiff
path: root/include/cps
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-22 15:14:35 +0000
committer_ov4 <ov4@ov4.org>2026-10-22 15:33:15 +0000
commit17993103e1ba1d142205eb2e41291edebc0e3a89 (patch)
tree4a3208d9c0edb1bdd7ae317da0d6dd0d098279b6 /include/cps
parentcb62de1eba07d4c522213bdd8331686684b3468c (diff)
fix(parser): report missing THEN and ')' on the line that needs them
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'include/cps')
-rw-r--r--include/cps/Parser.h4
1 files changed, 4 insertions, 0 deletions
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<unsigned> 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<ExprAST> ParseExpression();