POV-Ray : Newsgroups : povray.off-topic : Mini-languages : Re: Mini-languages Server Time
3 Sep 2024 21:17:00 EDT (-0400)
  Re: Mini-languages  
From: Darren New
Date: 8 Nov 2010 12:31:27
Message: <4cd833ef$1@news.povray.org>
Invisible wrote:
> I'd much prefer to see a much bigger separation between what's a literal 
> character and what's a command. 

Technically, they're all commands. The letter "s" means "match against the 
letter s." :-)

> you could probably use 
> it to match against streams of other data, not just characters. 

You can. For example, Singularity uses "regular expressions" to match 
permissions. "if it started as the FTPD server and then fred logged in and 
it launched ls, *or* it started as the sshd server and any administrator 
logged in, then you launched a shell *then* you launched ls, allow access to 
this directory."

> A quick inspection of Wikipedia suggests that POSIX ERE involves at 
> least .[]^$()\*{}?+|:, which is 16, not 10. (Still, it's not the 
> thousands it seemed like last time I tried to learn this stuff.)

: and {} and ^ $ aren't original regular expression characters. Technically 
not + either, so I think that's where the 10 come from. The rest are 
short-cuts for what you can already otherwise specify (: + { }), or are 
useful for programming but outside the theory (^$).

> 
>>    Regular expressions are nowhere near Turing strong. They are state
>> machines.
> 
> I recall reading somewhere that Perl's "regular expressions" aren't 
> actually regular, and so require exponential time for matching. Truly 
> regular expressions apparently require only linear time.

Correct. And not only exponential time, but memory as well. A regular 
expression is regular because it requires a fixed amount of memory to match 
or reject.

> The other thing I dislike is that people seem to have a tendency to use 
> regexs where they should be using a real parser.

Yes, well, that's because people are stupid, not regexps.

> But the result is still incredibly fragile. 

Yes, because regular expressions can't parse XML. One of the benefits of 
regular expressions is you can tell when they'll fail.

> In short, people tend to use regexs for quick and dirty hacks that kinda 
> work, rather than doing the job properly with a full parser. And I'm 
> really not fond of hacks.

Only stupid people. Learn regexps, and learn the theory behind them, so when 
the boss asks you to write a parser, you know which one to use.

-- 
Darren New, San Diego CA, USA (PST)
   Serving Suggestion:
     "Don't serve this any more. It's awful."


Post a reply to this message

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