lily2.scm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. (require note)
  2. (export lilyscore->file
  3. #!optional
  4. chord-display
  5. lilyscore-display)
  6. (def lp-value? (either string? real?))
  7. (def. (keyword.lilypond-bag key)
  8. ;; XX should check for valid lilypond symbol names
  9. (list "\\" (keyword->string key)))
  10. (def. (string.lilypond-bag v)
  11. ;; XX may not always be the right way to print strings for lilypond
  12. (object->string v))
  13. (def. (real.lilypond-bag v)
  14. (list "#" (object->string v)))
  15. (defclass (lp-setting [keyword? key] [lp-value? value])
  16. (defmethod (lilypond-bag _)
  17. (list (.lilypond-bag key)
  18. " = "
  19. (.lilypond-bag value)
  20. "\n")))
  21. (TEST
  22. > (def (t v)
  23. (fst (with-output-to-string (lambda () (print (.lilypond-bag v))))))
  24. > (t (lp-setting foo: 234))
  25. "\\foo = #234\n"
  26. > (t (lp-setting foo: "234"))
  27. "\\foo = \"234\"\n")
  28. (defclass lp-instruction
  29. (defclass (lp-version [string? value]))
  30. (defclass (lp-language [string? value]))
  31. (defclass (lp-header [(list-of lp-setting?) settings]))
  32. )
  33. (defclass (lp-document [(list-of lp-instruction?) instructions]))
  34. (TEST
  35. > (lp-document (list
  36. (lp-version "5.24.5")
  37. (lp-language "english")
  38. (lp-header (list (lp-setting tagline: "")
  39. (lp-setting author: "batman")))))
  40. [(lp-document)
  41. ([(lp-version) "5.24.5"]
  42. [(lp-language) "english"]
  43. [(lp-header) ([(lp-setting) tagline: ""]
  44. [(lp-setting) author: "batman"])])])
  45. "TODO
  46. Near:
  47. Make .lilypond-bag methods for lp-version lp-language, lp-header, and lp-document
  48. Far:
  49. create a type for lilypond version statement
  50. create a type for lilypond language statement"