def second_pass(filename, symbol_table): parser_object = parser.Parser(filename) symbols = symbol_table next_address = 16 out_filename = remove_file_extension(filename) + '.hack' with open(out_filename, 'w') as out_file: while parser_object.has_more_commands: parser_object.advance() if parser_object.command_type == parser.CommandType.A_COMMAND and not is_int( parser_object.symbol): if parser_object.symbol in symbols: symbol = symbols[parser_object.symbol] else: symbol = '0{0:015b}\n'.format(next_address) symbols[parser_object.symbol] = symbol next_address += 1 out_file.write(symbol) elif parser_object.command_type == parser.CommandType.A_COMMAND and is_int( parser_object.symbol): symbol = '0{0:015b}\n'.format(int(parser_object.symbol)) out_file.write(symbol) elif parser_object.command_type == parser.CommandType.C_COMMAND: comp_code = code.Code(parser_object) out_file.write('111{}{}{}\n'.format(comp_code.comp(), comp_code.dest(), comp_code.jump()))
def first_pass(filename): symbol_table = symbolTable.SymbolTable.copy() ROM_address = 0 parser_object = parser.Parser(filename) while parser_object.has_more_commands: parser_object.advance() if (parser_object.command_type == parser.CommandType.C_COMMAND or parser_object.command_type == parser.CommandType.A_COMMAND): ROM_address += 1 elif parser_object.command_type == parser.CommandType.L_COMMAND: symbol = '0{0:015b}\n'.format(ROM_address) symbol_table[parser_object.symbol] = symbol return symbol_table
def __init__(self): self.args = args.Parser().get_args() self.__repo_name = REPOSITORY.split('/')[1].replace('.git', '') self.__path = '/tmp' self.__repo_local_path = '{0}/{1}'.format(self.__path, self.__repo_name) self.__current_branch = '' self.__common_actions(self.args.branch, self.args.commit) if self.args.target == 'android': self.__android(self.args.environment) else: self.__ios(self.args.environment)
LinkedIn Information Gathering Tool\n\n""" # Parses the data from command line ArgParser = argparse.ArgumentParser( description='Raven - LinkedIn Information Gathering Tool') ArgParser.add_argument('-c', '--company', help='Input the Company name. Ex: Pizzahut ', required=True) ArgParser.add_argument('-s', '--state', help='Input the State initials. Ex: uk , al , etc...', required=True) args = vars(ArgParser.parse_args()) ParserObject = parser.Parser(args['state']) RequesterObject = requester.Requester() companyArg = pathname2url(args['company']) state = args['state'] # Prints the banner, who doesn't loves banners :P sys.stdout.write(GREEN) print banner sys.stdout.write(RESET) sys.stdout.write(CYAN) Persons = []
import modules.parser as p import modules.models as m PATHTOBLOCK = './sampleblock' print("start") a = p.Parser() with open(PATHTOBLOCK, 'r') as content_file: CONTENT = content_file.read() a.parse(CONTENT) print("done") print("#######") print("#######")