pyrser/passes/topython.py
def visit_Capture(self, node: parsing.Capture) -> [ast.stmt] or ast.expr:
        """Generates python code to capture text consumed by a clause.

        #If all clauses can be inlined
        self.beginTag('tagname') and clause and self.endTag('tagname')

        if not self.beginTag('tagname'):
            return False
        <code for the clause>
        if not self.endTag('tagname'):
            return False
        """
        begintag = ast.Attribute(
            ast.Name('self', ast.Load()), 'beginTag', ast.Load())
        endtag = ast.Attribute(
            ast.Name('self', ast.Load()), 'endTag', ast.Load())
        begin = ast.Call(begintag, [ast.Str(node.tagname)], [], None, None)
        end = ast.Call(endtag, [ast.Str(node.tagname)], [], None, None)
        result = [begin, self.visit(node.pt), end]
        for clause in result:
            if not isinstance(clause, ast.expr):
                break
        else:
            return ast.BoolOp(ast.And(), result)
        res = []
        for stmt in map(self._clause, result):
            res.extend(stmt)
        return res
def visit_Capture(self, node: parsing.Capture) -> [ast.stmt] or ast.expr:
        """Generates python code to capture text consumed by a clause.

        #If all clauses can be inlined
        self.beginTag('tagname') and clause and self.endTag('tagname')

        if not self.beginTag('tagname'):
            return False
        <code for the clause>
        if not self.endTag('tagname'):
            return False
        """
        begintag = ast.Attribute(
            ast.Name('self', ast.Load()), 'beginTag', ast.Load())
        endtag = ast.Attribute(
            ast.Name('self', ast.Load()), 'endTag', ast.Load())
        begin = ast.Call(begintag, [ast.Str(node.tagname)], [], None, None)
        end = ast.Call(endtag, [ast.Str(node.tagname)], [], None, None)
        result = [begin, self.visit(node.pt), end]
        for clause in result:
            if not isinstance(clause, ast.expr):
                break
        else:
            return ast.BoolOp(ast.And(), result)
        res = []
        for stmt in map(self._clause, result):
            res.extend(stmt)
        return res
Generates python code to capture text consumed by a clause.

        #If all clauses can be inlined
        self.beginTag('tagname') and clause and self.endTag('tagname')

        if not self.beginTag('tagname'):
            return False
        <code for the clause>
        if not self.endTag('tagname'):
            return False