def StmtIfElse(): yield ps.token(TOKEN.IF) yield ps.token(TOKEN.PAR_OPEN) condition = yield Exp yield ps.token(TOKEN.PAR_CLOSE) yield ps.token(TOKEN.CURL_OPEN) if_contents = yield ps.many(Stmt) yield ps.token(TOKEN.CURL_CLOSE) first_cond = AST.CONDBRANCH(expr=condition, stmts=if_contents) elifs = yield ps.many(StmtElif) elses = yield ps.times(StmtElse, 0, 1) return AST.IFELSE(condbranches=[first_cond, *elifs, *elses])
stmts=[ AST.STMT( val=AST.RETURN(expr=None)), AST.STMT(val=AST.IFELSE(condbranches=[ AST.CONDBRANCH(expr=AST.DEFERREDEXPR(contents=[ Token(None, TOKEN.IDENTIFIER, "x"), Token(None, TOKEN.OP_IDENTIFIER, "=="), Token(None, TOKEN.IDENTIFIER, "y") ]), stmts=[ AST.STMT(val=AST.RETURN( expr=None)) ]), AST.CONDBRANCH(expr=AST.DEFERREDEXPR(contents=[ Token(None, TOKEN.IDENTIFIER, "x"), Token(None, TOKEN.OP_IDENTIFIER, "=="), Token(None, TOKEN.IDENTIFIER, "y") ]), stmts=[ AST.STMT(val=AST.RETURN( expr=None)) ]), AST.CONDBRANCH(expr=None, stmts=[ AST.STMT(val=AST.RETURN( expr=None)) ]) ])) ]) ]) ])