From d1ee6eca193be9b625591651976a0db409672aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 20 Apr 2018 16:32:18 +0200 Subject: [PATCH] Add suffix to variables with known domain This adds suffixes to integer and general variables, where the domain is explicitly known. --- include/anthem/output/AST.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/include/anthem/output/AST.h b/include/anthem/output/AST.h index 3b4eb55..6f6ffd9 100644 --- a/include/anthem/output/AST.h +++ b/include/anthem/output/AST.h @@ -322,6 +322,22 @@ inline output::ColorStream &print(output::ColorStream &stream, const Variable &v inline output::ColorStream &print(output::ColorStream &stream, const VariableDeclaration &variableDeclaration, PrintContext &printContext, bool) { + const auto domainSuffix = + [&variableDeclaration]() + { + switch (variableDeclaration.domain) + { + case Domain::Unknown: + return ""; + case Domain::General: + return "g"; + case Domain::Integer: + return "i"; + } + + return ""; + }; + const auto printVariableDeclaration = [&](const auto *prefix, auto &variableIDs) -> output::ColorStream & { @@ -334,7 +350,7 @@ inline output::ColorStream &print(output::ColorStream &stream, const VariableDec matchingVariableID = emplaceResult.first; } - const auto variableName = std::string(prefix) + std::to_string(matchingVariableID->second); + const auto variableName = std::string(prefix) + std::to_string(matchingVariableID->second) + domainSuffix(); return (stream << output::Variable(variableName.c_str())); };