[Compiler-sig] Number classes

Finn Bock bckfnn@worldonline.dk
Fri, 19 Apr 2002 14:43:36 GMT


Hi,

I would like to seperate the number types in some way. I have used 
the patch below in jython but adding a flag to the Num() ctor would
also be fine. I think this is needed because all my codegens need
to generate different code for each of the number types.

Also, I have the information available from my lexer and it would be
a pity to loose the info just to recreate it again in the visitNum()
method.

             | Call(expr func, expr* args, keyword* keywords,
                         expr? starargs, expr? kwargs)
             | Repr(expr value)
-            | Num(string n) -- string representation of a number
+            | IntNum(string n) -- string representation of a integer
+            | FloatNum(string n) -- string representation of a float 
+            | LongNum(string n) -- string representation of a long
+            | ComplexNum(string n) -- string representation of a complex
             | Str(string s) -- need to specify raw, unicode, etc?
             -- other literals? bools?

['Float' and 'Long' are unfortunate classnames in java]

I think the compiler package also have the number type available as
the type of the Const() argument and that solution would be even 
better but I don't know how to express that in asdl. Could we invent
an anonymous 'object' builtin asdl type?

Thoughts?

regards,
finn