From 5e8a2a90eda390cbe5272e209fdc085ad7d51077 Mon Sep 17 00:00:00 2001 From: Marvin Schlegel Date: Wed, 8 May 2024 00:00:18 +0200 Subject: [PATCH] parser improve error messages --- src/Parser/JavaParser.y | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Parser/JavaParser.y b/src/Parser/JavaParser.y index 8edb2df..6c249ac 100644 --- a/src/Parser/JavaParser.y +++ b/src/Parser/JavaParser.y @@ -7,6 +7,7 @@ import Parser.Lexer %name parse %tokentype { Token } %error { parseError } +%errorhandlertype explist %token BOOLEAN { BOOLEAN } @@ -368,7 +369,7 @@ data Declarator = Declarator Identifier (Maybe Expression) convertDeclarator :: DataType -> Declarator -> VariableDeclaration convertDeclarator dataType (Declarator id assigment) = VariableDeclaration dataType id assigment -parseError :: [Token] -> a -parseError msg = error ("Parse error: " ++ show msg) +parseError :: ([Token], [String]) -> a +parseError (errortoken, expected) = error ("parse error on token: " ++ show errortoken ++ "\nexpected one of: " ++ show expected) }