From 91f52c12ff69716b09a68afb68752fbfe8602e8a Mon Sep 17 00:00:00 2001 From: Lai-YT <381xvmvbib@gmail.com> Date: Fri, 15 Sep 2023 14:34:13 +0800 Subject: [PATCH] Enhance error message verbosity --- parser.y | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/parser.y b/parser.y index bad5f7d2..f74ae21e 100644 --- a/parser.y +++ b/parser.y @@ -38,6 +38,12 @@ extern std::unique_ptr program; %define api.value.automove // This guarantees that headers do not conflict when included together. %define api.token.prefix {TOK_} +// Have messages report the unexpected token, and possibly the expected ones. +// Without this, the error message is always only "syntax error". +%define parse.error verbose +// Improve syntax error handling, as LALR parser might perform additional +// parser stack reductions before discovering the syntax error. +%define parse.lac full %token NUM %token ID