[Python-Dev] Order of operations

"Martin v. Löwis" martin at v.loewis.de
Thu Aug 30 00:33:48 CEST 2007


> True enough, however Python doesn't support negative numbers as individual
> tokens at the lexical analysis level.  -3.41 is '-' followed by '3.41'.  In
> C it's a single token resolved at compile time.

That is not true. ISO C99 defines (6.4.4.1)

               integer-constant:
                       decimal-constant integer-suffix-opt
                       octal-constant integer-suffix-opt
                       hexadecimal-constant integer-suffix-opt

               decimal-constant:
                       nonzero-digit
                       decimal-constant digit

and then (6.5.3)

               unary-expr:
                       postfix-expr
                       ++ unary-expr
                       -- unary-expr
                       unary-operator cast-expr
                       sizeof unary-expr
                       sizeof ( type-name )

               unary-operator: one of
                       &  *  +  -  ~  !

So -3.41 is definitely two tokens in C.

Regards,
Martin


More information about the Python-Dev mailing list