POV-Ray : Newsgroups : povray.advanced-users : Passing function to macros? : Re: Passing function to macros? Server Time
29 Jul 2024 12:28:40 EDT (-0400)
  Re: Passing function to macros?  
From: Thorsten Froehlich
Date: 6 Apr 2002 14:51:23
Message: <3caf51bb@news.povray.org>
In article <3caed2ed$1@news.povray.org> , "Hugo" <hua### [at] post3teledk> wrote:

> Strange that it doesn't work.

In computer science terms (and as it has been explained several times before),
the current POV-Ray parser is a recursive decent parser which is a plain and
simple LL(1) parser.  In order to parse "Run(Sum)" one needs a more complex
LR(1) parser to handle the more complex grammar.  Essentially an LR(k) parser,
just like a human, is able to read to the end of a sentence and then able to
make sense out of it while the LL(k) parser is only able to look at the next
word and then has to guess what you are up to without having read to the end.

This said however, I have to admit that LR(1) is only relevant for some "odd"
features of #declares and not macro parameters.  In order to parse macro
parameters correctly it is sufficient to modify the current parser to be
"nearly an LL(2) parser".  To be more precise, by some tricky but small
internal changes it is possible to keep enough information and perform a two
token look-ahead for functions*, which is sufficient to determine if it is a
function call or not...


    Thorsten


* I have not checked yet if the same is possible for splines with easy
modifications as well.

____________________________________________________
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

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