From ce812d449bdf8407c5cbe969944196fbb7f2b360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Mon, 19 Jun 2017 01:08:27 +0200 Subject: [PATCH] Added exceptions for inconsistent use of typing. --- .../src/pddlparse/detail/parsing/ConstantDeclaration.cpp | 5 +++++ .../src/pddlparse/detail/parsing/VariableDeclaration.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/pddlparse/src/pddlparse/detail/parsing/ConstantDeclaration.cpp b/lib/pddlparse/src/pddlparse/detail/parsing/ConstantDeclaration.cpp index 423a622..9c427ea 100644 --- a/lib/pddlparse/src/pddlparse/detail/parsing/ConstantDeclaration.cpp +++ b/lib/pddlparse/src/pddlparse/detail/parsing/ConstantDeclaration.cpp @@ -56,6 +56,11 @@ void parseAndAddConstantDeclarations(Context &context, ast::Domain &domain, ast: tokenizer.skipWhiteSpace(); } + + const bool isTypingUsed = !domain.types.empty(); + + if (isTypingUsed && !constantDeclarations.empty() && !constantDeclarations.back()->type) + throw ParserException(tokenizer, "missing type declaration for constant “" + constantDeclarations.back()->name + "”"); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/lib/pddlparse/src/pddlparse/detail/parsing/VariableDeclaration.cpp b/lib/pddlparse/src/pddlparse/detail/parsing/VariableDeclaration.cpp index eca18d8..7b23510 100644 --- a/lib/pddlparse/src/pddlparse/detail/parsing/VariableDeclaration.cpp +++ b/lib/pddlparse/src/pddlparse/detail/parsing/VariableDeclaration.cpp @@ -56,6 +56,11 @@ void parseAndAddVariableDeclarations(Context &context, ast::Domain &domain, ast: tokenizer.skipWhiteSpace(); } + + const bool isTypingUsed = !domain.types.empty(); + + if (isTypingUsed && !variableDeclarations.empty() && !variableDeclarations.back()->type) + throw ParserException(tokenizer, "missing type declaration for variable “?" + variableDeclarations.back()->name + "”"); } ////////////////////////////////////////////////////////////////////////////////////////////////////