def build_compound(builder: Builder, lineno: int, token: str, value: typing.Any) -> bool: assert token in compound_tokens stmt, nodes = value builder.add(lineno, stmt) builder.start_block() builder.build_block(nodes) builder.end_block() return True
def build_render(builder: Builder, lineno: int, token: str, nodes: typing.Iterable[Token]) -> bool: assert lineno <= 0 assert token == "render" builder.add(lineno, WRITER_DECLARE) builder.build_block(nodes) lineno = builder.lineno builder.add(lineno + 1, WRITER_RETURN) return True
def build_def(builder: Builder, lineno: int, token: str, value: typing.Any) -> bool: assert token == "def " stmt, nodes = value def_name = stmt[4:stmt.index("(", 5)] builder.add(lineno, stmt) builder.start_block() builder.add(lineno + 1, WRITER_DECLARE) builder.build_block(nodes) lineno = builder.lineno builder.add(lineno, WRITER_RETURN) builder.end_block() builder.add( lineno + 1, def_name.join(( "super_defs['", "'] = ", "; ", " = local_defs.setdefault('", "', ", ")", )), ) return True
def build_out(builder: Builder, lineno: int, token: str, nodes: typing.Iterable[Token]) -> bool: assert token == "out" builder.build_block(nodes) return True