當前位置: 首頁>>代碼示例>>Python>>正文


Python Parser.Parser方法代碼示例

本文整理匯總了Python中Parser.Parser方法的典型用法代碼示例。如果您正苦於以下問題:Python Parser.Parser方法的具體用法?Python Parser.Parser怎麽用?Python Parser.Parser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Parser的用法示例。


在下文中一共展示了Parser.Parser方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def __init__(self, compiler, file_location, compiler_options = "", lang = "c++"):
        self.file_location = file_location
        self.file_name = None
        self.file_extn = None
        self.file_output_name = None    #Includes output file extension
        self.file_output_extn = None
        self.lang = lang
        self.compiler = compiler
        self.compiler_options = compiler_options
        self.test_cases = []            #Each test case is a pair [input, output]
        self.test_case_files = []
        self.contest_id = None
        self.problem_id = None
        self.comms = CodeforcesComms()
        self.parser = Parser()

        if(lang == "c++"):
            self.file_output_extn = ".out" 
開發者ID:cpragadeesh,項目名稱:codeforces-cli,代碼行數:20,代碼來源:CodeforcesCLI.py

示例2: __init__

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def __init__(self):
        self.start = False
        self.connections_socket = []
        self.connections_address = []
        self.clients_couples = []

        parser = Parser([
            ("-p", {"type": int, "dest": "port", "help": "Type the server's port to connect to"}),
            ("-l", {"type": int, "dest": "listen", "default": "5", "help": "Type the max users the server can listen to at the same time"}),
        ])
        args = parser.parse()
        self.args = vars(args)

        self.server_socket = socket.socket()
        self.server_socket.bind(("0.0.0.0", self.args["port"]))
        self.server_socket.listen(self.args["listen"]) 
開發者ID:yonatanperi,項目名稱:python,代碼行數:18,代碼來源:server.py

示例3: pass_2

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def pass_2(self, asm_file, hack_file):
        """
        Second compilation pass: Generate hack machine code and write results to output file.
        :param asm_file: The program source code file, written in Hack Asembly Language.
        :param hack_file: Output file to write Hack Machine Code output to.
        :return: None.
        """
        parser = Parser.Parser(asm_file)
        with open(hack_file, 'w', encoding='utf-8') as hack_file:
            code = Code.Code()
            while parser.has_more_instructions():
                parser.advance()
                inst_type = parser.instruction_type
                if inst_type == parser.A_INSTRUCTION:
                    hack_file.write(code.gen_a_instruction(self._get_address(parser.symbol)) + '\n')
                elif inst_type == parser.C_INSTRUCTION:
                    hack_file.write(code.gen_c_instruction(parser.dest, parser.comp, parser.jmp) + '\n')
                elif inst_type == parser.L_INSTRUCTION:
                    pass 
開發者ID:aalhour,項目名稱:Assembler.hack,代碼行數:21,代碼來源:Assembler.py

示例4: main

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def main():
    print('A calculator written by RQY at Mar 31, 2017.')
    print('version ' + VERSION)
    try:
        while True:
            try:
                text = raw_input('>>> ')
            except NameError:
                text = input('>>> ')
            if text and not text.isspace():
                text.strip()
                if text[0] == ':':
                    runcmd(text)
                else:
                    try:
                        p = Parser.Parser(text)
                        i = ASTVisiter.Interpreter(p, variable_table, functions)
                        ans = i.interpret()
                        # if ans is not None:
                        # print(ans)
                        # print(p.parse())
                    except Exception, e:
                        print(e.message)
    except EOFError:
        print('') 
開發者ID:rqy1458814497,項目名稱:calculator,代碼行數:27,代碼來源:main.py

示例5: __init__

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def __init__(self, width, height):

        super().__init__(width, height, title="Egzaminator")
        self.background_list = None
        self.lecturer = None
        self.students_amount = 11
        self.score = 0
        self.physics_engine = None
        self.program_bot = ProgramBot()
        self.parser = Parser()
        self.MOVEMENT_SPEED = 15
        self.SPRITE_SCALING = 1
        self.resourcesSetup(11)
        self.wilhelm = arcade.sound.load_sound("app_resources/sounds/wilhelm.ogg")
        self.setup()
        print("Wpisz co? aby uruchomi? program") 
開發者ID:MieszkoWrzeszczynski,項目名稱:KCK,代碼行數:18,代碼來源:App.py

示例6: main

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def main():
	# Setup standard binary operators
	# 1 is lowest possible precedence, 40 is highest
	operatorPrecedence = {
		'<': 10, 
		'+': 20, 
		'-': 20, 
		'*': 40
	}

	# Run the main 'interpreter loop'
	while True:
		try:
			raw = input('archon> ')
		# Allow user to quit with Ctrl+C
		except KeyboardInterrupt:
			break

		# Tokenize() is in the lexer class so would be Lexer.Tokenize()
		# And need to import Lexer
		parser = Parser.Parser(Lexer.Tokenize(raw), operatorPrecedence)

		while True:
			# If you hit EOF then stop
			if isinstance(parser.current, Lexer.EOFToken):
				break
			if isinstance(parser.current, Lexer.DefToken):
				parser.HandleDefinition()
			elif isinstance(parser.current, Lexer.ExternToken):
				parser.HandleExtern()
			else:
				parser.HandleTopLevelExpression()

	print('\n', AbstractSyntaxTree.g_llvm_module) 
