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


Python pyparsing.Empty方法代码示例

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


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

示例1: _make_matcher_element

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import Empty [as 别名]
def _make_matcher_element(self):
        return self._set_matcher_element_attributes(pyparsing.Empty()) 
开发者ID:Danesprite,项目名称:pyjsgf,代码行数:4,代码来源:expansions.py

示例2: _ParseFieldsMetadata

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import Empty [as 别名]
def _ParseFieldsMetadata(self, structure):
    """Parses the fields metadata and updates the log line definition to match.

    Args:
      structure (pyparsing.ParseResults): structure parsed from the log file.
    """
    fields = self._GetValueFromStructure(structure, 'fields', default_value='')
    fields = fields.strip()
    fields = fields.split(' ')

    log_line_structure = pyparsing.Empty()
    if fields[0] == 'date' and fields[1] == 'time':
      log_line_structure += self.DATE_TIME.setResultsName('date_time')
      fields = fields[2:]

    for member in fields:
      log_line_structure += self._LOG_LINE_STRUCTURES.get(member, self.URI)

    updated_structures = []
    for line_structure in self._line_structures:
      if line_structure[0] != 'logline':
        updated_structures.append(line_structure)
    updated_structures.append(('logline', log_line_structure))
    # TODO: self._line_structures is a work-around and this needs
    # a structural fix.
    self._line_structures = updated_structures 
开发者ID:log2timeline,项目名称:plaso,代码行数:28,代码来源:iis.py

示例3: _match_boolean

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import Empty [as 别名]
def _match_boolean(literal):
    return (
        literal
        + pyparsing.Empty().setParseAction(pyparsing.replaceWith("="))
        + pyparsing.Empty().setParseAction(pyparsing.replaceWith(True))
    ) 
开发者ID:Mergifyio,项目名称:mergify-engine,代码行数:8,代码来源:parser.py

示例4: parseWithLocation

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import Empty [as 别名]
def parseWithLocation(expr, action):
  startMarker = p.Empty().setParseAction(lambda s, loc, t: loc)
  endMarker = startMarker.copy()
  complete = startMarker + expr + endMarker
  startMarker.setName(str(expr))

  def parseAction(s, loc, t):
    start, inner_tokens, end = t[0], t[1:-1], t[-1]
    src_loc = SourceLocation(s, start, end)
    return callParseAction(action, src_loc, inner_tokens)

  complete.setParseAction(parseAction)
  return complete 
开发者ID:rix0rrr,项目名称:gcl,代码行数:15,代码来源:ast.py

示例5: bracketedList

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import Empty [as 别名]
def bracketedList(l, r, sep, expr, allow_missing_close=False):
  """Parse bracketed list.

  Empty list is possible, as is a trailing separator.
  """
  # We may need to backtrack for lists, because of list comprehension, but not for
  # any of the other lists
  strict = l != '['
  closer = sym(r) if not allow_missing_close else p.Optional(sym(r))
  if strict:
    return sym(l) - listMembers(sep, expr) - closer
  else:
    return sym(l) + listMembers(sep, expr) + closer 
开发者ID:rix0rrr,项目名称:gcl,代码行数:15,代码来源:ast.py

示例6: _make_matcher_element

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import Empty [as 别名]
def _make_matcher_element(self):
        # Handle the case where use_current_match is True.
        if self.use_current_match is True:
            current_match = self.current_match
            if current_match is None:
                result = pyparsing.NoMatch()
            elif current_match == "":
                result = pyparsing.Empty()
            else:
                result = pyparsing.Literal(self.current_match)

            # Set the parse action and return the element.
            return result.setParseAction(self._parse_action)

        # Otherwise build a list of next possible literals. Make the required stack
        # of child-parent pairs.
        stack = []
        p1, p2 = self, self.parent
        while p1 and p2:
            stack.append((p1, p2))

            # Move both pivots further up the tree.
            p1 = p1.parent
            p2 = p2.parent

        # Build a list of next literals using the stack.
        next_literals, _ = _collect_next_literals(stack, 0, True, False)

        # De-duplicate the list.
        next_literals = set(next_literals)

        word = pyparsing.Regex(_word_regex_str, re.UNICODE)
        if next_literals:
            # Check if there is a next dictation literal. If there is, only match
            # one word for this expansion.
            if _word_regex_str in next_literals:
                result = word

            # Otherwise build an element to match one or more words stopping on
            # any of the next literals so that they aren't matched as dictation.
            else:
                next_literals = list(map(pyparsing.Literal, next_literals))
                result = pyparsing.OneOrMore(
                    word, stopOn=pyparsing.Or(next_literals)
                )
        else:
            # Handle the case of no literals ahead by allowing one or more Unicode
            # words without restrictions.
            result = pyparsing.OneOrMore(word)

        return self._set_matcher_element_attributes(result) 
开发者ID:Danesprite,项目名称:pyjsgf,代码行数:53,代码来源:expansions.py


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