]> git.donarmstrong.com Git - lilypond.git/commitdiff
(NEWLYRICS): Switch to LYRICS mode for lyrics.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 18 Apr 2004 20:14:32 +0000 (20:14 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 18 Apr 2004 20:14:32 +0000 (20:14 +0000)
Fix for simple case: input/simple-song.ly, more complex stuff
does not work yet.

ChangeLog
input/simple-song.ly
lily/lexer.ll
lily/my-lily-lexer.cc
lily/parser.yy
ly/declarations-init.ly
scm/lily.scm

index fd2f9caedb5c97a0f52df2a120dd3e0cd02196c0..8d94ba6e51635fd3f20eaa76904d59bd5cb707dc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-04-18  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * lily/parser.yy (NEWLYRICS): Switch to LYRICS mode for lyrics.
+       Fix for simple case: input/simple-song.ly, more complex stuff
+       does not work yet.
+
 2004-04-18  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
        * lily/parser.yy (Prefix_composite_music): split Composite_music
index 0b1023628c4c6a7acc151575fcfe35aca9eed12d..b7b42d99a8c6aa04512fa88d0708f54b3760fc0a 100644 (file)
@@ -5,7 +5,6 @@
        d2 d c4 bes a2 \break
        c2 c d4 f g2
     }
-
     \newlyrics {
        My first Li -- ly song,
        Not much can go wrong!
index b999b0477f3c486ab988e16ba73508bcb7ef5616..aa44ebf2f6796cd6ad39533075663dad74542968 100644 (file)
@@ -555,7 +555,6 @@ HYPHEN              --
                if (!close_input ())
                /* Returns YY_NULL */
                        yyterminate ();
-               return EOI;
        }
        else if (!close_input ())
                /* Returns YY_NULL */
index 0365f15302f5d7922db901272f50800112ce61ff..44ab32fcd37f52fb2fffdbec9c49bd2d03b10bde 100644 (file)
@@ -150,9 +150,9 @@ My_lily_lexer::lookup_keyword (String s)
 }
 
 SCM
