summaryrefslogtreecommitdiff
path: root/modules/language/python/compile.scm
diff options
context:
space:
mode:
authorStefan Israelsson Tampe <stefan.itampe@gmail.com>2018-09-02 19:48:52 +0200
committerStefan Israelsson Tampe <stefan.itampe@gmail.com>2018-09-02 19:48:52 +0200
commit0f56fc6181a3167db9f45b8a042a8d2f56ade3a8 (patch)
tree19966c8557ecdd0024903b04157ee90e4af64d4f /modules/language/python/compile.scm
parent3d44139af1b65ec71abafec939b5240d3821490b (diff)
refined the errors in the os module, translating scheme errors to python errors. close command changed
Diffstat (limited to 'modules/language/python/compile.scm')
-rw-r--r--modules/language/python/compile.scm68
1 files changed, 37 insertions, 31 deletions
diff --git a/modules/language/python/compile.scm b/modules/language/python/compile.scm
index 91c33c1..86b30dc 100644
--- a/modules/language/python/compile.scm
+++ b/modules/language/python/compile.scm
@@ -188,7 +188,7 @@
(let ((e (car x)))
(if (pair? e)
(let ((ee (car e)))
- (if (equal? ee 'cons)
+ (if (equal? ee '(@ (guile) cons))
(append (lp (list (cadr e)))
(lp (list (caddr e)))
(lp (cdr x)))
@@ -377,7 +377,7 @@
(union
s
(fold (lambda (x s)
- (match x
+ (match x
((#:test (#:power v2 v1 () . _) . _)
(if v2
(union
@@ -907,6 +907,9 @@
(define lr* (lr `((#:* . ,(mklr (G '*))) (#:/ . ,(mklr (N 'py-/)))
(#:% . ,f%) (#:// . ,(mklr (N 'py-floordiv))))))
+(define lr-or (lr `((#:bor . ,(mklr (N 'py-logior))))))
+(define lr-and (lr `((#:band . ,(mklr (N 'py-logand))))))
+(define lr-xor (lr `((#:bxor . ,(mklr (N 'py-logxor))))))
(define-syntax-rule (gen-table x vs (tag code ...) ...)
(begin
@@ -1016,16 +1019,13 @@
(list '+ (exp vs x))))
(#:band
- ((_ . l)
- (cons (N 'py-logand) (map (g vs exp) l))))
-
+ (x (lr-and vs x)))
+
(#:bxor
- ((_ . l)
- (cons (N 'py-logxor) (map (g vs exp) l))))
+ (x (lr-xor vs x)))
(#:bor
- ((_ . l)
- (cons (N 'py-logior) (map (g vs exp) l))))
+ (x (lr-or vs x)))
(#:not
((_ x)
@@ -1555,18 +1555,18 @@
(,(D 'lam) ,aa
(,(C 'with-return) ,r
,(mk `(,(G 'let) ,(map (lambda (x) (list x #f)) ls)
- (,(C 'with-self) ,c? ,aa
- ,(with-fluids ((return r))
- (wth (exp ns code)))))))))))
+ (,(C 'with-self) ,c? ,aa
+ ,(with-fluids ((return r))
+ (wth (exp ns code)))))))))))
`(set! ,f
(,(C 'def-decor) ,decor
(,(D 'lam) ,aa
(,(C 'with-return) ,r
,(mk `(,(G 'let) ,(map (lambda (x) (list x #f)) ls)
- (,(C 'with-self) ,c? ,aa
- ,(with-fluids ((return r))
- (wth (exp ns code)))))))))))
+ (,(C 'with-self) ,c? ,aa
+ ,(with-fluids ((return r))
+ (wth (exp ns code)))))))))))
(if y?
`(set! ,f
@@ -1575,18 +1575,18 @@
(,(D 'lam) ,aa
(,(C 'with-return) ,r
(,(G 'let) ,(map (lambda (x) (list x #f)) ls)
- (,(C 'with-self) ,c? ,aa
- ,(with-fluids ((return r))
- (mk
- (wth (exp ns code)))))))))))
+ (,(C 'with-self) ,c? ,aa
+ ,(with-fluids ((return r))
+ (mk
+ (wth (exp ns code)))))))))))
`(set! ,f
(,(C 'def-decor) ,decor
(,(D 'lam) ,aa
(,(C 'with-return) ,r
(,(G 'let) ,(map (lambda (x) (list x #f)) ls)
- (,(C 'with-self) ,c? ,aa
- ,(with-fluids ((return r))
- (wth (exp ns code)))))))))))))))
+ (,(C 'with-self) ,c? ,aa
+ ,(with-fluids ((return r))
+ (wth (exp ns code)))))))))))))))
(#:global
((_ . _)
@@ -1871,7 +1871,7 @@
#:use-module ((guile) #:select
(@ @@ pk let* lambda call-with-values case-lambda
set! = * + - < <= > >= / pair?
- syntax-rules let-syntax))
+ syntax-rules let-syntax abort-to-prompt))
#:use-module (language python module python)
#:use-module ((language python compile) #:select (pks))
#:use-module (language python exceptions))
@@ -2716,14 +2716,20 @@
#:final l)))))
(define-syntax qset!
- (syntax-rules (cons quote)
- ((_ (cons x y) v)
- (let ((w v))
- (qset! x (car w))
- (qset! y (cdr w))))
- ((_ '() v) (values))
- ((_ x v)
- (set! x v))))
+ (lambda (x)
+ (syntax-case x ()
+ ((_ (cons x y) v)
+ (equal? (syntax->datum #'cons) '(@ (guile) cons))
+ #'(let ((w v))
+ (qset! x (car w))
+ (qset! y (cdr w))))
+
+ ((_ '() v)
+ #'(if (not (null? v))
+ (raise (ValueError "too many values to unpack"))))
+
+ ((_ x v)
+ #'(set! x v)))))
(define-syntax define-
(syntax-rules (cons quote)