Example #1
0
void
Analyze(ValueNode& root, const TokenList& token_list)
{
#if 0
	if(token_list.empty())
		throw LoggedEvent("Empty token list found;", Alert);
#endif
	if(Validate(token_list.begin(), token_list.end()) != token_list.end())
		throw LoggedEvent("Redundant ')' found.", Alert);

	const auto res(Reduce(root, token_list.begin(), token_list.end()));

	yassume(res == token_list.end());
}
Example #2
0
SDst
AMUnitList::GetItemHeight() const
{
	const auto item_h(GetItemHeightCore());

	if(item_h != 0)
		return item_h;
	throw LoggedEvent("Zero item height found.");
}
Example #3
0
Session::Session(const TextFile& tf)
{
	ystdex::ifile_iterator i(*tf.GetPtr());

	while(!tf.CheckEOF())
	{
		if(YB_UNLIKELY(is_undereferenceable(i)))
			throw LoggedEvent("Bad Source!", Critical);
		llex.ParseByte(*i);
		++i;
	}
}
Example #4
0
TLCIter
Validate(TLCIter b, TLCIter e)
{
	while(b != e && *b != ")")
		if(*b == "(")
		{
			auto res(Validate(++b, e));

			if(res == e || *res != ")")
				throw LoggedEvent("Redundant '(' found.", Alert);
			b = ++res;
		}
		else
			++b;
	return b;
}
Example #5
0
ValueNode
LoadNPLA1(ValueNode&& tree, std::function<NodeMapper> mapper)
{
	ValueNode root;

	try
	{
		root = TransformNPLA1(tree, mapper);
	}
	catch(ystdex::bad_any_cast& e)
	{
		// TODO: Avoid memory allocation.
		throw LoggedEvent(ystdex::sfmt(
			"Bad configuration found: cast failed from [%s] to [%s] .",
			e.from(), e.to()), Warning);
	}
	return root;
}
Example #6
0
TLCIter
Reduce(ValueNode& node, TLCIter b, TLCIter e)
{
	while(b != e && *b != ")")
		if(*b == "(")
		{
			auto nd(MakeNode(to_string(node.GetSize())));
			auto res(Reduce(nd, ++b, e));

			if(res == e || *res != ")")
				throw LoggedEvent("Redundant '(' found.", Alert);
			node += std::move(nd);
			b = ++res;
		}
		else
			node += {0, to_string(node.GetSize()), *b++};
	return b;
}