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()); }
SDst AMUnitList::GetItemHeight() const { const auto item_h(GetItemHeightCore()); if(item_h != 0) return item_h; throw LoggedEvent("Zero item height found."); }
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; } }
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; }
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; }
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; }