예제 #1
0
bool Why3Translator::visit(UnaryOperation const& _unaryOperation)
{
	try
	{
		toFormalType(*_unaryOperation.annotation().type);
	}
	catch (NoFormalType &err)
	{
		string const* typeNamePtr = boost::get_error_info<errinfo_noFormalTypeFrom>(err);
		error(_unaryOperation, "Type \"" + (typeNamePtr ? *typeNamePtr : "") + "\" supported in unary operation.");
	}

	switch (_unaryOperation.getOperator())
	{
	case Token::Not: // !
		add("(not ");
		break;
	default:
		error(_unaryOperation, "Operator not supported.");
		break;
	}

	_unaryOperation.subExpression().accept(*this);
	add(")");

	return false;
}
예제 #2
0
bool ASTPrinter::visit(UnaryOperation const& _node)
{
	writeLine(string("UnaryOperation (") + (_node.isPrefixOperation() ? "prefix" : "postfix") +
			  ") " + Token::toString(_node.getOperator()));
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}