1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include "FxDeclaration.h"
#include "string/case_conv.h"
#include "FxAction.h"
namespace fx
{
FxDeclaration::FxDeclaration(const std::string& name) :
DeclarationBase<IFxDeclaration>(decl::Type::Fx, name)
{}
std::size_t FxDeclaration::getNumActions()
{
ensureParsed();
return _actions.size();
}
IFxAction::Ptr FxDeclaration::getAction(std::size_t index)
{
ensureParsed();
return _actions.at(index);
}
std::string FxDeclaration::getBindTo()
{
ensureParsed();
return _bindTo;
}
const char* FxDeclaration::getKeptDelimiters() const
{
return "{}(),";
}
void FxDeclaration::onBeginParsing()
{
_bindTo.clear();
_actions.clear();
}
void FxDeclaration::parseFromTokens(parser::DefTokeniser& tokeniser)
{
while (tokeniser.hasMoreTokens())
{
auto token = tokeniser.nextToken();
string::to_lower(token);
if (token == "bindto")
{
_bindTo = tokeniser.nextToken();
}
else if (token == "{")
{
// An opening brace indicates an action, proceed
auto action = std::make_shared<FxAction>(*this);
action->parseFromTokens(tokeniser);
_actions.emplace_back(std::move(action));
}
}
}
}
|