Commit 14689e01 authored by Marc's avatar Marc
Browse files

Fix typoes

parent b8d7ffc4
......@@ -41,7 +41,7 @@ namespace TuringSim::Listener {
*/
DummyListener& operator=(const DummyListener& other) = default;
/*!@brief Move assignement operator
/*!@brief Move assignment operator
* @param[in, out] other the listener to move.
* @return a reference to <tt>*this</tt>.
*/
......
......@@ -67,7 +67,7 @@ namespace TuringSim::Listener {
*/
Listener& operator=(const Listener& other) = default;
/*!@brief Move assignement operator
/*!@brief Move assignment operator
* @param[in, out] other the listener to move.
* @return a reference to <tt>*this</tt>.
*/
......
......@@ -41,7 +41,7 @@ namespace TuringSim::Listener {
*/
NonDeterministicCounterListener& operator=(const NonDeterministicCounterListener& other) = default;
/*!@brief Move assignement operator
/*!@brief Move assignment operator
* @param[in, out] other the listener to move.
* @return a reference to <tt>*this</tt>.
*/
......
......@@ -63,7 +63,7 @@ namespace TuringSim::Machine {
* @return A Boolean, if the NodeType is a constant, empty if it is a quantifier.
*/
std::optional<bool> toBool(NodeType node);
};
}
/*!@class AcceptingMachine acceptingMachine.h <machine/acceptingMachine.h>
* @brief Base class for accepting machines.
......
......@@ -440,7 +440,7 @@ namespace TuringSim::Memory::Stack {
*/
[[nodiscard]] constexpr size_t getSize() const { return this->memory->size; }
/*!@brief Return the unused allocated stack.
* @return the free sptace on the stack.
* @return the free space on the stack.
*/
[[nodiscard]] constexpr size_t getFreeSpace() const { return this->memory->freeSpace; }
/*!@brief Return the allocated space.
......
......@@ -202,8 +202,7 @@ namespace TuringSim::Runner {
}
else if constexpr (IsAccepting_v && !IsAlternating_v) {
return this->machine.isAcceptingConfiguration(getCurrentState(), this->getStorage());
}
else {
} else {
switch (this->machine.isAcceptingConfiguration(getCurrentState(), memory)) {
case Machine::Acceptance::Accept:
case Machine::Acceptance::Universal:
......
......@@ -352,31 +352,31 @@ namespace TuringSim::State::MConfiguration {
* @tparam U the type of nodes of the MConfigurations
* @tparam CharT char type
* @tparam Traits <tt>std::basic_ostream</tt> trait.
* @param[in, out] ooss the output stream
* @param[in, out] os the output stream
* @param[in] m_conf the MConfiguration to print.
* @return reference to @p ooss.
* @return reference to @p os.
*
* Type @p U have to have <tt>operator<<(std::basic_ostream<CharT, Traits>&, const U&)</tt> implemented.
*/
template <typename U, typename CharT, typename Traits> constexpr friend std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ooss, const MConfiguration<U>& m_conf) {
template <typename U, typename CharT, typename Traits> constexpr friend std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const MConfiguration<U>& m_conf) {
if(m_conf.args.empty()) {
ooss << (m_conf.isVar ? "_" : "") << m_conf.node;
return ooss;
os << (m_conf.isVar ? "_" : "") << m_conf.node;
return os;
}
ooss << m_conf.node << "(";
os << m_conf.node << "(";
bool first = true;
for(size_t i = 0; i < m_conf.args.size(); ++i) {
if(first) {
first = false;
}
else {
ooss << ", ";
os << ", ";
}
ooss << *m_conf.args[i];
os << *m_conf.args[i];
}
ooss << ")";
return ooss;
os << ")";
return os;
}
protected:
......@@ -820,7 +820,7 @@ namespace TuringSim::State::MConfiguration {
};
if(isPattern()) {
if(state.isMFunction()) {
if(state->isMFunction()) {
return unifyWithMConf_opt(state);
}
throw make_exception("Two patterns in MConfiguration<T>::unify");
......
......@@ -158,8 +158,8 @@ namespace TuringSim::State::MConfiguration {
}
/*!@brief Debug printer of TokenKind.
* tparam CharT the char type.
* tparam Traits <tt>std::basic_ostream</tt> trait.
* @tparam CharT the char type.
* @tparam Traits <tt>std::basic_ostream</tt> trait.
* @param[in, out] os output stream.
* @param[in] token the token to print.
* return the updated stream.
......
......@@ -90,7 +90,7 @@ namespace TuringSim::Transition::Amnesic {
}
/*!@brief Whether the transition should halts the machine.
* @return True iff the transition terminates the exeuction.
* @return True iff the transition terminates the execution.
*/
bool isTerminating() const noexcept {
return terminating;
......
......@@ -12,7 +12,7 @@ namespace TuringSim::Transition {
* This is a utility class, transition may use or not.
*/
template <typename TransitionType>
class ConfigurationDoesNotMatchException : public Utils::MessageException {
class [[maybe_unused]] ConfigurationDoesNotMatchException : public Utils::MessageException {
public:
/*!@brief ConfigurationDoesNotMatchException must be build with interesting data.
*/
......
......@@ -66,7 +66,7 @@ namespace TuringSim::Utils {
}
protected:
/*!@brief Build the full error message. It should be overriden by derived class that adds data to the exception.
/*!@brief Build the full error message. It should be overridden by derived class that adds data to the exception.
* @return the full error message.
*
* This is called the first time the full error is requested, the result is then memoized.
......@@ -75,7 +75,7 @@ namespace TuringSim::Utils {
return msg;
}
std::string msg; /*!<@brief The error messsage. */
std::string msg; /*!<@brief The error message. */
mutable std::optional<std::string> fullMsg; /*!<@brief The optional full message. Empty until first request. */
};
......
......@@ -38,6 +38,7 @@ namespace TuringSim::Utils {
if(this != &other) {
uid = other.uid;
}
return *this;
}
/*!@brief Move a dispenser
* @param[in, out] other the dispenser to move.
......@@ -47,6 +48,7 @@ namespace TuringSim::Utils {
if(this != &other) {
uid = std::move(other.uid);
}
return *this;
}
/*!@brief Generate a new identifier.
......@@ -97,6 +99,7 @@ namespace TuringSim::Utils {
tag = other.tag;
uid = other.uid;
}
return *this;
}
/*!@brief Move a dispenser
......@@ -108,6 +111,7 @@ namespace TuringSim::Utils {
tag = std::move(other.tag);
uid = std::move(other.uid);
}
return *this;
}
/*!@brief Generate a new identifier.
......@@ -125,7 +129,7 @@ namespace TuringSim::Utils {
/*!@class TaggedUidDispenserFactory uidDispenser.h <utils/uidDispenser.h>
* @brief Return a new UID dispenser at each invocation.
* @tparam Tag the type of tags, must be incrementable.
* @tparam UID the type of uidq, must be incrementable.
* @tparam UID the type of unique identifiers, must be incrementable.
*/
template<typename Tag, typename UID>
class TaggedUidDispenserFactory {
......@@ -137,7 +141,7 @@ namespace TuringSim::Utils {
static_assert(std::is_default_constructible_v<UID>);
/*!@brief Generate the next uid dispenser.
* @return A uid dispenser generating uids disjoint from each other.
* @return A uid dispenser generating unique identifiers disjoint from each other.
*/
UidDispenser<UIDType> operator()() {
return UidDispenser<UIDType>{tag++};
......
......@@ -162,8 +162,8 @@ namespace TuringSim::State::MConfiguration {
if(!explicitBlank && node_str.empty()) {
throw MConfigurationParserSyntaxErrorException("Token shouldn't be empty.", m_fun, tokens, position);
}
auto [isVariable, node] = isVariableNode(node_str);
return std::make_shared<const MConfiguration<std::string>>(node, isVariable);
auto [isVariable, nodeName] = isVariableNode(node_str);
return std::make_shared<const MConfiguration<std::string>>(nodeName, isVariable);
};
switch(std::get<0>(tokens[position])) {
......
#include <utils/messageException.h>
#include <symbol/turingStyleMixedSymbolPatternParser.h>
#include <symbol/turingMachineSymbolPattern.h>
namespace TuringSim::Symbol {
void TuringStyleMixedSymbolPatternParser::checkInitialization() const {
......
......@@ -20,6 +20,7 @@ namespace TuringSimTest::State {
CPPUNIT_TEST(testUnifyStateMismatchingOccurrences);
CPPUNIT_TEST(testUnifyWithMConf);
CPPUNIT_TEST(testUnify);
CPPUNIT_TEST(testUnify_opt);
CPPUNIT_TEST(testAlphaEquivalence);
CPPUNIT_TEST(testAlphaEquivalenceFail);
CPPUNIT_TEST(testComparison);
......@@ -42,6 +43,7 @@ namespace TuringSimTest::State {
void testUnifyStateMismatchingOccurrences();
void testUnifyWithMConf();
void testUnify();
void testUnify_opt();
void testApplySubs();
void testAlphaEquivalence();
void testAlphaEquivalenceFail();
......
......@@ -270,6 +270,45 @@ namespace TuringSimTest::State {
}
}
void TestMConfiguration::testUnify_opt() {
vector<
tuple<
shared_ptr<const MConfiguration<string>>,
shared_ptr<const MConfiguration<string>>,
map<string, MConfiguration<string>>>> test_cases
{
{
parser.parse("ga(foo, _a, zo(_b, _c))"),
parser.parse("ga(foo, bu, zo(meu, bli(coin, pan)))"),
{
{"a", "bu"s},
{"b", "meu"s},
{"c", {"bli"s, {"coin"s, "pan"s}}},
},
},
{
parser.parse("ga(_a, _a)"),
parser.parse("ga(f(x, y), f(x, y))"),
{
{"a", {"f"s, {"x"s, "y"s}}},
},
},
};
for (auto&[pattern, m_conf, expected_unifier] : test_cases) {
optional<map<string, shared_ptr<const MConfiguration<string>>>> actual_unifier_opt = pattern->unify_opt(m_conf);
CPPUNIT_ASSERT(actual_unifier_opt);
CPPUNIT_ASSERT_EQUAL(expected_unifier.size(), actual_unifier_opt->size());
for (const auto&[key, val]: expected_unifier) {
CPPUNIT_ASSERT_EQUAL(1UL, actual_unifier_opt->count(key));
CPPUNIT_ASSERT_EQUAL(val, *actual_unifier_opt->at(key));
}
CPPUNIT_ASSERT_THROW(m_conf->unify(m_conf), NoUnificationException<string>);
CPPUNIT_ASSERT_THROW(pattern->unify(pattern), NoUnificationException<string>);
}
}
void TestMConfiguration::testApplySubs() {
vector<
tuple<
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment