POV-Ray : Newsgroups : povray.programming : Parsing optional float parameter? : Parsing optional float parameter? Server Time
28 Jul 2024 14:26:07 EDT (-0400)
  Parsing optional float parameter?  
From: Warp
Date: 8 Dec 2000 08:18:46
Message: <3a30dfb5@news.povray.org>
Suppose that I want to make a new function in povray which takes two
integer parameters, the second one being optional, ie you could call it with
either one or two parameters (eg. "thefunction(1)" or "thefunction(1,2)").
  How do I parse this? I just don't get it.

  I have tried something like this to parse the second parameter:

    Parse_Comma();
    EXPECT
      CASE (FLOAT_FUNCT_TOKEN)
        SecondParam = (int)Token.Token_Float;
        EXIT
      END_CASE

      OTHERWISE
        UNGET
        EXIT
      END_CASE
    END_EXPECT

which works if I call it with a number as the second parameter (eg.
"thefunction(1,2)"), but if I call it, for example, with
"thefunction(1,false)", the SecondParam above gets the value '2'.


-- 
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

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