X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fparser.yy;h=ee022a618511671e0ee5e9b8629e10f845e4ef70;hb=21085be16bbb0fc1914210b69476c4f0a3ec92ea;hp=e8c710b8ac6a15235331da1b29cadc4b8f56eaa5;hpb=196bdae43d1d4f13a3080dbb5e5b4dd07f92cb51;p=lilypond.git diff --git a/lily/parser.yy b/lily/parser.yy index e8c710b8ac..ee022a6185 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -53,7 +53,9 @@ TODO: */ #include +#include #include +#include #include "scm-option.hh" @@ -161,10 +163,11 @@ SCM make_chord_step (int step, int alter) { if (step == 7) - alter--; + alter += FLAT; - /* ugh: fucks up above 13 */ - Pitch m(step > 7 ? 1 : 0,(step - 1) % 7, alter); + while(step < 0) + step += 7; + Pitch m((step -1) / 7 , (step - 1) % 7, alter); return m.smobbed_copy (); } @@ -245,8 +248,8 @@ yylex (YYSTYPE *s, void * v) %token BREATHE %token CHORDMODIFIERS %token CHORDS -%token CHORD_CLOSE -%token CHORD_OPEN +%token LESSLESS +%token MOREMORE %token CLEF %token COMMANDSPANREQUEST %token CONSISTS @@ -255,12 +258,11 @@ yylex (YYSTYPE *s, void * v) %token DEFAULT %token DENIES %token DESCRIPTION -%token DURATION %token EXTENDER %token FIGURES FIGURE_OPEN FIGURE_CLOSE %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN %token GRACE -%token ACCIACATURA +%token ACCIACCATURA %token APPOGGIATURA %token GROBDESCRIPTIONS %token HEADER @@ -276,12 +278,10 @@ yylex (YYSTYPE *s, void * v) %token NOTES %token OCTAVE %token ONCE -%token OUTPUTPROPERTY %token OVERRIDE SET REVERT %token PAPER %token PARTCOMBINE %token PARTIAL -%token PITCH %token PITCHNAMES %token PROPERTY %token RELATIVE @@ -367,12 +367,11 @@ yylex (YYSTYPE *s, void * v) %type note_chord_element chord_body chord_body_element %type chord_body_elements %type steno_duration optional_notemode_duration multiplied_duration -%type verbose_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 explicit_pitch steno_tonic_pitch +%type steno_tonic_pitch %type duration_length fraction %type new_chord step_number chord_items chord_item chord_separator step_numbers @@ -541,9 +540,6 @@ identifier_init: $$ = $1->self_scm (); scm_gc_unprotect_object ($$); } - | verbose_duration { - $$ = $1; - } | number_expression { $$ = $1; } @@ -870,7 +866,7 @@ Simultaneous_music: $$->set_spot(THIS->here_input()); } - | '<' Music_list '>' { + | simul_open Music_list simul_close { $$ = MY_MAKE_MUSIC("SimultaneousMusic"); $$->set_mus_property ("elements", ly_car ($2)); $$->set_spot(THIS->here_input()); @@ -893,25 +889,6 @@ Simple_music: $$->set_mus_property ("procedure", $2); $$->set_spot (THIS->here_input()); } - | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm { - SCM pred = $2; - if (!gh_symbol_p ($3)) - { - THIS->parser_error (_ ("Second argument must be a symbol")); - } - /* Should check # args */ - if (!gh_procedure_p (pred)) - { - THIS->parser_error (_ ("First argument must be a procedure taking one argument")); - } - - Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic"); - m->set_mus_property ("predicate", pred); - m->set_mus_property ("grob-property", $3); - m->set_mus_property ("grob-value", $5); - - $$ = m; - } | MUSIC_IDENTIFIER { $$ = unsmob_music ($1); } @@ -922,7 +899,7 @@ Simple_music: grace_head: GRACE { $$ = scm_makfrom0str ("Grace"); } - | ACCIACATURA { $$ = scm_makfrom0str ("Acciaccatura"); } + | ACCIACCATURA { $$ = scm_makfrom0str ("Acciaccatura"); } | APPOGGIATURA { $$ = scm_makfrom0str ("Appoggiatura"); } ; @@ -1022,8 +999,10 @@ basic music objects too, since the meaning is different. csm->set_mus_property ("context-type", scm_string_to_symbol ($2)); - SCM new_id = scm_number_to_string (gh_int2scm (new_context_count ++), - gh_int2scm (10)); + char s[1024]; + snprintf (s, 1024, "uniqueContext%d", new_context_count ++); + + SCM new_id = scm_makfrom0str (s); csm->set_mus_property ("context-id", new_id); $$ = csm; } @@ -1062,15 +1041,20 @@ basic music objects too, since the meaning is different. } | APPLY embedded_scm Music { if (!ly_input_procedure_p ($2)) + { THIS->parser_error (_ ("\\apply takes function argument")); - - SCM ret = gh_call1 ($2, $3->self_scm ()); - Music *m = unsmob_music (ret); - if (!m) { - THIS->parser_error ("\\apply must return a Music"); - m = MY_MAKE_MUSIC("Music"); + $$ = $3; + } + else + { + SCM ret = gh_call1 ($2, $3->self_scm ()); + Music *m = unsmob_music (ret); + if (!m) { + THIS->parser_error ("\\apply must return a Music"); + m = MY_MAKE_MUSIC("Music"); + } + $$ = m; } - $$ = m; } | NOTES { THIS->lexer_->push_note_state (); } @@ -1341,8 +1325,20 @@ note_chord_element: } ; +chord_open: '<' + ; + +chord_close: '>' + ; + +simul_open: LESSLESS + ; + +simul_close: MOREMORE + ; + chord_body: - CHORD_OPEN chord_body_elements CHORD_CLOSE + chord_open chord_body_elements chord_close { $$ = MY_MAKE_MUSIC("EventChord"); $$->set_mus_property ("elements", @@ -1608,7 +1604,7 @@ configurable, i.e. } | open_event { $$ = $1; - dynamic_cast ($$)->set_mus_property ("span-direction", gh_int2scm (STOP)) + dynamic_cast ($$)->set_mus_property ("span-direction", gh_int2scm (STOP)); } | EVENT_IDENTIFIER { $$ = unsmob_music ($1); @@ -1694,9 +1690,6 @@ pitch: steno_pitch { $$ = $1; } - | explicit_pitch { - $$ = $1; - } ; pitch_also_in_chords: @@ -1704,26 +1697,9 @@ pitch_also_in_chords: | steno_tonic_pitch ; -explicit_pitch: - PITCH embedded_scm { - $$ = $2; - if (!unsmob_pitch ($2)) { - THIS->parser_error (_f ("Expecting musical-pitch value", 3)); - $$ = Pitch ().smobbed_copy (); - } - } - ; -verbose_duration: - DURATION embedded_scm { - $$ = $2; - if (!unsmob_duration ($2)) - { - THIS->parser_error (_ ("Must have duration object")); - $$ = Duration ().smobbed_copy (); - } - } - ; + + extender_req: EXTENDER { @@ -1849,9 +1825,6 @@ duration_length: multiplied_duration { $$ = $1; } - | verbose_duration { - $$ = $1; - } ; optional_notemode_duration: @@ -1867,10 +1840,6 @@ optional_notemode_duration: THIS->beam_check ($$); } - | verbose_duration { - $$ = $1; - THIS->default_duration_ = *unsmob_duration ($$); - } ; steno_duration: @@ -1949,12 +1918,12 @@ bass_number: | UNSIGNED { $$ = scm_number_to_string (gh_int2scm ($1), gh_int2scm (10)); } - | STRING { $$ = $1 } + | STRING { $$ = $1; } ; bass_mod: - '-' { $$ = -1; } - | '+' { $$ = 1; } + '-' { $$ = -2; } + | '+' { $$ = 2; } | '!' { $$ = 0; } ; @@ -2120,7 +2089,7 @@ simple_element: ; lyric_element: - full_markup { $$ = $1 } + full_markup { $$ = $1; } | STRING { $$ = $1 ; } ; @@ -2182,10 +2151,10 @@ step_number: $$ = make_chord_step ($1, 0); } | bare_unsigned '+' { - $$ = make_chord_step ($1, 1); + $$ = make_chord_step ($1, SHARP); } | bare_unsigned CHORD_MINUS { - $$ = make_chord_step ($1,-1); + $$ = make_chord_step ($1, FLAT); } ; @@ -2347,7 +2316,7 @@ markup: ; markup_list: - CHORD_OPEN markup_list_body CHORD_CLOSE { $$ = scm_reverse_x ($2, SCM_EOL); } + chord_open markup_list_body chord_close { $$ = scm_reverse_x ($2, SCM_EOL); } ; markup_line: