From 1e9dfe1c12b59db134ab9d0afc5254e94139939c Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 21:45:16 +0000 Subject: [PATCH] lilypond-1.1.14 --- lily/parser.yy | 184 +++++++++++++++++++++---------------------------- 1 file changed, 78 insertions(+), 106 deletions(-) diff --git a/lily/parser.yy b/lily/parser.yy index 2cf38355e3..a0c4fbdba7 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -46,23 +46,13 @@ #include "repeated-music.hh" // mmm -Mudela_version oldest_version ("1.0.7"); +Mudela_version oldest_version ("1.0.10"); Mudela_version version ("1.0.12"); // needed for bison.simple's malloc() and free() #include -int const GUESS_PLET = 5; -int guess_plet_a[GUESS_PLET] = -{ - 1, - 3, - 2, - 3, - 4 -}; - struct Assignment { String *name_p_; Identifier *id_p_; @@ -136,7 +126,6 @@ Paper_def* current_paper = 0; char c; const char *consstr; int i; - int pair[2]; int ii[10]; } %{ @@ -162,7 +151,6 @@ yylex (YYSTYPE *s, void * v_l) %token ACCEPTS %token ALTERNATIVE %token BAR -%token BEAMPLET %token CADENZA %token CHORDMODIFIERS %token CHORDS @@ -170,7 +158,6 @@ yylex (YYSTYPE *s, void * v_l) %token CM_T %token CONSISTS %token DURATION -%token END %token EXTENDER %token FONT %token GROUPING @@ -179,21 +166,17 @@ yylex (YYSTYPE *s, void * v_l) %token KEY %token KEYSIGNATURE %token LYRICS -%token MAEBTELP %token MARK %token MEASURES %token MIDI %token MM_T -%token MUSIC %token MUSICAL_PITCH %token NAME %token NOTENAMES %token NOTES -%token OCTAVE %token PAPER %token PARTIAL %token PENALTY -%token PLET %token PROPERTY %token PT_T %token RELATIVE @@ -208,7 +191,6 @@ yylex (YYSTYPE *s, void * v_l) %token SPANDYNAMIC %token SYMBOLTABLES %token TABLE -%token TELP %token TEMPO %token TIME_T %token TIMES @@ -223,6 +205,7 @@ yylex (YYSTYPE *s, void * v_l) %type dots %token DIGIT %token NOTENAME_PITCH +%token TONICNAME_PITCH %token CHORDMODIFIER_PITCH %token DURATION_IDENTIFIER %token IDENTIFIER @@ -238,7 +221,6 @@ yylex (YYSTYPE *s, void * v_l) %token SCORE_IDENTIFIER %token MIDI_IDENTIFIER %token PAPER_IDENTIFIER -%token REQUEST_IDENTIFIER %token REAL %token DURATION RESTNAME %token STRING @@ -250,9 +232,8 @@ yylex (YYSTYPE *s, void * v_l) %type box %type open_request_parens close_request_parens %type open_abbrev_parens -%type open_plet_parens close_plet_parens %type sub_quotes sup_quotes -%type simple_element request_chord command_element Simple_music Composite_music +%type simple_element request_chord command_element Simple_music Composite_music %type Alternative_music Repeated_music %type abbrev_type %type int unsigned @@ -266,11 +247,12 @@ yylex (YYSTYPE *s, void * v_l) %type symtables symtables_body %type explicit_musical_pitch steno_musical_pitch musical_pitch absolute_musical_pitch +%type steno_tonic_pitch %type steno_notepitch %type pitch_list -%type chord -%type chord_additions chord_subtractions -%type chord_note +%type chord notemode_chord +%type chord_additions chord_subtractions +%type chord_addsub chord_note %type midi_block midi_body %type duration_length @@ -282,7 +264,6 @@ yylex (YYSTYPE *s, void * v_l) %type real_expression real dimension %type abbrev_command_req %type post_request structured_post_request -%type plet_fraction %type command_req verbose_command_req %type script_req dynamic_req extender_req %type string @@ -297,7 +278,8 @@ yylex (YYSTYPE *s, void * v_l) %type tempo_request %type notenames_body notenames_block chordmodifiers_block -%expect 6 +/* 5 extra for notemode_chord */ +%expect 15 %left '-' '+' @@ -613,6 +595,11 @@ optional_semicolon: | ';' ; +optional_dot: + /* empty */ + | '.' + ; + paper_def_body: /* empty */ { Paper_def *p = THIS->default_paper_p (); @@ -787,6 +774,9 @@ Simple_music: | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); } | property_def | translator_change + | Simple_music '*' unsigned '/' unsigned { } + | Simple_music '*' unsigned { } + ; @@ -807,7 +797,7 @@ Composite_music: THIS->remember_spot (); } /* CONTINUED */ - int '/' int Music + unsigned '/' unsigned Music { $$ = new Compressed_music ($3, $5, $6); @@ -820,6 +810,10 @@ Composite_music: $$ = new Transposed_music ($3, *$2); delete $2; } + | TRANSPOSE steno_tonic_pitch Music { + $$ = new Transposed_music ($3, *$2); + delete $2; + } | NOTES { THIS->lexer_p_->push_note_state (); } Music @@ -912,7 +906,10 @@ abbrev_command_req: | COMMAND_IDENTIFIER { $$ = $1->access_content_Request (true); } -/* +/* TODO */ +/* | '~' { + $$ = new Command_tie_req; + } | '[' { $$ = new Beam_req; $$->spantype = Span_req::START; @@ -1073,6 +1070,20 @@ steno_musical_pitch: } ; +steno_tonic_pitch: + TONICNAME_PITCH { + $$ = $1; + } + | TONICNAME_PITCH sup_quotes { + $$ = $1; + $$->octave_i_ += $2; + } + | TONICNAME_PITCH sub_quotes { + $$ = $1; + $$->octave_i_ += - $2; + } + ; + explicit_musical_pitch: MUSICAL_PITCH '{' int_list '}' {/* ugh */ Array &a = *$3; @@ -1144,39 +1155,7 @@ dynamic_req: } ; -plet_fraction: - unsigned '/' unsigned { - $$[0] = $1; - $$[1] = $3; - } - | - '/' unsigned { - int num = $2 >? 1; - $$[0] = guess_plet_a[(num plet_.type_i_ = $2[1]; - THIS->plet_.iso_i_ = $2[0]; - THIS->default_duration_.plet_ = THIS->plet_; - } - | TELP { - $$ = TELP; - THIS->plet_.type_i_ = 1; - THIS->plet_.iso_i_ = 1; - THIS->default_duration_.plet_ = THIS->plet_; - } - | TELP plet_fraction { - $$ = TELP; - THIS->plet_.type_i_ = $2[1]; - THIS->plet_.iso_i_ = $2[0]; - THIS->default_duration_.plet_ = THIS->plet_; - } - ; close_request_parens: '~' { @@ -1194,7 +1173,6 @@ close_request_parens: | E_BIGGER { $$ = '>'; } - | close_plet_parens ; open_abbrev_parens: @@ -1209,20 +1187,6 @@ open_abbrev_parens: } ; -open_plet_parens: - '[' plet_fraction { - $$ = BEAMPLET; - THIS->plet_.type_i_ = $2[1]; - THIS->plet_.iso_i_ = $2[0]; - THIS->default_duration_.plet_ = THIS->plet_; - } - | PLET plet_fraction { - $$ = PLET; - THIS->plet_.type_i_ = $2[1]; - THIS->plet_.iso_i_ = $2[0]; - THIS->default_duration_.plet_ = THIS->plet_; - } - ; open_request_parens: E_EXCLAMATION { @@ -1235,7 +1199,6 @@ open_request_parens: $$='['; } | open_abbrev_parens - | open_plet_parens ; @@ -1357,6 +1320,12 @@ duration_length: steno_duration { $$ = $1; } + | duration_length '*' unsigned { + $$->plet_.iso_i_ *= $3; + } + | duration_length '/' unsigned { + $$->plet_.type_i_ *= $3; + } ; dots: @@ -1390,7 +1359,6 @@ steno_duration: THIS->parser_error (_f ("not a duration: %d", $1)); else { $$->durlog_i_ = Duration_convert::i2_type ($1); - $$->set_plet (THIS->plet_.iso_i_, THIS->plet_.type_i_); } } | DURATION_IDENTIFIER { @@ -1399,12 +1367,6 @@ steno_duration: | steno_duration '.' { $$->dots_i_ ++; } - | steno_duration '*' unsigned { - $$->plet_.iso_i_ *= $3; - } - | steno_duration '/' unsigned { - $$->plet_.type_i_ *= $3; - } ; @@ -1425,8 +1387,7 @@ abbrev_type: simple_element: steno_notepitch notemode_duration { - if (!THIS->lexer_p_->note_state_b () - && !THIS->lexer_p_->chord_state_b ()) + if (!THIS->lexer_p_->note_state_b ()) THIS->parser_error (_ ("have to be in Note mode for notes")); $1->duration_ = *$2; $$ = THIS->get_note_element ($1, $2); @@ -1451,40 +1412,48 @@ simple_element: $$ = THIS->get_word_element (*$1, $2); delete $1; } - | '@' chord { + | chord { if (!THIS->lexer_p_->chord_state_b ()) THIS->parser_error (_ ("have to be in Chord mode for chords")); + $$ = $1; + } + | '@' notemode_chord { + if (!THIS->lexer_p_->note_state_b ()) + THIS->parser_error (_ ("have to be in Note mode for @chords")); $$ = $2; } ; - chord: - notemode_duration steno_musical_pitch chord_additions chord_subtractions { - $$ = THIS->get_chord (*$2, $3, $4, *$1); + steno_tonic_pitch notemode_duration chord_additions chord_subtractions { + $$ = THIS->get_chord (*$1, $3, $4, *$2); }; -chord_additions: +notemode_chord: + steno_musical_pitch notemode_duration chord_additions chord_subtractions { + $$ = THIS->get_chord (*$1, $3, $4, *$2); + }; + +chord_additions: { $$ = new Array; } - | chord_additions chord_note { - $1->push (*$2); - $$ = $1; - } - | chord_additions CHORDMODIFIER_PITCH { - /* - urg, this is kind of ugly. - all but "sus" chord modifiers can be - handled as chord_additions... - */ - $1->push (*$2); + | '-' { + $$ = new Array; + } + | chord_additions chord_addsub { $$ = $1; + $$->push (*$2); } ; +chord_addsub: + chord_note optional_dot + | CHORDMODIFIER_PITCH optional_dot + ; + chord_note: - UNSIGNED { + UNSIGNED { $$ = new Musical_pitch; $$->notename_i_ = ($1 - 1) % 7; $$->octave_i_ = $1 > 7 ? 1 : 0; @@ -1508,9 +1477,12 @@ chord_subtractions: { $$ = new Array; } - | '^' chord_subtractions chord_note { - $2->push (*$3); - $$ = $2; + | '^' { + $$ = new Array; + } + | chord_subtractions chord_addsub { + $$ = $1; + $$->push (*$2); } ; -- 2.39.2