POV-Ray : Newsgroups : povray.beta-test : Bug List : Re: Bug List Server Time
28 Jul 2024 18:20:39 EDT (-0400)
  Re: Bug List  
From: Warp
Date: 6 Feb 2008 05:14:39
Message: <47a9888e@news.povray.org>
Tim Attwood <tim### [at] comcastnet> wrote:
> // misformed #declare
> #declare Weird = #declare Aval = 1;

> // other properly formed statements
> #declare PigVal = pigment {rgb <0,0,0>};
> #declare ObjVal = sphere {<0,0,0>,1};

> #if (true=true)
> #local c=0;
> #while (c=0)

> // this object ends the misformed #declare and doesn't render
> object {pass_text}

  It's not "misformed" from the point of view of the parser. It's just
a side-effect of the recursive nature of parsing #-commands. #-commands
can be embedded almost everywhere (which is sometimes necessary to make
some things work), often even in-between other #-commands.

  I'm not sure how the parser could be modified to raise a warning
about this. It simply doesn't see anything wrong with it, as it works
in an entirely logical way.

  I'm not saying the current way of parsing is perfect. It does sometimes
cause problems. For example, I just can't implement a + operator for
strings even though I really would have wanted to, and it's due to this
parsing logic. The problem is that if the parser checks for every string
element if a '+' follows it, it messes up #debug. For instance this:

#debug "a\n"
#debug "b\n"

will print:

b
a

  That's because after "a\n" it checks if a '+' follows, and while doing
that it parses the second #debug, after which it sees that no '+' follows,
after which it finishes parsing the first #debug, and thus the lines are
printed in the wrong order.
  (It's possible to temporarily disallow parsing of #-commands, but that
breaks things too if I try to use it to check for the '+'. It will parse
the next '#' as an independent token, after which there's no way to
easily re-join it with the 'debug' following it, which will then cause
a parsing error because the parser just sees a lone '#' symbol.)

  But anyways, even though this way of parsing is not perfect, it's logical
and quite flexible. Being able to embed #-commands almost everywhere is
quite handy. That way you can embed eg. loops inside object definitions, etc.

-- 
                                                          - Warp


Post a reply to this message

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