diff options
Diffstat (limited to 'modules/language')
-rw-r--r-- | modules/language/python/module/re.scm | 11 | ||||
-rw-r--r-- | modules/language/python/module/re/compile.scm | 26 |
2 files changed, 29 insertions, 8 deletions
diff --git a/modules/language/python/module/re.scm b/modules/language/python/module/re.scm index 1d7dbca..139393e 100644 --- a/modules/language/python/module/re.scm +++ b/modules/language/python/module/re.scm @@ -11,11 +11,14 @@ #:use-module (language python def) #:use-module (language python yield) #:use-module (oop pf-objects) - #:use-module ((parser stis-parser) #:select (f-checkr f-eof f-ftr f-pos f-pk f-seq! f-and! - f-reg f-seq Ds f-or! ff* f-ftr)) + #:use-module ((parser stis-parser) + #:select (f-checkr f-eof f-ftr f-pos f-pk + f-seq! f-and! f-nl + f-reg f-seq Ds f-or! ff* f-ftr)) #:use-module ((ice-9 match) #:select ((match . ice-match))) #:re-export (A ASCII DEBUG I IGNORECASE L LOCALE M MULTILINE X VERBOSE) - #:export (compile match fullmatch search split finditer findall sub subn purge escape)) + #:export (compile match fullmatch search split finditer findall sub subn + purge escape)) (define start (make-fluid 0)) (define end (make-fluid 0)) @@ -47,7 +50,7 @@ (define (e-search e) (let lp () - (f-or! (f-seq! e-start (f-and! e) e-end) (f-seq (f-reg ".") (Ds (lp)))))) + (f-or! (f-seq! e-start (f-and! e) e-end) (f-seq (f-or! (f-reg ".") f-nl) (Ds (lp)))))) (define-python-class Regexp () (define __init__ diff --git a/modules/language/python/module/re/compile.scm b/modules/language/python/module/re/compile.scm index 9c4dfd3..ca7663d 100644 --- a/modules/language/python/module/re/compile.scm +++ b/modules/language/python/module/re/compile.scm @@ -3,10 +3,10 @@ #:use-module (language python module re flags) #:use-module (language python list) #:use-module (language python string) - #:use-module ((parser stis-parser) #:select + #:use-module ((parser stis-parser) #:select ((parse . stisparse) <p-lambda> <p-cc> .. f-nl! f-nl f-tag! f-tag f-seq f-or f-or! f-and f-true g* g+ gmn ng* ng+ - ngmn f-reg! f-and! + ngmn f-reg! f-and! f-test N M X XL g? ng? f-test! f-eof f-not! f-prev f-not f-out f-rev *whitespace* f-nm f-pos)) @@ -28,6 +28,11 @@ (.. c2 (f c)) (<p-cc> (wrap L c2)))) +(define startline + (<pp-lambda> (L c) + (when (= N 0) + (<p-cc> (wrap L c))))) + (define (gt f) (<pp-lambda> (L c) (let ((x #f)) @@ -268,8 +273,21 @@ ((#:?if-rev name yes no) (f-or (f-seq yes (incant-rev name)) no)) - (#:$ f-eof) - (#:^ (f-nm 0 1)) + (#:$ + (f-or! f-eof + (f-and (f-test (lambda (c) + (let ((x (fluid-ref *flags*))) + (not (= 0 (logior x MULTILINE)))))) + f-nl + f-true))) + (#:^ + (f-or! (f-nm 0 1) + (f-and (f-test (lambda (c) + (let ((x (fluid-ref *flags*))) + (not (= 0 (logior x MULTILINE)))))) + startline + f-true))) + ((#:op x #:* ) (g* (compile x) )) ((#:op x #:+ ) (g+ (compile x) )) ((#:op x (#:rep m n)) (gmn (compile x) m n)) |