POV-Ray : Newsgroups : povray.advanced-users : Parse weirdness Server Time
31 Oct 2024 21:30:11 EDT (-0400)
  Parse weirdness (Message 1 to 7 of 7)  
From: Andrew C on Mozilla
Subject: Parse weirdness
Date: 6 Jun 2004 10:55:26
Message: <40c3305e$1@news.povray.org>
Here's an interesting one for you...

I've got a scene that won't parse; I get an error message half way 
through one of the include files. Here's a snippet of the source:

-----
#declare Thingy =
object
{
   sphere...
-----

I get an error on the line with the open bracket. The error reads

Parse Error: Expected 'object or directive', { found instead.

...ok, so that's strange.

But is gets stranger... if I comment out a certain macro call, the error 
dissapears! :-0 (The scene renders correctly. Trouble is, the bit I have 
to comment out is the main animation control function!)

* * *

OK, so I've now spent about 2 hours trying to find a cause for this 
bizzare behaviour... I eventually tracked down the source; there was an 
#fclose command without a file handle.

This is really irritating. Why can't POV-Ray just issue and error 
message if you reach the #end of a macro and the target for #fclose 
hasn't been reached yet?

Andrew @ home.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Parse weirdness
Date: 6 Jun 2004 16:00:02
Message: <40c377c2$1@news.povray.org>
In article <40c3305e$1@news.povray.org> , Andrew C on Mozilla 
<voi### [at] devnull>  wrote:

> Here's an interesting one for you...
>
> I've got a scene that won't parse; I get an error message half way
> through one of the include files. Here's a snippet of the source:
>
> -----
> #declare Thingy =
> object
> {
>    sphere...
> -----
>
> I get an error on the line with the open bracket. The error reads
>
> Parse Error: Expected 'object or directive', { found instead.
>
> ...ok, so that's strange.

Without a complete but minimal scene, I don't think there is a way to help
you.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Andrew C on Mozilla
Subject: Re: Parse weirdness
Date: 8 Jun 2004 16:24:53
Message: <40c62095@news.povray.org>
> Without a complete but minimal scene, I don't think there is a way to help
> you.

The scene I have is *huge*. It will take you years to wade through it all.

If I can come up with something more minimal, I'll post it.

Thanks.
Andrew @ home.


Post a reply to this message

From: stephen parkinson
Subject: Re: Parse weirdness
Date: 8 Jun 2004 16:47:03
Message: <40c625c7$1@news.povray.org>
Andrew C on Mozilla wrote:
> Here's an interesting one for you...
> 
> I've got a scene that won't parse; I get an error message half way 
> through one of the include files. Here's a snippet of the source:
> 
> -----
> #declare Thingy =
> object
> {
>   sphere...
> -----
> 
> I get an error on the line with the open bracket. The error reads
> 
> Parse Error: Expected 'object or directive', { found instead.
> 
> ....ok, so that's strange.
> 
> But is gets stranger... if I comment out a certain macro call, the error 
> dissapears! :-0 (The scene renders correctly. Trouble is, the bit I have 
> to comment out is the main animation control function!)
> 
> * * *
> 
> OK, so I've now spent about 2 hours trying to find a cause for this 
> bizzare behaviour... I eventually tracked down the source; there was an 
> #fclose command without a file handle.
> 
> This is really irritating. Why can't POV-Ray just issue and error 
> message if you reach the #end of a macro and the target for #fclose 
> hasn't been reached yet?

cos it might not be in that macro, but in another macro?
'missing argument to fclose' might be a better message though
or maybe 'fclose missing argument defaulting to handle NNN'
> 
> Andrew @ home.

that suggests a bracket mismatch in what you've commented out
maybe a ) instead of a } ??
easy to do

whats the syntax hi-lighting like in the editor you use?
try re-indenting that section ?

stephen


Post a reply to this message

From: Invisible
Subject: Re: Parse weirdness
Date: 18 Jun 2004 09:45:19
Message: <40d2f1ef$1@news.povray.org>
>> Without a complete but minimal scene, I don't think there is a way to 
>> help you.
> 
> 
> The scene I have is *huge*. It will take you years to wade through it all.
> 
> If I can come up with something more minimal, I'll post it.

OK, try this...

-----
#macro Save(X, Y)
   #fopen Datafile "Test.data" write
   #write(Datafile, X, ", ", Y, ", ")
   #fclose
#end

Save(7, 9)

object {sphere {+1*z, 0} pigment {red 1}}
light_source {+1*y, 1}
-----

On the penultimate line, I get
   Parse Error: expected 'object or directive', found {
If you comment out the "Save(7, 9)" line, it renders fine.

The cause is the #fclose command - I forgot to type *which* file to 
close! But rather than POV-Ray saying "you didn't say which file to 
close", it gives me the (rather baffling) error indicated above. Given 
that the mistake was in one include file and the error was reported in a 
totally different include file, this took me a rather long time to track 
down. :-S

I would suggest that if #fclose is followed by the end of the current 
macro (or the end of the current file) this should at the very least 
generate a warning.

(Personally I would feel happier if both #fopen and #fclose took 
arguments in brackets like #read and #write do - but that would break 
existing scenes.)

Thanks.
Andrew.


Post a reply to this message

From: Slime
Subject: Re: Parse weirdness
Date: 18 Jun 2004 21:36:30
Message: <40d3989e@news.povray.org>
> I would suggest that if #fclose is followed by the end of the current
> macro (or the end of the current file) this should at the very least
> generate a warning.


The reason why it doesn't, in case you're not aware, is because your macro
could be used validly as follows:

Save(7,9) Datafile

And there may be obscure reasons that one would want to use a macro in this
way.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Andrew C on Mozilla
Subject: Re: Parse weirdness
Date: 19 Jun 2004 14:13:45
Message: <40d48259$1@news.povray.org>
>>I would suggest that if #fclose is followed by the end of the current
>>macro (or the end of the current file) this should at the very least
>>generate a warning.
> 
> 
> 
> The reason why it doesn't, in case you're not aware, is because your macro
> could be used validly as follows:
> 
> Save(7,9) Datafile
> 
> And there may be obscure reasons that one would want to use a macro in this
> way.

Yeah, I figured as much...

There are also reasons why you might want a camera *inside* a non-hollow 
object. But it still warns you about it. That's all I was suggesting - 
that POV-Ray might give you a warning to say "hey man, did you really 
mean this?"

Andrew @ home.


Post a reply to this message

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