{
}
+ IRCompiler(const IRCompiler&) = delete;
+ IRCompiler& operator=(const IRCompiler&) = delete;
+
bool Compile();
+ std::string GetSourceName() const;
const IR::Module& GetIR() const;
private:
+ void CompileTrackBlock(std::size_t index);
+
IR::Module m_IR;
};
Unknown,
UnknownInPhrase2IR,
UnknownInComposition2IR,
+ UnknownInIRProcessor,
UnknownInIR2MIDI,
UnprocessedAttribute,
DuplicatedCompositionName,
GrammarPhrase4,
GrammarPhraseName,
+ // IRProcessor
+ InvalidAttributeName,
+
// IR2MIDI
InvalidCommandName,
WrongNumberOfCommandArguments,
{Message::MessageID::Unknown, ICEMessage},
{Message::MessageID::UnknownInPhrase2IR, ICEMessage + " (Phrase2IR: Phrase = '{0}', Message = '{1}')"},
{Message::MessageID::UnknownInComposition2IR, ICEMessage + " (Composition2IR: Composition = '{0}', Message = '{1}')"},
+ {Message::MessageID::UnknownInIRProcessor, ICEMessage + " (IRProcessor: Message = '{0}')"},
{Message::MessageID::UnknownInIR2MIDI, ICEMessage + " (IR2MIDI: Message = '{0}')"},
{Message::MessageID::UnprocessedAttribute, ICEMessage + " (Unprocessed attribute: '{0}')"},
{Message::MessageID::DuplicatedCompositionName, "composition named '{0}' is already defined"},
{Message::MessageID::GrammarPhrase4, "unexpected token '{0}', expecting notes"},
{Message::MessageID::GrammarPhraseName, "expecting valid name for phrase"},
+ // IRProcessor
+ {Message::MessageID::InvalidAttributeName, "invalid attribute '{0}'"},
+
// IR2MIDI
{Message::MessageID::InvalidCommandName, "invalid command '{0}'"},
{Message::MessageID::WrongNumberOfCommandArguments, "wrong number of arguments passed to command '{0}'; {2} expected, {1} found"},
+#include <exception>
+
+#include <exceptions/messageexception.hpp>
#include <irprocessor/irprocessor.hpp>
+#include <message/message.hpp>
namespace YAMML
{
bool IRCompiler::Compile()
{
- return true;
+ try
+ {
+ std::size_t numberOfTrackBlocks = m_IR.TrackBlocks.size();
+
+ for (std::size_t i = 0; i < numberOfTrackBlocks; i++)
+ {
+ CompileTrackBlock(i);
+ }
+
+ return !HasErrors();
+ }
+ catch (const Exceptions::MessageException& e)
+ {
+ AddMessage(e.Item);
+ return false;
+ }
+ catch (const std::exception& e)
+ {
+ AddMessage(
+ Message::MessageItem{
+ Message::MessageKind::FetalError,
+ Message::MessageID::UnknownInIRProcessor,
+ GetSourceName(),
+ {0, 0},
+ {e.what()}
+ }
+ );
+
+ return false;
+ }
+}
+
+std::string IRCompiler::GetSourceName() const
+{
+ return m_IR.Name;
}
const IR::Module& IRCompiler::GetIR() const
return m_IR;
}
+void IRCompiler::CompileTrackBlock(std::size_t index)
+{
+ // TODO
+
+ if (!m_IR.TrackBlocks[index].Attributes.empty())
+ {
+ auto attribute = m_IR.TrackBlocks[index].Attributes.at(0);
+
+ throw Exceptions::MessageException(
+ Message::MessageItem{
+ Message::MessageKind::Error,
+ Message::MessageID::InvalidAttributeName,
+ GetSourceName(),
+ attribute.Location,
+ {attribute.Name}
+ }
+ );
+ }
+}
+
} // namespace IRProcessor
} // namespace YAMML
#pragma once
#include <algorithm>
+#include <exception>
#include <functional>
#include <string>
#include <unordered_map>