Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Regular expressions

2 views
Skip to first unread message

Maurício

unread,
Mar 1, 2002, 12:41:56 PM3/1/02
to

Hi,

I've been looking for a language where I can do regular expressions in
Windows. Scsh seems to be nice, but, in all examples I've seen on the
documentation or in external modules, I only see regular expressions used in
small strings, but I need to search big files (500Mb) for several matchs of
a regular expressions. How do you suggest me to do that in scsh/scheme,
using either the scsh way or other modules?

Thanks,
Maurício


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Michael Sperber [Mr. Preprocessor]

unread,
Mar 2, 2002, 10:26:22 AM3/2/02
to

>>>>> "Maurício" == briqueabraque <Maur> writes:

Maurício> Hi,

Maurício> I've been looking for a language where I can do regular expressions in
Maurício> Windows. Scsh seems to be nice, but, in all examples I've seen on the
Maurício> documentation or in external modules, I only see regular expressions used in
Maurício> small strings, but I need to search big files (500Mb) for several matchs of
Maurício> a regular expressions. How do you suggest me to do that in scsh/scheme,
Maurício> using either the scsh way or other modules?

Just read the file in line by line. You probably want to use
PORT-FOLD, READ-LINE, and REGEXP-SEARCH.

--
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla

Maurício

unread,
Mar 4, 2002, 6:56:28 AM3/4/02
to

> Maurício> Hi,
>
> Maurício> I've been looking for a language where I can do regular
expressions in

> Maurício> Windows (...) but I need to search big files (500Mb) for several
matchs > Maurício> a regular expressions. How do you suggest me to do that
in csh/scheme,
> Maurício> (...)

> Just read the file in line by line. You probably want to use
> PORT-FOLD, READ-LINE, and REGEXP-SEARCH.
>

The problem is that the regular expression usually matches many lines at
once. Isn't it possible, for intance, to "memory map" the file to a string
or something like that?

Michael Sperber [Mr. Preprocessor]

unread,
Mar 4, 2002, 7:08:39 AM3/4/02
to

>>>>> "Maurício" == briqueabraque <Maur> writes:

>> Maurício> Hi,
>>
>> Maurício> I've been looking for a language where I can do regular

Maurício> expressions in


>> Maurício> Windows (...) but I need to search big files (500Mb) for several

Maurício> matchs > Maurício> a regular expressions. How do you suggest me to do that
Maurício> in csh/scheme,
>> Maurício> (...)

>> Just read the file in line by line. You probably want to use
>> PORT-FOLD, READ-LINE, and REGEXP-SEARCH.
>>

Maurício> The problem is that the regular expression usually matches many lines at
Maurício> once. Isn't it possible, for intance, to "memory map" the file to a string
Maurício> or something like that?

If there's no upper bound on the size of the matches, you'll have a
hard time putting a meaningful bound on the chunks of the file you'll
have to read in order to search for regexps. (This has little to do
with scsh.) If there is, well, just read ahead that much.

Michel Schinz

unread,
Mar 4, 2002, 9:31:24 AM3/4/02
to
spe...@informatik.uni-tuebingen.de (Michael Sperber [Mr.
Preprocessor]) writes:

[...]

> If there's no upper bound on the size of the matches, you'll have a
> hard time putting a meaningful bound on the chunks of the file
> you'll have to read in order to search for regexps. (This has little
> to do with scsh.) If there is, well, just read ahead that much.

But couldn't we imagine a regular expression matcher that fetches
characters from ports as it needs? I sometimes wish I had a "lex"
macro in scsh, providing something similar to what the (f)lex tools
provides for C (and other languages). I find it sad that I have to
revert to "read-char" as soon as I need to analyze text files which
cannot be read line-by-line (e.g. any source file of a language
allowing multi-line comments).

Michel.

Tom Lord

unread,
Mar 4, 2002, 3:46:49 PM3/4/02
to

Michel Schinz:

But couldn't we imagine a regular expression matcher that fetches
characters from ports as it needs? I sometimes wish I had a "lex"
macro in scsh, providing something similar to what the (f)lex tools
provides for C (and other languages). I find it sad that I have to
revert to "read-char" as soon as I need to analyze text files which
cannot be read line-by-line (e.g. any source file of a language
allowing multi-line comments).

For general Posix regexps, it isn't quite as simple as fetching
characters as needed -- the matcher needs random access to
characters already matched.

However, there is no need to use only your imagination. The Rx
regexp engine permits matching over non-contiguous, dynamically
constructed strings. In both the Posix functions and some lower
level functions it has everything you need to make a fast lexer --
I use it for that purpose in Systas Scheme. See http://www.regexps.com.

Primitives for fast I/O in scheme are a persistent need and Systas
has some nice examples of those, too.

Systas has a process mgt. interface largely cribbed from SCSH, but
would need a few more lines of code to actually be source-level
compatible.

(In many other ways, though, Systas basically sucks and I don't recommend
using it for anything critical -- it's just a place to consider grabbing
ideas and techniques for better regexp support and neat I/O primitives.)

-t

David Rush

unread,
Mar 8, 2002, 10:23:16 AM3/8/02
to
Due to propagation problems I haven't seen the start of this...

Michel Schinz:
> But couldn't we imagine a regular expression matcher that fetches
> characters from ports as it needs? I sometimes wish I had a "lex"
> macro in scsh, providing something similar to what the (f)lex tools
> provides for C (and other languages).

Bigloo. read/rp and read/lalrp. They're great. I keep agitating those
guys to make a SRFI out of them. Actually, the code could easily be
glommed into scsh as it's all written in Scheme anyway...

david rush
--
Einstein said that genius abhors consensus because when consensus is
reached, thinking stops. Stop nodding your head.
-- the Silicon Valley Tarot

0 new messages