POV-Ray : Newsgroups : povray.general : Parser oddities (sum/prod and others) : Parser oddities (sum/prod and others) Server Time
30 Jul 2024 00:31:06 EDT (-0400)
  Parser oddities (sum/prod and others)  
From: Bent
Date: 19 Apr 2010 17:35:01
Message: <web.4bcccb967190038c2ca8bd450@news.povray.org>
Oddly, sum and prod are considered to be numbers -- when POV-Ray is looking for
numbers:

#debug concat("sum = ",str(sum,0,3),"; prod = ",str(prod,0,3),"\n")


So far as I can tell, this is due to a discrepancy between
'backend/parser/reswords.h' and 'backend/parser/express.cpp'.  Specifically,
SUM_TOKEN and PROD_TOKEN both appear before FLOAT_FUNCT_TOKEN in the TOKEN_IDS
enum (reswords.h), so they get treated as float functions (when POV-Ray isn't
doing function compilation); however, neither SUM_TOKEN nor PROD_TOKEN is
handled in Parser::Parse_Num_Factor (express.cpp), so they fall through the
switch statement beginning on line 687.  The result is that whatever is sitting
in the memory location for Val gets returned as being the value of 'sum' or
'prod' (for me, this tends to be a denormalized number).

[Note that the source references are from the 3.7.0.beta.35a source...]




Also, I was curious why POV-Ray is only picky about argument delimiters (that
is, commas) some of the time.

For instance, POV-Ray is perfectly happy with this:

#macro A(b c)b+c#end
#declare a=0;
#declare b=A(1a);
#declare f=function{A(a.3)+A(A(1a)1)}
#debug str(b(0)3)
#debug"\n"
#debug str(pow(3!1)0(3))
#debug "\n"
#debug str(f(0
0a)0 3)
#debug "\n"
#debug vstr(3x"a"1!2+2)
#debug "\n"


However, it is not happy with this:

#declare f=function{pow(3!1)}


It isn't happy with this, either:

#macro A(b(c))b+c#end


Nor this:

#macro A(b c)b+c#end
#declare a=0;
#declare b=A(1A(1a));


Nor this:

#debug("a\n")



Why?




(For reference, I'm using the unofficial 64-bit Mac version of POV-Ray
3.7.0.beta.36 provided by the MegaPOV-Team; however, all of the oddities also
occur under a self-compiled (unofficial) version of POV-Ray 3.6.1.  I'm running
Mac OS X 10.6.3 on an Intel Core 2 Duo with 4 GB of memory.)


Bent


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.