2002-09-21 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ * lily/identifier-smob.cc (unpack_identifier): new file.
+
+ * lily/lexer.ll (identifier_type): new function. use ly-id to
+ pass off scheme expressions as music identifiers.
+
* scm/lily.scm: reorganisation, cleanups.
* lily/main.cc: small cleanups.
-New features in 1.6 since 1.4
-
-* Support for figured bass and tablature.
-
-* Completely rewritten beam formatting: provides much better output
-now.
-
-* Completely revised and improved music font.
-
-* Completely rewritten MIDI import support.
-
-* Completely rewritten grace note support. Practically speaking this
-means that grace notes can be slurred to normal normal notes.
-
-* Improved accidental handling and formatting: styles for producing
-cautionaries may vary, and complex collisions between accidentals of a
-chord are handled much better.
-
-* Better spacing: both globally and locally. This includes subtle
-details like optical stem spacing.
-
-* More support for ancient notation: mensural ligatures, ambitus
-(pitch range) of voices, more shapes, etc.
-
-* More support for piano notation: bracket pedals, directed arpeggios,
-arpeggio brackets.
-
-* Easier music polyphonic music entry.
-
-* More extensibility, many speedups and bugfixes
-
-* The manual has been thoroughly revised.
-
-* Development is now hosted at http://savannah.gnu.org, and sources
-can be downloaded through anonymous CVS.
-
-* Support for windows: LilyPond is part of the cygwin distribution,
-which comes with a user-friendly installer.
+New features in 1.7 since 1.6
+* Deeper integration of the input language and Scheme. You can now use
+LilyPond identifiers in Scheme, and use Scheme expressions instead of
+LilyPond identifiers.
--- /dev/null
+
+\header {
+
+ texidoc = "With @code{ly-id}, you can pass of the result of
+Scheme expressions as lilypond input. Within a Scheme expression, you
+can use, define or change lilypond variables. "
+
+}
+
+
+foo = \notes \transpose c' { d''4-. }
+bra = \notes \transpose c' { e'4-. }
+
+\score {
+ \context Voice \notes\relative c' {
+ c4
+ #(ly-id (make-sequential-music (list foo foo foo )))
+ #(begin (define baz (make-simultaneous-music (list foo bra)))
+ (empty-music))
+ c4
+ \baz
+ c4
+ }
+}
--- /dev/null
+/*
+identifier-smob.cc -- implement glue to pass Scheme expressions off as
+identifiers.
+
+source file of the GNU LilyPond music typesetter
+
+(c) 2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+*/
+#include "identifier-smob.hh"
+/*
+ C&P from example/box.c
+ */
+
+scm_t_bits package_tag;
+
+/* Print a textual represenation of the smob to a given port. */
+static int
+print_box (SCM b, SCM port, scm_print_state *pstate)
+{
+ SCM value = SCM_CELL_OBJECT_1 (b);
+
+ scm_puts ("#<packaged object ", port);
+ scm_write (value, port);
+ scm_puts (">", port);
+
+ /* Non-zero means success. */
+ return 1;
+}
+
+
+/* This defines the primitve `make-box', which returns a new smob of
+ type `box', initialized to `#f'. */
+LY_DEFINE(package_identifier, "ly-id", 1,0,0, (SCM arg),
+ "Package a Scheme object, so it is treated as an identifier.")
+{
+ /* This macro creates the new objects, stores the value `#f' into it
+ and returns it to the caller. */
+ SCM_RETURN_NEWSMOB (package_tag, arg);
+}
+
+
+/* This is the primitive `box-ref' which returns the object stored in
+ the box. */
+SCM
+unpack_identifier(SCM box)
+{
+ if (SCM_IMP(box) || SCM_CELL_TYPE(box) != package_tag)
+ return SCM_UNDEFINED;
+
+ return SCM_CELL_OBJECT_1 (box);
+}
+
+static void
+init_box_type (void)
+{
+ package_tag = scm_make_smob_type ("box", 0);
+ scm_set_smob_mark (package_tag, scm_markcdr);
+ scm_set_smob_print (package_tag, print_box);
+}
+ADD_SCM_INIT_FUNC(package, init_box_type);
--- /dev/null
+/*
+identifier-smob.hh -- declare identifier smob.
+
+source file of the GNU LilyPond music typesetter
+
+(c) 2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#ifndef IDENTIFIER_SMOB_HH
+#define IDENTIFIER_SMOB_HH
+
+#include "lily-guile.hh"
+
+
+SCM package_identifier (SCM);
+bool identifier_smob_p (SCM);
+SCM unpack_identifier (SCM);
+
+#endif /* IDENTIFIER_SMOB_HH */
+
int lookup_keyword (String);
int scan_bare_word (String);
int scan_escaped_word (String);
-
+ int identifier_type (SCM);
char escaped_char (char) const;
};
#include "lilypond-input-version.hh"
#include "translator-def.hh"
#include "music-output-def.hh"
+#include "identifier-smob.hh"
/*
RH 7 fix (?)
yylval.scm = SCM_EOL;
return SCM_T;
}
- yylval.scm = ly_parse_scm (s, &n, here_input());
-
+ SCM sval = ly_parse_scm (s, &n, here_input());
+
for (int i=0; i < n; i++)
{
yyinput ();
}
char_count_stack_.top () += n;
+ if (unpack_identifier (sval) != SCM_UNDEFINED)
+ {
+ yylval.scm = unpack_identifier(sval);
+ return identifier_type (yylval.scm);
+ }
+
+ yylval.scm = sval;
return SCM_T;
}
<figures>{
}
int
-My_lily_lexer::scan_escaped_word (String str)
+My_lily_lexer::identifier_type(SCM sid)
{
- // use more SCM for this.
-
- SCM sym = ly_symbol2scm (str.to_str0 ());
-
- int l = lookup_keyword (str);
- if (l != -1) {
- return l;
- }
- SCM sid = lookup_identifier (str);
if (gh_string_p (sid)) {
yylval.scm = sid;
return STRING_IDENTIFIER;
yylval.scm = sid;
return MUSIC_OUTPUT_DEF_IDENTIFIER;
}
+ return SCM_IDENTIFIER;
+}
+
+
+int
+My_lily_lexer::scan_escaped_word (String str)
+{
+ // use more SCM for this.
- if (sid != SCM_UNDEFINED) {
+ SCM sym = ly_symbol2scm (str.to_str0 ());
+
+ int l = lookup_keyword (str);
+ if (l != -1) {
+ return l;
+ }
+ SCM sid = lookup_identifier (str);
+ if (sid != SCM_UNDEFINED)
+ {
yylval.scm = sid;
- return SCM_IDENTIFIER;
+ return identifier_type (sid);
}
if ((YYSTATE != notes) && (YYSTATE != chords)) {
(sign (- up down)))
;; arguments are in the form (up . down)
-(define (beam-dir-majority count total)
+(define-public (beam-dir-majority count total)
(dir-compare (car count) (cdr count)))
-(define (beam-dir-majority-median count total)
+(define-public (beam-dir-majority-median count total)
"First try majority. If that doesn't work, try median."
(let ((maj (dir-compare (car count) (cdr count))))
(if (not (= maj 0))
))
-(define (beam-dir-mean count total)
+(define-public (beam-dir-mean count total)
(dir-compare (car total) (cdr total)))
-(define (beam-dir-median count total)
+(define-public (beam-dir-median count total)
(if (and (> (car count) 0)
(> (cdr count) 0))
(dir-compare (/ (car total) (car count)) (/ (cdr total) (cdr count)))
;; DONT use non-ascii characters, even if ``it works'' in Windows
-(define chord::names-alist-american '())
+(define-public chord::names-alist-american '())
(set! chord::names-alist-american
(append
;; American style chordnames use no "no",
;; but otherwise very similar to banter for now
-(define (chord::name-american tonic exception-part unmatched-steps
+(define-public (chord::name-american tonic exception-part unmatched-steps
bass-and-inversion steps)
(let ((additions (chord::additions unmatched-steps))
(subtractions #f))
;;
;; DONT use non-ascii characters, even if ``it works'' in Windows
-(define chord::names-alist-jazz '())
+(define-public chord::names-alist-jazz '())
(set! chord::names-alist-jazz
(append
'(
;; If you set subtract #f, the chord::inner-name-jazz does not see any
;; subtractions, ever, so they don't turn up in the chord name.
;;
-(define (chord::name-jazz tonic exception-part unmatched-steps
+(define-public (chord::name-jazz tonic exception-part unmatched-steps
bass-and-inversion steps)
(let ((additions (chord::additions unmatched-steps))
;; get no 'omit' or 'no'
(stem-attachment-function . ,note-head-style->attachment-coordinates)
(font-family . ancient)
(style . mensural)
+ (glyph-name-procedure . ,find-notehead-symbol)
(meta . ((interfaces . (ligature-head-interface rhythmic-head-interface
font-interface
note-head-interface staff-symbol-referencer-interface))))
m
))
+(define-public (empty-music)
+ (ly-id (ly-make-music "Music"))
+ )
;;;
; Make a function that checks score element for being of a specific type.
(string-encode-integer (quotient i 26))))))
-(define ((every-nth-bar-number-visible n) barnum) (= 0 (modulo barnum n)))
+(define-public ((every-nth-bar-number-visible n) barnum) (= 0 (modulo barnum n)))
(define-public (default-bar-number-visibility barnum) (> barnum 1))