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


Python compiler.compile方法代碼示例

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


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

示例1: grammar

# 需要導入模塊: from prompt_toolkit.contrib.regular_languages import compiler [as 別名]
# 或者: from prompt_toolkit.contrib.regular_languages.compiler import compile [as 別名]
def grammar():
    grams = getClientGrams() + getNewClientGrams()
    return compile("".join(grams)) 
開發者ID:hyperledger-archives,項目名稱:indy-client,代碼行數:5,代碼來源:test_command_reg_ex.py

示例2: __init__

# 需要導入模塊: from prompt_toolkit.contrib.regular_languages import compiler [as 別名]
# 或者: from prompt_toolkit.contrib.regular_languages.compiler import compile [as 別名]
def __init__(self):
        # Compile grammar.
        g = compile(
            r"""
                # First we have an executable.
                (?P<executable>[^\s]+)

                # Ignore literals in between.
                (
                    \s+
                    ("[^"]*" | '[^']*' | [^'"]+ )
                )*

                \s+

                # Filename as parameters.
                (
                    (?P<filename>[^\s]+) |
                    "(?P<double_quoted_filename>[^\s]+)" |
                    '(?P<single_quoted_filename>[^\s]+)'
                )
            """,
            escape_funcs={
                'double_quoted_filename': (lambda string: string.replace('"', '\\"')),
                'single_quoted_filename': (lambda string: string.replace("'", "\\'")),
            },
            unescape_funcs={
                'double_quoted_filename': (lambda string: string.replace('\\"', '"')),  # XXX: not enterily correct.
                'single_quoted_filename': (lambda string: string.replace("\\'", "'")),
            })

        # Create GrammarCompleter
        super(SystemCompleter, self).__init__(
            g,
            {
                'executable': ExecutableCompleter(),
                'filename': PathCompleter(only_directories=False, expanduser=True),
                'double_quoted_filename': PathCompleter(only_directories=False, expanduser=True),
                'single_quoted_filename': PathCompleter(only_directories=False, expanduser=True),
            }) 
開發者ID:chrisjim316,項目名稱:Liljimbo-Chatbot,代碼行數:42,代碼來源:system.py

示例3: _create_grammar

# 需要導入模塊: from prompt_toolkit.contrib.regular_languages import compiler [as 別名]
# 或者: from prompt_toolkit.contrib.regular_languages.compiler import compile [as 別名]
def _create_grammar():
    patterns = map(_build_pattern, [
        (command, operand_pattern)
        for (command, (_, operand_pattern, _)) in COMMANDS.items()])
    patterns = '|'.join(patterns)
    return compiler.compile(patterns) 
開發者ID:kevinjqiu,項目名稱:cdbcli,代碼行數:8,代碼來源:grammar.py

示例4: initializeGrammar

# 需要導入模塊: from prompt_toolkit.contrib.regular_languages import compiler [as 別名]
# 或者: from prompt_toolkit.contrib.regular_languages.compiler import compile [as 別名]
def initializeGrammar(self):
        # TODO Do we really need both self.allGrams and self.grams
        self.grams = getAllGrams(*self.allGrams)
        self.grammar = compile("".join(self.grams)) 
開發者ID:hyperledger,項目名稱:indy-plenum,代碼行數:6,代碼來源:cli.py

示例5: grammar

# 需要導入模塊: from prompt_toolkit.contrib.regular_languages import compiler [as 別名]
# 或者: from prompt_toolkit.contrib.regular_languages.compiler import compile [as 別名]
def grammar():
    utilGrams = getUtilGrams()
    nodeGrams = getNodeGrams()
    clientGrams = getClientGrams()
    grams = getAllGrams(utilGrams, nodeGrams, clientGrams)
    return compile("".join(grams)) 
開發者ID:hyperledger,項目名稱:indy-plenum,代碼行數:8,代碼來源:test_command_reg_ex.py


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