POV-Ray : Newsgroups : povray.bugreports : alpha.10064268 macro problem Server Time
21 Nov 2024 14:53:31 EST (-0500)
  alpha.10064268 macro problem (Message 1 to 10 of 32)  
Goto Latest 10 Messages Next 10 Messages >>>
From: jr
Subject: alpha.10064268 macro problem
Date: 3 Apr 2021 14:40:00
Message: <web.6068b5eea7e9bfcc79819d986cde94f1@news.povray.org>
hi,

I've run into a problem which I cannot understand.  I'm working on a 'Foreach'
macro, to process arrays.  it works as expected, except..

the below shows the error message I'm getting when I try to create an object
from within the "payload" macro; first run displays the values supplied from an
array, with the offending line (208) commented out.

jr@swift:1:$ povparse fore_demo.pov
Persistence of Vision(tm) Ray Tracer Version 3.8.0-alpha.10064268.unofficial
  ...
==== [Parsing...] ==========================================================
e[0] = 0  e[1] = 0  e[2] = 'one'  e[3] = 7.
e[0] = 2  e[1] = 1  e[2] = 'two'  e[3] = 6.
e[0] = 4  e[1] = 2  e[2] = 'three'  e[3] = 5.
e[0] = 6  e[1] = 3  e[2] = 'four'  e[3] = 3.
e[0] = 1  e[1] = 4  e[2] = 'five'  e[3] = 2.
e[0] = 3  e[1] = 5  e[2] = 'six'  e[3] = 4.
e[0] = 5  e[1] = 6  e[2] = 'seven'  e[3] = 1.
e[0] = 7  e[1] = 7  e[2] = 'eight'  e[3] = 0.
File 'fore_demo.pov' line 216: Parse Warning: No objects in scene.
==== [Rendering...] ========================================================
Rendered 1024 of 1024 pixels (100%)
POV-Ray finished


jr@swift:2:$ povparse fore_demo.pov
   ...
==== [Parsing...] ==========================================================
e[0] = 0  e[1] = 0  e[2] = 'one'  e[3] = 7.
File 'fore_demo.pov' line 199: Parse Error: Expected 'numeric expression',
 sphere found instead
Fatal error in parser: Cannot parse input.
Render failed


zip attached.  (the demo scene is meant to double as draft documentation, hence
the format)


regards, jr.


Post a reply to this message


Attachments:
Download 'foreachbug.zip' (5 KB)

From: Bald Eagle
Subject: Re: alpha.10064268 macro problem
Date: 3 Apr 2021 16:35:00
Message: <web.6068d0cd54e5aaba1f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> I've run into a problem which I cannot understand.  I'm working on a 'Foreach'
> macro, to process arrays.  it works as expected, except..

> File 'fore_demo.pov' line 199: Parse Error: Expected 'numeric expression',
>  sphere found instead


Because it is looking for a numeric expression that you somehow left out.

When I insert a line before the sphere and put "0", I get:

Possible Parse Error: Unmatched (
at File: foreach.inc Line: 344 Col: 11
Parse Error: No matching ), sphere found instead

But then curiously, when I put "0)" I get:

Parse Warning: Unbalanced ) in include file
Parse Warning: Unbalanced } in include file
Parse Error: Unbalanced #end directives in include file.


Other than that, you have too much clever stuff going on for me to follow.
Add in more debug statements to follow your code flow.

I added:

#macro fore_exec(s_)
  #local fn_ = "/tmp/parse_fore.tmp";
  #fopen fp_ fn_ write
  #write (fp_, s_)
  #fclose fp_
  #debug "fore_exec(s_).... \n" // BW
  #debug concat (s_, "\n")
  #include fn_
#end

#macro fore_call(a_,s_,f_)
  #if (f_)
    #local rtn_ = fore_exec(s_);
  #else
   #debug "fore_call 1.... \n" // BW
    fore_exec(s_)
    #local rtn_ = 1;
  #end
  #if (fore_debug)
    #debug concat("call '",s_,"' returned '",str(rtn_,0,0),"'.\n")
  #end
  #debug "fore_call 2.... \n" // BW
  rtn_
