Python pyparsing.SkipTo() Examples
The following are 13
code examples of pyparsing.SkipTo().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyparsing
, or try the search function
.
Example #1
Source File: _parser.py From pingparsing with MIT License | 6 votes |
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("+"))
Example #2
Source File: preprocessing_parser.py From rekall with GNU General Public License v2.0 | 5 votes |
def _preprocessor_directive(self): return (_SHARP.suppress() + _PREPROCESSOR_KEYWORD + pyparsing.SkipTo(pyparsing.lineEnd))
Example #3
Source File: trimming_parser.py From rekall with GNU General Public License v2.0 | 5 votes |
def _struct_definition(): return ( (_STRUCT.setResultsName("type") | _UNION.setResultsName("type")) + _IDENTIFIER.setResultsName("name") + parsers.anything_in_curly() + pyparsing.SkipTo(_SEMICOLON) + _SEMICOLON ).setResultsName("_struct_definition")
Example #4
Source File: trimming_parser.py From rekall with GNU General Public License v2.0 | 5 votes |
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")
Example #5
Source File: trimming_parser.py From rekall with GNU General Public License v2.0 | 5 votes |
def _simple_typedef(): return ( _TYPEDEF + pyparsing.SkipTo(_SEMICOLON) + _SEMICOLON ).setResultsName("_simple_typedef")
Example #6
Source File: c_parser.py From rekall with GNU General Public License v2.0 | 5 votes |
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)
Example #7
Source File: yara_support.py From rekall with GNU General Public License v2.0 | 5 votes |
def condition_section(): return (_IDENTIFIER + _COLON + pyparsing.SkipTo(_RIGHT_CURLY).setResultsName("statement") ).setResultsName("condition")
Example #8
Source File: _qdisc.py From tcconfig with MIT License | 5 votes |
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
Example #9
Source File: _qdisc.py From tcconfig with MIT License | 5 votes |
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
Example #10
Source File: _qdisc.py From tcconfig with MIT License | 5 votes |
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
Example #11
Source File: _importer.py From tcconfig with MIT License | 5 votes |
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]
Example #12
Source File: _importer.py From tcconfig with MIT License | 5 votes |
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]
Example #13
Source File: _parser.py From pingparsing with MIT License | 5 votes |
def _parse_duplicate(self, line: str) -> int: 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])