Removed unneeded variable parsing functions.
This commit is contained in:
parent
7de9980c10
commit
80167fd21b
@ -16,9 +16,7 @@ namespace detail
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO: find consistent naming scheme
|
||||
std::experimental::optional<ast::VariablePointer> testParsingVariable(Context &context, VariableStack &variableStack);
|
||||
ast::VariablePointer parseVariable(Context &context, VariableStack &variableStack);
|
||||
std::experimental::optional<ast::VariablePointer> parseVariable(Context &context, VariableStack &variableStack);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -22,7 +22,7 @@ std::experimental::optional<ast::Term> parseTerm(Context &context, ASTContext &a
|
||||
tokenizer.skipWhiteSpace();
|
||||
|
||||
// TODO: refactor
|
||||
auto variable = testParsingVariable(context, variableStack);
|
||||
auto variable = parseVariable(context, variableStack);
|
||||
|
||||
if (variable)
|
||||
return std::move(variable.value());
|
||||
|
@ -10,11 +10,11 @@ namespace detail
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Predicate
|
||||
// Variable
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::experimental::optional<std::string> testParsingVariableName(Context &context)
|
||||
std::experimental::optional<ast::VariablePointer> parseVariable(Context &context, VariableStack &variableStack)
|
||||
{
|
||||
auto &tokenizer = context.tokenizer;
|
||||
|
||||
@ -23,48 +23,11 @@ std::experimental::optional<std::string> testParsingVariableName(Context &contex
|
||||
|
||||
tokenizer.expect<std::string>("?");
|
||||
|
||||
return tokenizer.getIdentifier();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string parseVariableName(Context &context)
|
||||
{
|
||||
auto &tokenizer = context.tokenizer;
|
||||
|
||||
tokenizer.expect<std::string>("?");
|
||||
|
||||
return tokenizer.getIdentifier();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::experimental::optional<ast::VariablePointer> testParsingVariable(Context &context, VariableStack &variableStack)
|
||||
{
|
||||
auto variableName = testParsingVariableName(context);
|
||||
|
||||
if (!variableName)
|
||||
return std::experimental::nullopt;
|
||||
|
||||
auto variableDeclaration = variableStack.findVariableDeclaration(variableName.value());
|
||||
|
||||
if (!variableDeclaration)
|
||||
return std::experimental::nullopt;
|
||||
|
||||
return std::make_unique<ast::Variable>(variableDeclaration.value());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ast::VariablePointer parseVariable(Context &context, VariableStack &variableStack)
|
||||
{
|
||||
auto &tokenizer = context.tokenizer;
|
||||
|
||||
auto variableName = parseVariableName(context);
|
||||
auto variableName = tokenizer.getIdentifier();
|
||||
auto variableDeclaration = variableStack.findVariableDeclaration(variableName);
|
||||
|
||||
if (!variableDeclaration)
|
||||
throw ParserException(tokenizer.location(), "undeclared variable “" + variableName + "”");
|
||||
return std::experimental::nullopt;
|
||||
|
||||
return std::make_unique<ast::Variable>(variableDeclaration.value());
|
||||
}
|
||||
|
Reference in New Issue
Block a user