From: Jan Nieuwenhuizen Date: Sun, 18 Apr 2004 20:14:32 +0000 (+0000) Subject: (NEWLYRICS): Switch to LYRICS mode for lyrics. X-Git-Tag: release/2.3.1~69 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fdceddc88e0861fb9c976c9485a4836a1ffb1c69;p=lilypond.git (NEWLYRICS): Switch to LYRICS mode for lyrics. Fix for simple case: input/simple-song.ly, more complex stuff does not work yet. --- diff --git a/ChangeLog b/ChangeLog index fd2f9caedb..8d94ba6e51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-04-18 Jan Nieuwenhuizen + + * 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 * lily/parser.yy (Prefix_composite_music): split Composite_music diff --git a/input/simple-song.ly b/input/simple-song.ly index 0b1023628c..b7b42d99a8 100644 --- a/input/simple-song.ly +++ b/input/simple-song.ly @@ -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! diff --git a/lily/lexer.ll b/lily/lexer.ll index b999b0477f..aa44ebf2f6 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -555,7 +555,6 @@ HYPHEN -- if (!close_input ()) /* Returns YY_NULL */ yyterminate (); - return EOI; } else if (!close_input ()) /* Returns YY_NULL */ diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 0365f15302..44ab32fcd3 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -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); diff --git a/lily/parser.yy b/lily/parser.yy index 8221572904..56ca971ea6 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -338,6 +338,7 @@ or %type context_mod_list %type lyric_element %type bass_number br_bass_figure bass_figure figure_list figure_spec +%type new_lyrics %token DIGIT %token NOTENAME_PITCH %token TONICNAME_PITCH @@ -379,7 +380,8 @@ or %type sub_quotes sup_quotes %type toplevel_music %type simple_element event_chord command_element -%type Composite_music Simple_music Prefix_composite_music Grouped_music_list +%type Composite_music Simple_music Prefix_composite_music +%type Grouped_music_list %type Repeated_music %type Alternative_music %type tremolo_type @@ -388,29 +390,31 @@ or %type identifier_init %type simple_string -%type note_chord_element chord_body chord_body_element -%type chord_body_elements -%type steno_duration optional_notemode_duration multiplied_duration +%type note_chord_element chord_body chord_body_element +%type chord_body_elements +%type steno_duration optional_notemode_duration multiplied_duration -%type post_events -%type gen_text_def direction_less_event direction_reqd_event -%type steno_pitch pitch absolute_pitch pitch_also_in_chords -%type steno_tonic_pitch +%type post_events +%type gen_text_def direction_less_event direction_reqd_event +%type steno_pitch pitch absolute_pitch pitch_also_in_chords +%type steno_tonic_pitch %type duration_length fraction -%type new_chord step_number chord_items chord_item chord_separator step_numbers +%type chord_item chord_items chord_separator new_chord +%type step_number step_numbers -%type embedded_scm scalar +%type embedded_scm scalar %type Music Sequential_music Simultaneous_music %type relative_music re_rhythmed_music %type music_property_def context_change -%type context_prop_spec -%type Music_list -%type property_operation context_mod context_def_mod optional_context_mod -%type music_output_def_body music_output_def_head +%type context_prop_spec +%type Music_list +%type property_operation +%type context_mod context_def_mod optional_context_mod +%type music_output_def_body music_output_def_head %type post_event tagged_post_event -%type command_req -%type string_number_event +%type command_req +%type string_number_event %type string bare_number number_expression number_term number_factor %type 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; diff --git a/ly/declarations-init.ly b/ly/declarations-init.ly index bb9506f742..360c178ea0 100644 --- a/ly/declarations-init.ly +++ b/ly/declarations-init.ly @@ -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) diff --git a/scm/lily.scm b/scm/lily.scm index 55d6dc71fc..963f064ce1 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -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)