void BulletMLRunnerImpl::runSub() {
	// 見たくもないコードだね。
	while (act_ != 0 && !isTurnEnd()) {
		BulletMLNode* prev = act_;
		Method fp = commandMap_[act_->getName()];
		(this->*fp)();

		// ref から戻る
		if (act_ == 0 &&
			prev->getParent() != 0 &&
			prev->getParent()->getName() == BulletMLNode::bulletml)
		{
			assert(!refStack_.empty());
			prev = refStack_.top().first;
			parameters_ = refStack_.top().second;
			refStack_.pop();
		}

		// 次の node を探す
		if (act_ == 0) act_ = prev->next();

		// 上に遡って次の node を探す
		while (act_ == 0) {
			if (prev->getParent() != 0 &&
				prev->getParent()->getName() == BulletMLNode::repeat)
			{
				RepeatElem* rep = repeatStack_.top();
				rep->ite++;
				if (rep->ite < rep->end) {
					act_ = rep->act;
					break;
				}
				else {
					delete rep;
					repeatStack_.pop();
				}
			}

			act_ = prev->getParent();
			if (act_ == 0) break;

			prev = act_;

			if (prev->getParent() != 0 &&
				prev->getParent()->getName() == BulletMLNode::bulletml)
			{
				assert(!refStack_.empty());
				prev = act_ = refStack_.top().first;
				parameters_ = refStack_.top().second;
				refStack_.pop();
			}

			act_ = act_->next();
		}
	}
}
void BulletMLParserXercesSAXHandler::endElement(const XMLCh* const) {
	curNode_ = curNode_->getParent();
}