開發者ID:rmccorm4,項目名稱:Archon,代碼行數:36,代碼來源:main.py

示例7: __init__

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def __init__(self):

        parser = Parser([
            ("-c", {"type": str, "dest": "character", "help": "Type your character name"}),
            ("-s", {"type": str, "dest": "server", "default": "127.0.0.1", "help": "Type the server's ip to connect to"}),
            ("-p", {"type": int, "dest": "port", "help": "Type the server's port to connect to"}),
        ])
        args = parser.parse()
        self.args = vars(args)
        self.client_socket = socket.socket() 
開發者ID:yonatanperi,項目名稱:python,代碼行數:12,代碼來源:client.py

示例8: pass_1

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def pass_1(self, file):
        """
        First compilation pass: Determine memory locations of label definitions: (LABEL).
        :param file:
        :return:
        """
        parser = Parser.Parser(file)
        curr_address = 0
        while parser.has_more_instructions():
            parser.advance()
            inst_type = parser.instruction_type
            if inst_type in [parser.A_INSTRUCTION, parser.C_INSTRUCTION]:
                curr_address += 1
            elif inst_type == parser.L_INSTRUCTION:
                self.symbols_table.add_entry(parser.symbol, curr_address) 
開發者ID:aalhour,項目名稱:Assembler.hack,代碼行數:17,代碼來源:Assembler.py

示例9: text_to_database

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def text_to_database(self, full_text, sha224, title, fluent_anki_session, target_language):

        language = DBWrapper().get_or_create_language(fluent_anki_session, target_language)
        #parse text into objects
        pobj = Parser().parse(full_text)
        #import pdb; pdb.set_trace()

        doc = Document(full_text)

        #create the source text database object
        source_text_dbobj = SourceText(title = title, 
                                       hash_text=sha224, 
                                       text_length=len(pobj.tagged_words))

        black_list = DBWrapper().get_black_list_word_set(fluent_anki_session)

        for word in tqdm(pobj.unique_words):
            #see if it's on the black list
            if (word not in black_list) and (not Util().has_numbers(word)):
                #length of the word should not be null
                if word:
                    wstf = Word_SourceText_Frequency(frequency = pobj.word_frequency_dict[word])
                    wstf.text_pos = pobj.unique_parse_words_dict[word].text_pos
                    wstf.tfidf = doc.tfidf(word)
                    wtype = pobj.unique_parse_words_dict[word][0].type
                    w = ExoticWord(text=word, word_type=wtype, lang=language.id)
                    wstf.words = w
                    source_text_dbobj.words.append(wstf)
                    for sentence in pobj.unique_parse_words_dict[word].suggested_sentences:
                        sent = DBWrapper().get_or_create_sentence(fluent_anki_session, sentence.string, target_language)
                        sent.words.append(w)
                        fluent_anki_session.add(sent)

        #write parsed words to database
        fluent_anki_session.add(source_text_dbobj)
        fluent_anki_session.commit() 
開發者ID:jayrod,項目名稱:fluentanki,代碼行數:38,代碼來源:Util.py

示例10: parse

# 需要導入模塊: import Parser [as 別名]
# 或者: from Parser import Parser [as 別名]
def parse(self, commands, service_name, command_name):
        main_name = "main"

        parsers = {
            main_name: Parser(prog='hive')
        }

        subparsers = {
            service_name: parsers[main_name].add_subparsers(
                title=service_name,
                dest=service_name
            )
        }

        for commandName in commands:
            command = commands[commandName]
            parsers[commandName] = subparsers[service_name].add_parser(
                commandName, help=command["help"]
            )
            subparsers[commandName] = parsers[commandName].add_subparsers(
                title=command_name, dest=command_name
            )

            for subCommandName in command["commands"]:
                sub_command = command["commands"][subCommandName]
                parsers[subCommandName] = subparsers[commandName].add_parser(
                    subCommandName, help=sub_command["help"]
                )

                if "parameters" in sub_command:
                    for parameters in sub_command["parameters"]:
                        name = parameters["name"]
                        doc = parameters["help"]
                        if "nargs" in parameters:
                            parsers[subCommandName].add_argument(
                                name,
                                help=doc,
                                nargs=parameters["nargs"]
                            )
                        elif "action" in parameters:
                            parsers[subCommandName].add_argument(
                                name,
                                help=doc,
                                action=parameters["action"],
                                const=name
                            )
                        else:
                            parsers[subCommandName].add_argument(name, help=doc)

        return parsers[main_name].parse_args() 
開發者ID:tdeheurles,項目名稱:hive,代碼行數:52,代碼來源:Menu.py


注:本文中的Parser.Parser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。