Re: Bigloo Regexp: m/ /ms (now: Regular Parsing)

Laurent Bloch <[email protected]>
Newsgroups gmane.lisp.scheme.bigloo
Message-ID <[email protected]>
Le 2015-04-23 19:29, Laurent Bloch a écrit :

>> And what about mmap + pregexp-match ?

Here is my try on it. Besides the ugly copying operations, it seems to 
me that the multiline option doesn't make what I was waiting for: 
finding a pattern across a newline.

Cheers,

-- 
Laurent Bloch - http://www.laurentbloch.org/ - [email protected]
mmap-multi-line-pattern-search.scm (text/plain, 677 B)
(module mmap-pattern-search
   (main file-parse))

(define (file-parse args)
   (let ((the-sequence (open-mmap (cadr args) read: #t write: #t))
	 (pattern (caddr args)))
      (analyse the-sequence pattern)
      (close-mmap the-sequence)
       ))

(define (analyse sequence pattern)
   (let ((len (mmap-length sequence))
	 (regexp (pregexp pattern 'MULTILINE)))
      (let loop ((start::belong (make-elong 0)))
	 (let* ((sequence-rem (mmap-substring sequence start len))
		(result (pregexp-match-positions regexp sequence-rem)))
	    (if result
		(begin
		   (print "From " (+ start (caar result)) " to " (+ start (cdar result)))
		   (loop (+ start (cdar result)))) ) ) )))
raw-sequence-file.txt (application/octet-stream, 13 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.