POV-Ray : Newsgroups : povray.off-topic : Mini-languages : Re: Mini-languages Server Time
4 Sep 2024 03:17:12 EDT (-0400)
  Re: Mini-languages  
From: nemesis
Date: 11 Nov 2010 10:07:56
Message: <4cdc06cc$1@news.povray.org>
Invisible escreveu:
>> do you really believe spelling out "option (char '+' <|> char '-')" is
>> any worth as opposed to "(\+|-)"?
> 
> Um, *yes*. Why, do you think it doesn't have worth?

it's far more verbose and, thus, hurts readability?

come on! do you even need those quotes around the symbols?

>>> xs <- many1 digit
>>> if length xs > 3 then fail else return ()
>>
>> no, sorry. Truly overkill against "\d{3}".

BTW, my mistake.  Should be "\d{0,3}"

> So define a combinator for it:
> 
>   manyN 0 _ = return []
>   manyN n p = do x <- p; xs <- manyN (n-1) p; return (x:xs)
> 
> And now, forever more, you can merely write
> 
>   manyN 3 digit
> 
> Problem solved.

then try this in your little language:

// A phone number with or without hyphens:
[2-9]\d{2}-?\d{3}-?\d{4}

It looks pretty much like a template for a phone number.  I'm sure yours 
will look like a little backwards forth script and will be much harder 
to figure out.

I also wonder if it's the postfix nature of regexes that bothers you...

-- 
a game sig: http://tinyurl.com/d3rxz9


Post a reply to this message

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