本文整理汇总了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
示例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
示例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
示例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'