From f085359b3c6e6cfdcc6b663cebb6c7e40b2587b0 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 18 Apr 2004 14:13:37 +0000 Subject: [PATCH] * Documentation/user/lilypond.tely: Add comment and workaround for gs-8.01 crash. Fixes make web. * lily/lexer.ll, lily/parser.yy: * input/simple.ly: New file. * input/simple-song.ly: Idem. --- ChangeLog | 25 +++++- Documentation/user/lilypond.tely | 4 +- input/simple-song.ly | 16 ++++ input/simple.ly | 7 ++ lily/beaming-info.cc | 4 +- lily/parser.yy | 144 +++++++++++++------------------ lily/pitch.cc | 1 + 7 files changed, 110 insertions(+), 91 deletions(-) create mode 100644 input/simple-song.ly create mode 100644 input/simple.ly diff --git a/ChangeLog b/ChangeLog index aafb8041ae..5ddb1543b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,26 @@ 2004-04-18 Jan Nieuwenhuizen - * lily/lexer.ll: - * lily/parser.yy: In lyrics mode, return LYRICS_STRING. Use notes - mode at start of maininput. Grok toplevel composite music - expression, put in score and book. + * Documentation/user/lilypond.tely: Add comment and workaround for + gs-8.01 crash. Fixes make web. + + Simplification of toplevel music. + + * lily/lexer.ll, lily/parser.yy: + + * In LYRICS mode, return LYRICS_STRING. This fixes one + shift/reduce problem. + + * Use NOTES mode at start of maininput. + + * Grok toplevel composite music expression, put in score and book. + + * Grok \relative COMPOSITE_MUSIC, make relative on middleC. + + * \addlyrics is a shortcut for \context Lyrics \lyricsto "" \lyrics + + * input/simple.ly: New file. + + * input/simple-song.ly: Idem. 2004-04-16 Han-Wen Nienhuys diff --git a/Documentation/user/lilypond.tely b/Documentation/user/lilypond.tely index 9f1e8e6a11..c06925c2f0 100644 --- a/Documentation/user/lilypond.tely +++ b/Documentation/user/lilypond.tely @@ -102,7 +102,8 @@ Copyright @copyright{} 1999--2004 by the authors @vskip 20pt - +%% Not yet debugged or reported. This crashes gs-8.01: +%% compiling gs-8.01 right now... -- jcn @lilypond[raggedright] \score { \context Lyrics \notes { @@ -117,7 +118,6 @@ Copyright @copyright{} 1999--2004 by the authors } } @end lilypond - @end titlepage diff --git a/input/simple-song.ly b/input/simple-song.ly new file mode 100644 index 0000000000..fed51a97ed --- /dev/null +++ b/input/simple-song.ly @@ -0,0 +1,16 @@ +%% A simple song in LilyPond +<< + \relative { + \clef bass + d2 d c4 bes a2 \break + c2 c d4 f g2 + } + + \addlyrics { + My first Li -- ly song, + Not much can go wrong! + } +>> + +%% Optional helper for automatic updating by convert-ly. May be omitted. +\version "2.3.0" diff --git a/input/simple.ly b/input/simple.ly new file mode 100644 index 0000000000..744a969c13 --- /dev/null +++ b/input/simple.ly @@ -0,0 +1,7 @@ +%% A simple piece in LilyPond, a scale. +\relative { + c' d e f g a b c +} + +%% Optional helper for automatic updating by convert-ly. May be omitted. +\version "2.3.0" diff --git a/lily/beaming-info.cc b/lily/beaming-info.cc index 9382b6dc9b..1e4e6c0956 100644 --- a/lily/beaming-info.cc +++ b/lily/beaming-info.cc @@ -88,9 +88,7 @@ Beaming_info_list::beamify (Moment &beat_length,bool subdivide) do { if (splits[d].infos_.size () != 1) - { - splits[d].infos_.boundary (-d, 0).beams_i_drul_[-d] = middle_beams; - } + splits[d].infos_.boundary (-d, 0).beams_i_drul_[-d] = middle_beams; } while (flip (&d) != LEFT); diff --git a/lily/parser.yy b/lily/parser.yy index 1382e8ae1b..b4a509c615 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -164,6 +164,27 @@ set_property_music (SCM sym, SCM value) return p; } +Music* +make_music_relative (Pitch start, Music *music) +{ + Music *relative = MY_MAKE_MUSIC ("RelativeOctaveMusic"); + relative->set_property ("element", music->self_scm ()); + + Pitch last = music->to_relative_octave (start); + if (lily_1_8_relative) + music->set_property ("last-pitch", last.smobbed_copy ()); + return relative; +} + +Music* +make_lyric_combine_music (SCM name, Music *music) +{ + Music *combine = MY_MAKE_MUSIC ("NewLyricCombineMusic"); + combine->set_property ("element", music->self_scm ()); + combine->set_property ("associated-context", name); + return combine; +} + %} /* We use SCMs to do strings, because it saves us the trouble of @@ -196,19 +217,10 @@ yylex (YYSTYPE *s, void *v) %} -%expect 4 +%expect 3 /* - Four shift/reduce problems: - -1. foo = bar. - - "bar" -> String -> Lyric -> Music -> music-assignment - - "bar" -> String -> string-assignment - - -Similar problem for + Three shift/reduce problems: 2. \markup identifier. @@ -225,9 +237,6 @@ or \repeat { \repeat } \alternative ) - ---hwn - */ @@ -517,42 +526,9 @@ toplevel_expression: } ; -/* FIXME: Experimental kludge for automatic relative music - This will change or go away. */ -language: '@' - | '@' STRING { - /* FIXME? */ - THIS->lexer_->push_initial_state (); - THIS->lexer_->new_input (ly_scm2string ($2) + ".ly", - THIS->lexer_->sources_); - THIS->lexer_->pop_state (); - } - ; - toplevel_music: Composite_music { } - /* FIXME: Experimental kludge for automatic relative music - This will change or go away. - - How to introduce: [\notes]\relative 'c { } in an - implicit or otherwise intuitive way? */ - | language Music_list { - SCM lst = $2; - Music *m = MY_MAKE_MUSIC ("SequentialMusic"); - m->set_property ("elements", ly_car (lst)); - m->set_spot (THIS->here_input ()); - - Pitch middle_c; - $$ = MY_MAKE_MUSIC ("RelativeOctaveMusic"); - $$->set_property ("element", m->self_scm ()); - - Pitch last = m->to_relative_octave (middle_c); - if (lily_1_8_relative) - $$->set_property ("last-pitch", last.smobbed_copy ()); - - scm_gc_unprotect_object (m->self_scm ()); - } ; embedded_scm: @@ -561,8 +537,6 @@ embedded_scm: ; - - lilypond_header_body: { $$ = ly_make_anonymous_module (); @@ -1192,33 +1166,39 @@ basic music objects too, since the meaning is different. relative_music: RELATIVE absolute_pitch Music { - Music *p = $3; - Pitch pit = *unsmob_pitch ($2); - $$ = MY_MAKE_MUSIC ("RelativeOctaveMusic"); - - $$->set_property ("element", p->self_scm ()); - scm_gc_unprotect_object (p->self_scm ()); - - Pitch last = p->to_relative_octave (pit); - if (lily_1_8_relative) - $$->set_property ("last-pitch", last.smobbed_copy ()); + Music *m = $3; + Pitch start = *unsmob_pitch ($2); + $$ = make_music_relative (start, m); + scm_gc_unprotect_object (m->self_scm ()); + } + | RELATIVE Composite_music { + Music *m = $2; + /* FIXME: why is octave==0 and default not middleC? */ + Pitch middle_c (-1, 0, 0); + $$ = make_music_relative (middle_c, m); + scm_gc_unprotect_object (m->self_scm ()); } ; re_rhythmed_music: - ADDLYRICS Music Music { - Music *l = MY_MAKE_MUSIC ("LyricCombineMusic"); - l->set_property ("elements", scm_listify ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED)); - scm_gc_unprotect_object ($3->self_scm ()); - scm_gc_unprotect_object ($2->self_scm ()); - $$ = l; + ADDLYRICS { THIS->lexer_->push_lyric_state (); } + /* cont */ + Music { + THIS->lexer_->pop_state (); + + Music *music = $3; + 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 ()); } | LYRICSTO string Music { - Music *l = MY_MAKE_MUSIC ("NewLyricCombineMusic"); - l->set_property ("element", $3->self_scm ()); - scm_gc_unprotect_object ($3->self_scm ()); - $$ = l; - l->set_property ("associated-context", $2); + Music *music = $3; + SCM name = $2; + $$ = make_lyric_combine_music (name, music); + scm_gc_unprotect_object (music->self_scm ()); } ; @@ -1496,30 +1476,30 @@ command_element: } | OCTAVE { THIS->push_spot (); } pitch { - Music *l = MY_MAKE_MUSIC ("RelativeOctaveCheck"); - $$ = l; + Music *m = MY_MAKE_MUSIC ("RelativeOctaveCheck"); + $$ = m; $$->set_spot (THIS->pop_spot ()); $$->set_property ("pitch", $3); } | E_LEFTSQUARE { - Music *l = MY_MAKE_MUSIC ("LigatureEvent"); - l->set_property ("span-direction", scm_int2num (START)); - l->set_spot (THIS->here_input ()); + Music *m = MY_MAKE_MUSIC ("LigatureEvent"); + m->set_property ("span-direction", scm_int2num (START)); + m->set_spot (THIS->here_input ()); $$ = MY_MAKE_MUSIC ("EventChord"); - $$->set_property ("elements", scm_cons (l->self_scm (), SCM_EOL)); - scm_gc_unprotect_object (l->self_scm ()); + $$->set_property ("elements", scm_cons (m->self_scm (), SCM_EOL)); + scm_gc_unprotect_object (m->self_scm ()); $$->set_spot (THIS->here_input ()); } | E_RIGHTSQUARE { - Music *l = MY_MAKE_MUSIC ("LigatureEvent"); - l->set_property ("span-direction", scm_int2num (STOP)); - l->set_spot (THIS->here_input ()); + Music *m = MY_MAKE_MUSIC ("LigatureEvent"); + m->set_property ("span-direction", scm_int2num (STOP)); + m->set_spot (THIS->here_input ()); $$ = MY_MAKE_MUSIC ("EventChord"); - $$->set_property ("elements", scm_cons (l->self_scm (), SCM_EOL)); + $$->set_property ("elements", scm_cons (m->self_scm (), SCM_EOL)); $$->set_spot (THIS->here_input ()); - scm_gc_unprotect_object (l->self_scm ()); + scm_gc_unprotect_object (m->self_scm ()); } | E_BACKSLASH { $$ = MY_MAKE_MUSIC ("VoiceSeparator"); diff --git a/lily/pitch.cc b/lily/pitch.cc index 58e2b0baa4..8004d2fe65 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -20,6 +20,7 @@ Pitch::Pitch (int o, int n, int a) normalise (); } +/* FIXME: why is octave == 0 and default not middleC ? */ Pitch::Pitch () { notename_ = 0; -- 2.39.5