Esempio n. 1
0
bool ContextSubtract::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
	for (_i=_skipFirstArgs; _i < argc; _i++) {
		if (isUsed(_i - _skipFirstArgs)) {
			continue;
		}
		if (strcmp(_argv[_i], "-f") == 0) {
			if (!handle_f()) return false;
		}
		if (strcmp(_argv[_i], "-A") == 0) {
			if (!handle_A()) return false;
		}
		if (strcmp(_argv[_i], "-N") == 0) {
			if (!handle_N()) return false;
		}
	}
	return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs);
}
void parse1::to_hack_bin(){
	int i = 0;
	int print_num = 0;
	for (list<string>::iterator it = linked_list.begin(); it != linked_list.end(); ++it , ++i  ) {
		if( it->find("@") != string::npos ){
			print_num = (handle_A(*it ));
		}else if (it->find(";") != string::npos) {
			print_num = (handle_J(*it ));
		}else if (it->find("=") != string::npos) {
			print_num = (handle_C(*it ));
		}else {
			cout << "unknown command at line: " << *it << endl;
			break;
		}
		//to print or not to print
		if(print_num >= 0){
			cout <<bitset<BITWIDTH>(print_num) << endl;
		}else{
			cout <<"command Error on line : " << *it << endl;
			break;
		}
	}
}