[Compiler-sig] if .. elif:

Finn Bock bckfnn@worldonline.dk
Sat, 13 Apr 2002 13:02:40 GMT


Hi

Maybe I'm missing something, but I think the If() constructor is a bit
too simple to handle a list of 'elif:' parts.

	If(expr test, stmt* body, stmt* orelse)


This here is my take on a solution:


Index: python.asdl
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/ast/python.asdl,v
retrieving revision 1.9
diff -w -u -r1.9 python.asdl
--- python.asdl 11 Apr 2002 21:20:19 -0000      1.9
+++ python.asdl 13 Apr 2002 12:55:43 -0000
@@ -19,7 +19,7 @@
              -- need a better solution for that
              | For(expr target, expr iter, stmt* body, stmt* orelse)
              | While(expr test, stmt* body, stmt* orelse)
-             | If(expr test, stmt* body, stmt* orelse)
+             | If(ifpart* tests, stmt* orelse)

              -- 'type' is a bad name
              | Raise(expr? type, expr? inst, expr? tback)
@@ -96,4 +96,6 @@

         -- keyword arguments supplied to call
         keyword = (identifier arg, expr value)
+
+        ifpart = (expr test, stmt* body)
 }


regards,
finn