#end


and

#macro mkSphere (p_, d_, c_)
 #debug "executing mkSphere... \n"
 0)
  sphere {
    p_, d_
    pigment {colours_[c_]}
  }
#end


Post a reply to this message

From: jr
Subject: Re: alpha.10064268 macro problem
Date: 3 Apr 2021 17:15:00
Message: <web.6068da4954e5aaba79819d986cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> ...
> > File 'fore_demo.pov' line 199: Parse Error: Expected 'numeric expression',
> >  sphere found instead
>
> Because it is looking for a numeric expression that you somehow left out.

hmm, the 'bigSphere' macro does work until one tries to instantiate an object,
it runs otherwise.  and, well, I cannot see anything amiss.

> When I insert a line before the sphere and put "0", I get:
>
> Possible Parse Error: Unmatched (
> at File: foreach.inc Line: 344 Col: 11
> Parse Error: No matching ), sphere found instead
>
> But then curiously, when I put "0)" I get:
>
> Parse Warning: Unbalanced ) in include file
> Parse Warning: Unbalanced } in include file
> Parse Error: Unbalanced #end directives in include file.

yes, as it should, having just a '0)' before the primitive.  I don't get the
line before thing but suspect it's for the same reason -- extra ("spurious")
characters.

as for adding more output in the include, the error does occur in the scene
file.  (btw, a 'bool' type payload with debug on will print return info).

thanks for looking.


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: alpha.10064268 macro problem
Date: 3 Apr 2021 17:55:00
Message: <web.6068e3e554e5aaba1f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> yes, as it should, having just a '0)' before the primitive.  I don't get the
> line before thing but suspect it's for the same reason -- extra ("spurious")
> characters.

Right on, but we're looking at "as it shouldn't".

I commented out the macro call in bigSphere  (look at you, using capital
letters... :o)  and put an actual sphere in its place.
Same error.

Put a 1 on the line above it.   Same error as last time.

But when I closed the ), this time I got

Parse Error: Unbalanced #end directives in include file.
at File: fore_demo.pov Line: 213 Col: 1
e[0] = 0  e[1] = 0  e[2] = 'one'  e[3] = 7.
Parse Warning: Unbalanced ) in include file

So the error gets triggered in the scene file, but seems to be actually due to
an omission in some nested thing in the include file.
Also, 213 is a different line than when I did the 0) in the mkSphere macro.

If you can't find the issue, you may have to resort to mapping the nesting
levels like I did in that blood cells scene.


Post a reply to this message

From: Bald Eagle
Subject: Re: alpha.10064268 macro problem
Date: 3 Apr 2021 18:05:00
Message: <web.6068e5ad54e5aaba1f9dae3025979125@news.povray.org>
Further,
if I put a 2) before the #debug statement in bigSphere, it complains about line
_214_ instead.

You've got an extra ( somewhere that got injected or a missing ), or something
even harder to track down.

Just on the off chance:
The file is clean and has none of those weird non-ASCII characters, ...?


Post a reply to this message

From: jr
Subject: Re: alpha.10064268 macro problem
Date: 3 Apr 2021 18:20:00
Message: <web.6068e8ec54e5aaba79819d986cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> ...
> I commented out the macro call in bigSphere  (look at you, using capital
> letters... :o)  and put an actual sphere in its place.
> Same error.

yes, I too tried that.


> Put a 1 on the line above it.   Same error as last time.
>
> But when I closed the ), this time I got
>
> Parse Error: Unbalanced #end directives in include file.
> at File: fore_demo.pov Line: 213 Col: 1
> e[0] = 0  e[1] = 0  e[2] = 'one'  e[3] = 7.
> Parse Warning: Unbalanced ) in include file
>
> So the error gets triggered in the scene file, but seems to be actually due to
> an omission in some nested thing in the include file.
> Also, 213 is a different line than when I did the 0) in the mkSphere macro.

