#ifndef __PDDL_PARSE__DETAIL__PARSING__AST_H #define __PDDL_PARSE__DETAIL__PARSING__AST_H #include #include #include namespace pddl { namespace detail { /* //////////////////////////////////////////////////////////////////////////////////////////////////// // // ParseAST // //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Primitives //////////////////////////////////////////////////////////////////////////////////////////////////// template<> struct Parser { }; //////////////////////////////////////////////////////////////////////////////////////////////////// template<> struct Parser { }; //////////////////////////////////////////////////////////////////////////////////////////////////// template<> struct Parser { std::experimental::optional parse(Context &context, ASTContext &astContext) { auto &tokenizer = context.tokenizer; auto &types = astContext.description.domain.types; tokenizer.skipWhiteSpace(); auto typeName = tokenizer.getIdentifier(); if (typeName.empty()) throw tokenize::TokenizerException(tokenizer.location(), "no type supplied"); auto matchingType = std::find_if(types.begin(), types.end(), [&](auto &primitiveTypeDeclaration) { return primitiveTypeDeclaration->name == typeName; }); if (matchingType == types.end()) { // Only “object” is allowed as an implicit type if (typeName == "object" || typeName == "objects") { context.warningCallback(tokenizer.location(), "primitive type “" + typeName + "” should be declared"); types.emplace_back(std::make_unique(std::move(typeName))); return ast::PrimitiveType(types.back()); } else throw tokenize::TokenizerException(tokenizer.location(), "type “" + typeName + "” used but never declared"); } auto &type = *matchingType; return ast::PrimitiveType(type); } }; //////////////////////////////////////////////////////////////////////////////////////////////////// template<> struct Parser { }; //////////////////////////////////////////////////////////////////////////////////////////////////// template<> struct Parser { std::experimental::optional parse(Context &context, ASTContext &) { auto &tokenizer = context.tokenizer; ast::Unsupported unsupported; tokenizer.expect("("); unsupported.type = tokenizer.getIdentifier(); context.warningCallback(tokenizer.location(), "expression type “" + unsupported.type + "” currently unsupported in this context"); skipSection(tokenizer); return unsupported; } }; //////////////////////////////////////////////////////////////////////////////////////////////////// // Expressions //////////////////////////////////////////////////////////////////////////////////////////////////// template struct Parser> { template std::experimental::optional> parse(Context &context, ASTContext &astContext, ArgumentParser parseArgument) { return Parser, Argument>>::parse(context, astContext, parseArgument); } }; */ //////////////////////////////////////////////////////////////////////////////////////////////////// } } #endif