本文整理汇总了Python中pyparsing.SkipTo方法的典型用法代码示例。如果您正苦于以下问题:Python pyparsing.SkipTo方法的具体用法?Python pyparsing.SkipTo怎么用?Python pyparsing.SkipTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyparsing
的用法示例。
在下文中一共展示了pyparsing.SkipTo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _parse_duplicate
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def _parse_duplicate(self, line: str) -> Optional[int]:
if not self._is_support_packet_duplicate:
return None
packet_pattern = (
pp.SkipTo(pp.Word("+" + pp.nums) + pp.Literal("duplicates,"))
+ pp.Word("+" + pp.nums)
+ pp.Literal("duplicates,")
)
try:
duplicate_parse_list = packet_pattern.parseString(_to_unicode(line))
except pp.ParseException:
return 0
return int(duplicate_parse_list[-2].strip("+"))
示例2: _preprocessor_directive
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def _preprocessor_directive(self):
return (_SHARP.suppress()
+ _PREPROCESSOR_KEYWORD
+ pyparsing.SkipTo(pyparsing.lineEnd))
示例3: _struct_definition
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def _struct_definition():
return (
(_STRUCT.setResultsName("type") | _UNION.setResultsName("type"))
+ _IDENTIFIER.setResultsName("name")
+ parsers.anything_in_curly()
+ pyparsing.SkipTo(_SEMICOLON)
+ _SEMICOLON
).setResultsName("_struct_definition")
示例4: _struct_typedef
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def _struct_typedef():
return (
_TYPEDEF
+ (_STRUCT.setResultsName("type") | _UNION.setResultsName("type"))
+ pyparsing.Optional(_IDENTIFIER).setResultsName("id")
+ parsers.anything_in_curly()
+ pyparsing.Optional(_STAR)
+ _IDENTIFIER.setResultsName("typedef_name")
+ pyparsing.SkipTo(_SEMICOLON)
+ _SEMICOLON
).setResultsName("_struct_typedef")
示例5: _simple_typedef
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def _simple_typedef():
return (
_TYPEDEF
+ pyparsing.SkipTo(_SEMICOLON)
+ _SEMICOLON
).setResultsName("_simple_typedef")
示例6: _enum_definition
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def _enum_definition(self):
"""Detect an enum definition.
e.g.
enum foo {
OPTION_1: 1 + 2,
OPTION_2
}
"""
return (
_ENUM
+ pyparsing.Optional(self._identifier())("enum_name")
+ _OPEN_CURLY
+ pyparsing.ZeroOrMore(
pyparsing.Group(
self._identifier()("name")
+ pyparsing.Optional(
_EQUALS
# This allows us to get even invalid expressions.
+ pyparsing.SkipTo(pyparsing.Word(",}"))("expression")
)
+ pyparsing.Optional(_COMMA)
)
)("fields")
+ _CLOSE_CURLY
+ self._maybe_attributes()("attributes")
).setParseAction(self._process_enum_definition)
示例7: condition_section
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def condition_section():
return (_IDENTIFIER +
_COLON +
pyparsing.SkipTo(_RIGHT_CURLY).setResultsName("statement")
).setResultsName("condition")
示例8: __parse_netem_delay_distro
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def __parse_netem_delay_distro(self, line):
parse_param_name = "delay"
pattern = (
pp.SkipTo(parse_param_name, include=True)
+ pp.Word(pp.nums + ".msu")
+ pp.Word(pp.nums + ".msu")
)
try:
parsed_list = pattern.parseString(line)
self.__parsed_param[parse_param_name] = parsed_list[2]
self.__parsed_param["delay-distro"] = parsed_list[3]
except pp.ParseException:
pass
示例9: __parse_netem_param
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def __parse_netem_param(self, line, parse_param_name, word_pattern, key_name=None):
pattern = pp.SkipTo(parse_param_name, include=True) + pp.Word(word_pattern)
if not key_name:
key_name = parse_param_name
try:
result = pattern.parseString(line)[-1]
if typepy.is_not_null_string(result):
self.__parsed_param[key_name] = result
except pp.ParseException:
pass
示例10: __parse_bandwidth_rate
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def __parse_bandwidth_rate(self, line):
parse_param_name = "rate"
pattern = pp.SkipTo(parse_param_name, include=True) + pp.Word(pp.alphanums + "." + ":")
try:
result = pattern.parseString(line)[-1]
if typepy.is_not_null_string(result):
result = result.rstrip("bit")
self.__parsed_param[parse_param_name] = result
except pp.ParseException:
pass
示例11: __parse_tc_filter_network
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def __parse_tc_filter_network(text):
network_pattern = pp.SkipTo("{:s}=".format(Tc.Param.DST_NETWORK), include=True) + pp.Word(
pp.alphanums + "." + "/"
)
return network_pattern.parseString(text)[-1]
示例12: __parse_tc_filter_src_port
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import SkipTo [as 别名]
def __parse_tc_filter_src_port(text):
port_pattern = pp.SkipTo("{:s}=".format(Tc.Param.SRC_PORT), include=True) + pp.Word(pp.nums)
return port_pattern.parseString(text)[-1]