当前位置: 首页>>代码示例>>Python>>正文


Python OneOrMore.parseWithTabs方法代码示例

本文整理汇总了Python中pyparsing.OneOrMore.parseWithTabs方法的典型用法代码示例。如果您正苦于以下问题:Python OneOrMore.parseWithTabs方法的具体用法?Python OneOrMore.parseWithTabs怎么用?Python OneOrMore.parseWithTabs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyparsing.OneOrMore的用法示例。


在下文中一共展示了OneOrMore.parseWithTabs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sdio_ids_grammar

# 需要导入模块: from pyparsing import OneOrMore [as 别名]
# 或者: from pyparsing.OneOrMore import parseWithTabs [as 别名]
def sdio_ids_grammar():
    vendor_line = NUM4('vendor') + text_eol('text')
    device_line = TAB + NUM4('device') + text_eol('text')
    vendor = (vendor_line('VENDOR') +
              ZeroOrMore(device_line('DEVICES*') ^ COMMENTLINE.suppress()))

    klass = klass_grammar()

    commentgroup = OneOrMore(COMMENTLINE).suppress() ^ EMPTYLINE.suppress()
    grammar = OneOrMore(vendor('VENDORS*') ^ klass('CLASSES*') ^ commentgroup) + stringEnd()

    grammar.parseWithTabs()
    return grammar
开发者ID:OpenDZ,项目名称:systemd,代码行数:15,代码来源:ids_parser.py

示例2: usb_ids_grammar

# 需要导入模块: from pyparsing import OneOrMore [as 别名]
# 或者: from pyparsing.OneOrMore import parseWithTabs [as 别名]
def usb_ids_grammar():
    vendor_line = NUM4('vendor') + text_eol('text')
    device_line = TAB + NUM4('device') + text_eol('text')
    vendor = (vendor_line('VENDOR') +
             ZeroOrMore(device_line('VENDOR_DEV*') ^ COMMENTLINE.suppress()))

    klass = klass_grammar()

    other_line = (Literal('AT ') ^ Literal('HID ') ^ Literal('R ')
                  ^ Literal('PHY ') ^ Literal('BIAS ') ^ Literal('HUT ')
                  ^ Literal('L ') ^ Literal('VT ') ^ Literal('HCC ')) + text_eol('text')
    other_group = (other_line - ZeroOrMore(TAB + text_eol('text')))

    commentgroup = OneOrMore(COMMENTLINE).suppress() ^ EMPTYLINE.suppress()
    grammar = OneOrMore(vendor('VENDORS*') ^ klass('CLASSES*')
                        ^ other_group.suppress() ^ commentgroup) + stringEnd()

    grammar.parseWithTabs()
    return grammar
开发者ID:OpenDZ,项目名称:systemd,代码行数:21,代码来源:ids_parser.py

示例3: pci_ids_grammar

# 需要导入模块: from pyparsing import OneOrMore [as 别名]
# 或者: from pyparsing.OneOrMore import parseWithTabs [as 别名]
def pci_ids_grammar():
    vendor_line = NUM4('vendor') + text_eol('text')
    device_line = TAB + NUM4('device') + text_eol('text')
    subvendor_line = TAB + TAB + NUM4('a') + White(' ') + NUM4('b') + text_eol('name')

    device = (device_line('DEVICE') +
              ZeroOrMore(Group(subvendor_line)('SUBVENDORS*') ^ COMMENTLINE.suppress()))
    vendor = (vendor_line('VENDOR') +
              ZeroOrMore(Group(device)('DEVICES*') ^ COMMENTLINE.suppress()))

    klass = klass_grammar()

    commentgroup = OneOrMore(COMMENTLINE).suppress() ^ EMPTYLINE.suppress()
    grammar = OneOrMore(Group(vendor)('VENDORS*')
                        ^ Group(klass)('CLASSES*')
                        ^ commentgroup) + stringEnd()

    grammar.parseWithTabs()
    return grammar
开发者ID:coreos,项目名称:systemd,代码行数:21,代码来源:ids_parser.py

示例4: Regex

# 需要导入模块: from pyparsing import OneOrMore [as 别名]
# 或者: from pyparsing.OneOrMore import parseWithTabs [as 别名]
create_keyspace.setParseAction(ParseActionSimple('CREATE KEYSPACE'))

# Comments
# It would be nice to remove comments in the lexing stage, except that
# they are not part of the language that cassandra understands: they are
# part of cqlsh. Instead mark them as special chunks and skip them in
# the executor. This means that comments may only appear between
# statements.
comment = Regex('(--|//)[^\n]*') + lineEnd

comment.setParseAction(ParseActionSimple('COMMENT'))

cql = OneOrMore(ctable | alter | update | insert | create_keyspace | comment)

cql.enablePackrat()
cql.parseWithTabs()


class CqlChunk(object):
    def __init__(self, src, chunk_type, info, start, end):
        self.src = src
        self.chunk_type = chunk_type
        self.info = info
        self.start = start
        self.end = end
    def body(self):
        return self.src[self.start:self.end].strip()
    def is_update(self):
        return self.chunk_type == 'UPDATE'
    def is_comment(self):
        return self.chunk_type == 'COMMENT'
开发者ID:advancedtelematic,项目名称:cql-migrate,代码行数:33,代码来源:split.py


注:本文中的pyparsing.OneOrMore.parseWithTabs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。