POV-Ray : Newsgroups : povray.off-topic : Very long post : Re: Very long post Server Time
7 Sep 2024 05:13:50 EDT (-0400)
  Re: Very long post  
From: Invisible
Date: 25 Sep 2008 06:12:25
Message: <48db6409@news.povray.org>
scott wrote:

> I'm just curious, because I made a parser like this in C++ once (it was 
> very hacky and basically just stepped along the string trying to 
> identify what each byte was).  Anyway, it worked ok for things like 
> "-5*(4+2)" etc, but crashed with "-(4+2)".  I guess the minus operator 
> should be encoded as its own token and then let the parser sort out what 
> it should do.  Maybe I'll try a rewrite one day.

Yeah, this is one of the tricky edge-cases of expression parsing. 
Operator precidence and unary/binary operators can get pretty ugly. 
(Gets even harder if you want to report meaningful error messages if 
there's an actua syntax error...)


Post a reply to this message

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