1 ;;; pysk.scm -- implement Python output routines (for Sketch)
3 ;;; source file of the GNU LilyPond music typesetter
5 ;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 (define-module (scm pysk)
19 (define this-module (current-module))
20 (define-public (pysk-output-expression expr port)
21 (display (pythonify expr) port )
24 (define (ly-warn s) (display s))
28 ((string? q) (py-str q))
29 ((symbol? q) (py-str (symbol->string q)))
32 (not (eq? '() (cdr q)))
34 ((pair? q) (py-listify q))
35 ((number? q) (number->string q))
38 (ly-warn "Unknown object to pythonify:")
45 (string-append "'" s "'")
49 (string-append "(" (pythonify (car q)) "," (pythonify (cdr q)) ")")
52 (define (reduce-list list between)
53 "Create new list, inserting BETWEEN between elements of LIST"
56 (if (null? (cdr list))
59 (cons between (reduce-list (cdr list) between)))
63 (define (string-join str-list sep)
64 (apply string-append (reduce-list str-list sep))
71 (cons (f (car l)) (my-map f (cdr l)))
72 (cons (f (car l)) (f (cdr l)))
76 (define (tuplify-list lst)
80 (cons (car lst) (tuplify-list (cdr lst)))
81 (if (eq? '() (cdr lst))
83 (list (string-append "(" (car lst) ", " (cdr lst) ")" ))
87 (define (py-listify q)
91 (tuplify-list (my-map pythonify q)) ",")