patrick
/
plasp
Archived
1
0
Fork 0

Removed unneeded constant parsing functions.

This commit is contained in:
Patrick Lühne 2017-08-31 18:51:27 +02:00
parent 80167fd21b
commit 0a104d222c
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
3 changed files with 3 additions and 19 deletions

View File

@ -16,8 +16,7 @@ namespace detail
// //
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
std::experimental::optional<ast::ConstantPointer> testParsingConstant(Context &context, ASTContext &astContext); std::experimental::optional<ast::ConstantPointer> parseConstant(Context &context, ASTContext &astContext);
ast::ConstantPointer parseConstant(Context &context, ASTContext &astContext);
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -50,7 +50,7 @@ std::experimental::optional<ast::ConstantPointer> findConstant(const std::string
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
std::experimental::optional<ast::ConstantPointer> testParsingConstant(Context &context, ASTContext &astContext) std::experimental::optional<ast::ConstantPointer> parseConstant(Context &context, ASTContext &astContext)
{ {
auto &tokenizer = context.tokenizer; auto &tokenizer = context.tokenizer;
@ -65,20 +65,5 @@ std::experimental::optional<ast::ConstantPointer> testParsingConstant(Context &c
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
ast::ConstantPointer parseConstant(Context &context, ASTContext &astContext)
{
auto &tokenizer = context.tokenizer;
const auto constantName = tokenizer.getIdentifier();
auto constant = findConstant(constantName, astContext);
if (!constant)
throw ParserException(tokenizer.location(), "undeclared constant “" + constantName + "");
return std::move(constant.value());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
} }
} }

View File

@ -28,7 +28,7 @@ std::experimental::optional<ast::Term> parseTerm(Context &context, ASTContext &a
return std::move(variable.value()); return std::move(variable.value());
// Parse argument if it is a constant // Parse argument if it is a constant
auto constant = testParsingConstant(context, astContext); auto constant = parseConstant(context, astContext);
if (constant) if (constant)
return std::move(constant.value()); return std::move(constant.value());