-My_lily_lexer::lookup_identifier (String s)
+My_lily_lexer::lookup_identifier (String name)
 {
-  SCM sym = ly_symbol2scm (s.to_str0());
+  SCM sym = ly_symbol2scm (name.to_str0 ());
   for (SCM s = scopes_; ly_c_pair_p (s); s = ly_cdr (s))
     {
       SCM var = ly_module_lookup (ly_car (s), sym);
index 8221572904f76aadb0d098fddcf7214dd87bff19..56ca971ea6e9154282718021159be18be623eafe 100644 (file)
@@ -338,6 +338,7 @@ or
 %type <scm>    context_mod_list
 %type <scm>    lyric_element
 %type <scm>    bass_number br_bass_figure bass_figure figure_list figure_spec
+%type <music>  new_lyrics
 %token <i>     DIGIT
 %token <scm>   NOTENAME_PITCH
 %token <scm>   TONICNAME_PITCH
@@ -379,7 +380,8 @@ or
 %type <i>      sub_quotes sup_quotes
 %type <music>  toplevel_music
 %type <music>  simple_element event_chord command_element
-%type <music>  Composite_music Simple_music Prefix_composite_music Grouped_music_list
+%type <music>  Composite_music Simple_music Prefix_composite_music
+%type <music>  Grouped_music_list
 %type <music>  Repeated_music
 %type <scm>     Alternative_music
 %type <i>      tremolo_type
@@ -388,29 +390,31 @@ or
 %type <scm>    identifier_init
 %type <scm>    simple_string
 
-%type <music> note_chord_element chord_body chord_body_element
-%type <scm>  chord_body_elements
-%type <scm> steno_duration optional_notemode_duration multiplied_duration
+%type <music>  note_chord_element chord_body chord_body_element
+%type <scm>    chord_body_elements
+%type <scm>    steno_duration optional_notemode_duration multiplied_duration
        
-%type <scm>   post_events
-%type <music> gen_text_def direction_less_event direction_reqd_event
-%type <scm>   steno_pitch pitch absolute_pitch pitch_also_in_chords
-%type <scm>    steno_tonic_pitch
+%type <scm>    post_events
+%type <music>  gen_text_def direction_less_event direction_reqd_event
+%type <scm>    steno_pitch pitch absolute_pitch pitch_also_in_chords
+%type <scm>    steno_tonic_pitch
 %type <scm>    duration_length fraction
 
-%type <scm> new_chord step_number chord_items chord_item chord_separator step_numbers
+%type <scm>    chord_item chord_items chord_separator new_chord
+%type <scm>    step_number step_numbers 
 
-%type <scm>  embedded_scm scalar
+%type <scm>    embedded_scm scalar
 %type <music>  Music Sequential_music Simultaneous_music
 %type <music>  relative_music re_rhythmed_music
 %type <music>  music_property_def context_change
-%type <scm> context_prop_spec
-%type <scm> Music_list
-%type <scm> property_operation context_mod context_def_mod optional_context_mod
-%type <outputdef>  music_output_def_body music_output_def_head
+%type <scm>    context_prop_spec
+%type <scm>    Music_list
+%type <scm>    property_operation
+%type <scm>    context_mod context_def_mod optional_context_mod
+%type <outputdef>      music_output_def_body music_output_def_head
 %type <music>  post_event tagged_post_event
-%type <music> command_req
-%type <music> string_number_event
+%type <music>  command_req
+%type <music>  string_number_event
 %type <scm>    string bare_number number_expression number_term number_factor
 %type <score>  score_block score_body
 
@@ -448,10 +452,9 @@ toplevel_expression:
        }
        | toplevel_music {
                Music_output_def *paper = get_paper (THIS);
-               // delay?
-               // SCM proc = paper->get_scmvar ("toplevel-music-handler");
-               SCM proc = ly_scheme_function ("ly:parser-add-book-and-score");
-               //SCM proc = ly_scheme_function ("toplevel-music-handler");
+               SCM proc = THIS->lexer_->lookup_identifier ("toplevel-music-handler");
+               if (proc == SCM_UNDEFINED)
+                       proc = ly_scheme_function ("ly:parser-add-book-and-score");
                scm_call_2 (proc, THIS->self_scm (), $1->self_scm ());
                scm_gc_unprotect_object (paper->self_scm ());
        }
@@ -961,8 +964,8 @@ context_mod_list:
 
 
 Composite_music:
-       Prefix_composite_music { $$ = $1 ; }
-       | Grouped_music_list { $$ = $1 }
+       Prefix_composite_music { $$ = $1; }
+       | Grouped_music_list { $$ = $1; }
        ;
 
 Grouped_music_list:
@@ -1176,14 +1179,27 @@ relative_music:
        ;
 
 new_lyrics:
-       NEWLYRICS Grouped_music_list {
-       /*
-               Can also use Music at the expensive of two S/Rs
-similar to \repeat \alternative
-       */
+       NEWLYRICS { THIS->lexer_->push_lyric_state (); }
+       /*cont */
+       Grouped_music_list {
+       /* Can also use Music at the expensive of two S/Rs similar to
+           \repeat \alternative */
+               THIS->lexer_->pop_state ();
+#if 0
+               $$ = $3;
+#else
+               Music *music = MY_MAKE_MUSIC ("SimultaneousMusic");
+               music->set_property ("elements", scm_list_1 ($3->self_scm ()));
+               $$ = music;
+#endif
        }
-       | new_lyrics NEWLYRICS Grouped_music_list {
-               
+       | new_lyrics NEWLYRICS { THIS->lexer_->push_lyric_state (); }
+       Grouped_music_list {
+               THIS->lexer_->pop_state ();
+               Music *music = MY_MAKE_MUSIC ("SimultaneousMusic");
+               music->set_property ("elements", scm_cons ($4->self_scm (),
+                       $1->get_property ("elements")));
+               $$ = music;
        }
        ;
 
@@ -1197,15 +1213,36 @@ re_rhythmed_music:
                $$ = m;
        }
        | Grouped_music_list new_lyrics {
-               THIS->lexer_->pop_state ();
 
-               Music *music = $1;
+               /* TODO: loop over simultaneous lyric musics? */
+
+               Music *music = $2;
                SCM name = scm_makfrom0str ("");
-               Music *combined = make_lyric_combine_music (name, music);
                SCM context = scm_makfrom0str ("Lyrics");
-               $$ = context_spec_music (context, SCM_UNDEFINED, combined,
-                       SCM_EOL);
-               scm_gc_unprotect_object (music->self_scm ());
+               Music *all = MY_MAKE_MUSIC ("SimultaneousMusic");
+#if 0 // simple only
+               Music *combined = make_lyric_combine_music (name, music);
+               Music *csm = context_spec_music (context, SCM_UNDEFINED,
+                       combined, SCM_EOL);
+               all->set_property ("elements", scm_listify ($1->self_scm (),
+                       csm->self_scm (), SCM_UNDEFINED));
+#else
+               SCM lst = SCM_EOL;
+               for (SCM s = music->get_property ("elements"); ly_c_pair_p (s);
+                       s = ly_cdr (s))
+               {
+                       Music *com = make_lyric_combine_music (name, music);
+                       Music *csm = context_spec_music (context,
+                               SCM_UNDEFINED, com, SCM_EOL);
+                       //lst = ly_snoc (csm->self_scm (), lst);
+                       lst = scm_cons (csm->self_scm (), lst);
+               }
+#endif
+               all->set_property ("elements", scm_cons ($1->self_scm (),
+                       lst));
+               $$ = all;
+               scm_gc_unprotect_object ($1->self_scm ());
+               scm_gc_unprotect_object ($2->self_scm ());
        }
        | LYRICSTO string Music {
                Music *music = $3;
index bb9506f742856ccf2a12ba3e5920c06c922f8723..360c178ea072712c89d5007513035e8d6a6d6979 100644 (file)
@@ -64,14 +64,12 @@ melismaEnd = #(make-span-event 'ManualMelismaEvent STOP)
     #(define $is-paper #t)
     
     #(define font-defaults
-      '((font-encoding . fetaMusic))
-      )
+      '((font-encoding . fetaMusic)))
 
     #(define text-font-defaults
       '((font-encoding . latin1)
        (baseline-skip . 2)
-       (word-space . 0.6)
-       ))
+       (word-space . 0.6)))
 
     #(define page-breaking ly:ragged-page-breaks)
     %%#(define page-breaking ly:optimal-page-breaks)
