当前位置: 首页>>代码示例>>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;未经允许,请勿转载。