maybe I should have mentioned earlier.  before I got to the stage of calling
payload macros, I worked to get the "walking" done properly.  for that I've a
test scene with arrays from one to five dims, and the 'fore_call()' at the time
only spat out the 'cmd_' content, ie the index/indices of the current element.
while it is possible that I fucked up, I did test pretty thoroughly.

my gut feeling, given the "because it is looking for a numeric expression", is
that the parser somehow expects a RHS where it sees an object/primitive.

(and to add to the indignation :-), earlier I'd written a camera {} and left
forgot to fill in the details, and .. not a beep from the program.)


> If you can't find the issue, you may have to resort to mapping the nesting
> levels like I did in that blood cells scene.

yes, last resort though.  I do hope "one of the gods" can shed some light on
this.


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: alpha.10064268 macro problem
Date: 3 Apr 2021 18:45:00
Message: <web.6068ef0754e5aaba1f9dae3025979125@news.povray.org>
To CYA, check your "end"s    :D

I noticed that you have a
#ifndef (fore_include_temp)

but I'm not sure where it should be terminated.

Also, I'm not sure if there are enough #ends in
#macro Foreach(arr_,mac_,flg_,optional dim_)






I would sorely love different terminators for #macro, #if, #for, #while, etc....


Post a reply to this message

From: jr
Subject: Re: alpha.10064268 macro problem
Date: 3 Apr 2021 19:15:00
Message: <web.6068f67e54e5aaba79819d986cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> To CYA, check your "end"s    :D

are you looking at an unmodified file?  if yes, as posted, the indentation looks
correct.


> I noticed that you have a
> #ifndef (fore_include_temp)
>
> but I'm not sure where it should be terminated.

line 429.  :-)


> Also, I'm not sure if there are enough #ends in
> #macro Foreach(arr_,mac_,flg_,optional dim_)

no spare or missing '#end's, I'm confident.

(do you need to top up caffeine level?  :-))
(and please give it a whirr with some "normal" macros.  any errors?)


> I would sorely love different terminators for #macro, #if, #for, #while, etc....

yes, self prefers braced blocks (think Tcl), eg '#for () { ... }'.


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: alpha.10064268 macro problem
Date: 3 Apr 2021 19:55:00
Message: <web.6069002f54e5aaba1f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> (do you need to top up caffeine level?  :-))

Yes.
Though with what you've got going on, I'm gonna need either some crystal meth -
or a crystal ball - to see how you've gone and broken things this time.   :P

I think that with this, you are trying to get into the running on "Who breaks
POV-Ray the most?"

> (and please give it a whirr with some "normal" macros.  any errors?)
Give WHAT a whirr...


> yes, self prefers braced blocks (think Tcl), eg '#for () { ... }'.

Well, yes, that would be functional.

But I would still prefer #endif #endfor #endwhile #endmacro
as it would allow some interesting coding that wouldn't otherwise be possible
with equally ambiguous {'s


Post a reply to this message

From: jr
Subject: Re: alpha.10064268 macro problem
Date: 3 Apr 2021 20:20:00
Message: <web.6069059554e5aaba79819d986cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
>
> > (do you need to top up caffeine level?  :-))
>
> Yes.
> Though with what you've got going on, I'm gonna need either some crystal meth -
> or a crystal ball - to see how you've gone and broken things this time.   :P

</grin>  thanks.  can do with some lightheartedness.  :-)


> ...
> > (and please give it a whirr with some "normal" macros.  any errors?)
> Give WHAT a whirr...

the 'Foreach()'.  I'm sure you've plenty data (lingering in arrays).  if the
payload macros just do calculations etc, I'd expect it to run w/out issues.


> > yes, self prefers braced blocks (think Tcl), eg '#for () { ... }'.
>
> Well, yes, that would be functional.
>
> But I would still prefer #endif #endfor #endwhile #endmacro
> as it would allow some interesting coding that wouldn't otherwise be possible

intrigued.  what can you not do with just '#end's?


regards, jr.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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