@@ -141,11 +139,11 @@ partCombineListener = \paper {
 
 \include "property-init.ly"
 
-
-
-% reset default duration
+%% reset default duration
 unusedEntry = \notes { c4 }
 
+%% must have size argument for GUILE 1.6 compat.
+#(define musicQuotes (make-hash-table 29))
 
-% must have size argument for GUILE 1.6 compat.
-#(define musicQuotes (make-hash-table 29)) 
+%%#(define-public toplevel-music-handler ly:parser-add-book-and-score)
+#(define toplevel-music-handler default-toplevel-music-handler)
index 55d6dc71fc5b9fddfbcc5babc06acdd878109b2c..963f064ce1e532c7fb9f917e355edde1e1d2342a 100644 (file)
@@ -34,9 +34,6 @@
       (debug-enable 'backtrace)
       (read-enable 'positions)))
 
-;; FIXME: huh?
-(define-public toplevel-music-handler ly:parser-add-book-and-score)
-
 (define-public (line-column-location line col file)
   "Print an input location, including column number ."
   (string-append (number->string line) ":"
@@ -94,6 +91,8 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; lily specific variables.
+(define-public default-toplevel-music-handler ly:parser-add-book-and-score)
+
 (define-public default-script-alist '())
 
 (define-public safe-mode? #f)