Пример #1
0
def setLoggingDebugActionForParserElement(
        parser_element: pyparsing.ParserElement) -> None:
    '''
    helper function to set up the custom debug actions for a ParserElement with our
    own functions that use the logging framework rather than `print()`

    this also calls setDebug(True) for the parser element as well
    '''

    parser_element.setDebug(True)

    parser_element.setDebugActions(pyparsingLoggingStartDebugAction,
                                   pyparsingLoggingSuccessDebugAction,
                                   pyparsingLoggingExceptionDebugAction)
Пример #2
0
 def add_element(name: str, value: pp.ParserElement):
     nonlocal self
     if self.debug:
         value.setName(name)
         value.setDebug()
     return value