From c462f6e6c10a461af0926e5b1f6dee660d6e9404 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Fri, 12 Jun 2020 23:34:27 +0200 Subject: [PATCH] Improve error message for tuple type declaration Tuples are only defined for simple types. This means that defining tuples like let t:(R*R); is forbidden. This may change in future, but it does not seem a limitations and probably leads to simpler syntax. Now, when the used type is not simple, it is clearly indicated. --- src/language/PEGGrammar.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/language/PEGGrammar.hpp b/src/language/PEGGrammar.hpp index e8f66bbd3..336fb5583 100644 --- a/src/language/PEGGrammar.hpp +++ b/src/language/PEGGrammar.hpp @@ -77,7 +77,9 @@ struct basic_type : sor< scalar_type, string_type >{}; struct type_name_id; struct simple_type_specifier : sor< vector_type, basic_type, type_name_id >{}; -struct tuple_type_specifier : seq<open_parent, simple_type_specifier, ignored, close_parent>{}; +struct tuple_type_specifier : sor<try_catch< open_parent, simple_type_specifier, ignored, close_parent >, + // non matching braces management + if_must< at< open_parent >, raise< simple_type_specifier >, until< eof > > >{}; struct TYPE_SPECIFIER : seq< sor<simple_type_specifier, tuple_type_specifier>, ignored >{}; @@ -385,6 +387,9 @@ inline const std::string errors<language::slashstar>::error_message = "block com template <> inline const std::string errors<language::open_brace>::error_message = "open brace was never closed, missing '}'"; +template <> +inline const std::string errors<language::simple_type_specifier>::error_message = "expecting simple type specifier"; + // clang-format on } // namespace language -- GitLab