From 3ec70abe240d35a36ef8f246e350b16ee06fc725 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Mon, 3 Jun 2019 23:49:38 +0200 Subject: spec: Rename procedures. * modules/language/python/spec.scm (c): Rename this... (logging-compile): ...to this procedure. (cc): Rename this... (read-or-compile): ...to this procedure. (e): Rename this... (python-eval): ...to this procedure. (python-reader-wrap): Use new names. --- modules/language/python/spec.scm | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/language/python/spec.scm b/modules/language/python/spec.scm index 46b46e8..be7673e 100644 --- a/modules/language/python/spec.scm +++ b/modules/language/python/spec.scm @@ -1,6 +1,7 @@ (define-module (language python spec) #:use-module (language python guilemod) - #:use-module (parser stis-parser lang python3-parser) + #:use-module ((parser stis-parser lang python3-parser) + #:prefix python-parser:) #:use-module ((language python module python) #:select ()) #:use-module (language python compile) #:use-module (language python completer) @@ -29,13 +30,21 @@ (close port))) (car (reverse x))) -(define (c int x) (pr (comp int (pr (p (pr x)))))) -(define (cc int port x) - (if (string-null? x) +(define (logging-compile int? exp) + "Compile the Python expression EXP while optionally logging +intermediate values." + (pr (comp int? (pr (python-parser:p (pr exp)))))) + +(define (read-or-compile int? port exp) + "Compile the Python expression EXP or read a new one from PORT." + (if (string-null? exp) (read port) - (c int x))) + (logging-compile int? exp))) -(define (e x) (eval (c #t x) (current-module))) +(define (python-eval exp) + "Evaluate the Python expression EXP." + (eval (logging-compile #t exp) + (current-module))) (define (ignore-errors proc) "Run PROC and ignore all errors." @@ -56,12 +65,12 @@ (define python-reader-wrap (lambda (port env) (if (int) - (cc #t port (read-line port)) + (read-or-compile #t port (read-line port)) (let lp ((port2 (hash-ref mapper port))) (if port2 (read port2) (let ((port2 - (open-input-string (cc #f port (read-string port))))) + (open-input-string (read-or-compile #f port (read-string port))))) (use-modules (language python guilemod)) (in) (hash-set! mapper port port2) @@ -70,7 +79,7 @@ (ignore-errors (lambda () (set! (@@ (ice-9 readline) *readline-completion-function*) - (complete-python e)))) + (complete-python python-eval)))) (define-language python #:title "python" -- cgit v1.2.3