|
|
Hi ... I'm not sure if I'm right, and if I should post this here or
in p.bugreports ...
I saw this behaviour still in MP06a but I detected it first Time in
MP04 ... maybe it's the full MP-Codeline ...
I declared an Array :
#declare A=array[100]
and in the following instruction I want to declare a variable,
using the "$"-Operator I get an Errormessage ...
$B=1;
Here iss my File:
>--------------------------------
#version unofficial MegaPov 0.3;
#declare a=array[16]
$b=1;
#include "stdenv.inc"
>-----------------
Running on MP04 I get
the Output:
>--------------------
Parsing...This file was designed for (unofficial) MegaPov version
0.3. You are using version 0.4.
Some features may have changed.
#version unofficial MegaPov 0.3;
#declare a=array[16]
$ <----ERROR
bugtest.pov:4: error: object or directive expected but $ found
instead.
>----------------------
When changing to
#declare b=1;
everything is OK ....
Should it be posted to p.bugreports ???
Post a reply to this message
|
|
|
|
On Thu, 02 Nov 2000 11:55:33 GMT, wal### [at] informatikuni-hallede wrote:
>Hi ... I'm not sure if I'm right, and if I should post this here or
>in p.bugreports ...
[snip]
>Should it be posted to p.bugreports ???
p.bugreports is only for bugs in the official version. This is the correct
place for bugs in custom versions.
--
Ron Parker http://www2.fwi.com/~parkerr/traces.html
My opinions. Mine. Not anyone else's.
Post a reply to this message
|
|
|
|
<wal### [at] informatikuni-hallede> wrote...
> I declared an Array :
>
> #declare A=array[100]
>
> and in the following instruction I want to declare a variable,
> using the "$"-Operator I get an Errormessage ...
>
> $B=1;
Yes, this is known limitation (a bug that is too difficult to fix that I
won't bother).
The following three code snipets will work:
#declare a=array[16]
#declare b=1;
$a=array[16]
$b=1;
$a=array[16]
#declare b=1; //I'm pretty sure this will work
The following one will not:
#declare a=array[16]
$b=1;
The problem occurs when you use of a #declare that does NOT end with a
semicolon, followed by a $.
Here is an explanation of why it acts this way and why I haven't fixed it:
All "#" directives in POV (such as #declare and #local) are handled
specially. When the Get_Token() function (responsible for reading and
interpreting the character input) finds a "#" character, it interrupts what
it is doing and calls the Parse_Directive() function. Regular scene parsing
is suspended until POV is done parsing the directive.
Now, just like the rest of the parser, Parse_Directive() uses Get_Token() to
get its tokens. This means that if POV wasn't careful, it could get a stack
overflow if you have a long string of #declares one right after another.
Why? Well, if Get_Token() finds a "#" (such as in my first code snipet)
while it is parsing a #declare, it calls Parse_Directive().
The trick is to make Parse_Directive() contain a loop, and add a special
case for Get_Token() so it won't allow a re-entry of Parse_Directive(). If
Parse_Directive() is active and Get_Token() hits a "#", it will ignore it
and allow Parse_Directive() to take care of it.
I built this same looping capability into the "$" replacement for
"#declare". However, the two loops are independent from each other.
Because of the way Parse_Directive() works, I'm pretty sure that you can
enter Parse_Directive() from my "$" replacement, but you can't go the other
way.
The best solution would be to force all #declares to end with a semicolon,
so the parser knows exactly when the directive is complete and it can return
from Parse_Directive() without having to have that messy loop and special
re-entry flag. Of course, that would break more scenes, but I think it
would be best. It would also add consistency to the parser, because now you
need a semicolon for #declaring floats and vectors, but you CANNOT have a
semicolon when declaring arrays, textures, pigments, etc. That semicolon
would be useful for avoiding accidental layered textures, too.
-Nathan
Post a reply to this message
|
|
|
|
This is one reason why all #declares in povray should end with a semicolon.
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|