|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3a30dfb5@news.povray.org>, Warp <war### [at] tagpovrayorg>
wrote:
Try something like this:
Get_Token();
if(Token.Token_Id == COMMA_TOKEN)
{
SecondParam = (int)Parse_Float();
}
else
{
Unget_Token();
}
In other words, peek at the next token to see if it is a comma, in which
case another parameter has been specified. A more generalized version of
this could make a nice macro...
--
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/
<><
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Fri, 08 Dec 2000 09:17:48 -0500, Chris Huff wrote:
>In article <3a30dfb5@news.povray.org>, Warp <war### [at] tagpovrayorg>
>wrote:
>
>Try something like this:
>
>Get_Token();
>if(Token.Token_Id == COMMA_TOKEN)
>{
> SecondParam = (int)Parse_Float();
>}
>else
>{
> Unget_Token();
>}
>
>In other words, peek at the next token to see if it is a comma, in which
>case another parameter has been specified. A more generalized version of
>this could make a nice macro...
But that would violate the principle that most commas are optional.
--
Ron Parker http://www2.fwi.com/~parkerr/traces.html
My opinions. Mine. Not anyone else's.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Chris Huff <chr### [at] maccom> wrote:
: SecondParam = (int)Parse_Float();
I'm right now just reading both parameters to get on with my code, but
I have a bad problem with the Parse_Float() function.
For some reason it always returns 1026048. For both parameters. Always.
No matter what I put in the .pov file.
Aargh!
Any idea?
--
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <slr### [at] fwicom>, ron### [at] povrayorg
wrote:
> But that would violate the principle that most commas are optional.
I've never seen anyone write multiple-parameter functions without
commas...and if I did, I would tell them they forgot a comma. I don't
think that is a serious problem...but if you really want to do that, you
can just allow a comma and use the same technique to check the Token_Id
of the next token to see if it was a float, unget it, and use
Parse_Float() if it was a float token.
--
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/
<><
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3a31040e@news.povray.org>, Warp <war### [at] tagpovrayorg>
wrote:
> I have a bad problem with the Parse_Float() function.
> For some reason it always returns 1026048. For both parameters. Always.
Always? Just in this patch, or other places as well?
This sounds really odd...maybe you have a stray pointer somewhere, or
are accidentally modifying the values. Could you post the code?
--
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/
<><
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 8 Dec 2000 10:53:51 -0500, Warp wrote:
>Chris Huff <chr### [at] maccom> wrote:
>: SecondParam = (int)Parse_Float();
>
> I'm right now just reading both parameters to get on with my code, but
>I have a bad problem with the Parse_Float() function.
> For some reason it always returns 1026048. For both parameters. Always.
Did you #include "express.h" in your source file? A Failure to properly
declare a function returning a non-integer often leads to strange
results like this.
The default CFLAGS setting for povray is also a bit conservative on
enabling warnings. If you are using gcc, I recommend adding
-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
at least for your own source files.
hp
--
_ | Peter J. Holzer | Es war nicht Gegenstand der Abstimmung zu
| | | hjp### [at] wsracat | Zahlen neu festzulegen.
__/ | http://www.hjp.at/ | -- Johannes Schwenke <jby### [at] ginkode>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Peter J. Holzer <hjp### [at] sikituwsracat> wrote:
: Did you #include "express.h" in your source file? A Failure to properly
: declare a function returning a non-integer often leads to strange
: results like this.
That was exactly the problem (discovered it before reading your post,
though).
: The default CFLAGS setting for povray is also a bit conservative on
: enabling warnings.
Forgot that gcc doesn't require by default function prototypes...
--
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
|
|
| |
| |
|
|
|
|
| |