From: fred Date: Wed, 4 Dec 1996 19:55:58 +0000 (+0000) Subject: lilypond-0.0.14 X-Git-Tag: release/1.5.59~6673 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2916c025ad94b3345cb3063426d898a07efdaa33;p=lilypond.git lilypond-0.0.14 --- diff --git a/hdr/inputcommand.hh b/hdr/inputcommand.hh new file mode 100644 index 0000000000..aeec3b8ad3 --- /dev/null +++ b/hdr/inputcommand.hh @@ -0,0 +1,38 @@ +/* + inputcommand.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef INPUTCOMMAND_HH +#define INPUTCOMMAND_HH +#include "proto.hh" +#include "scalar.hh" +#include "vray.hh" + + +struct Input_command { + Real when; + + /// analogous to argv[] + svec args; + void print()const; + Input_command(); + Input_command(Real); + operator Command(); +}; + +Input_command* get_meterchange_command( int,int); +Input_command* get_key_interpret_command(svec); +Input_command* get_clef_interpret_command(String w); +Input_command *get_reset_command(); +Input_command *get_partial_command(Real u); +Input_command* get_skip_command( int,Real); + +void +interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat, + Real& whole_per_measure); + +Input_command *get_bar_command(Real ); +#endif // INPUTCOMMAND_HH + diff --git a/hdr/inputstaff.hh b/hdr/inputstaff.hh new file mode 100644 index 0000000000..abfcc52f61 --- /dev/null +++ b/hdr/inputstaff.hh @@ -0,0 +1,33 @@ +/* + inputstaff.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef INPUTSTAFF_HH +#define INPUTSTAFF_HH + +#include "string.hh" +#include "plist.hh" +#include "vray.hh" +#include "proto.hh" + +struct Input_staff { + String type; + IPointerList commands_; + IPointerList music_; + + /****************/ + + void add(Horizontal_music*m); + Input_staff(Input_staff&); + Input_staff(String); + void add(svec &s); + Staff* parse(PointerList); + void print() const; + +}; + + +#endif // INPUTSTAFF_HH + diff --git a/src/parser.y b/src/parser.y index abacc7add9..23c779ed7d 100644 --- a/src/parser.y +++ b/src/parser.y @@ -3,16 +3,17 @@ #include "lexer.hh" #include "paper.hh" -#include "staff.hh" -#include "score.hh" +#include "inputstaff.hh" +#include "inputscore.hh" +#include "inputmusic.hh" #include "main.hh" #include "keyword.hh" -#include "getcommand.hh" +#include "inputcommand.hh" #include "debug.hh" #include "parseconstruct.hh" #include "dimen.hh" #include "identifier.hh" -#include "inputmusic.hh" + #ifndef NDEBUG #define YYDEBUG 1 @@ -24,13 +25,11 @@ svec pre_reqs, post_reqs; %union { Real real; - Command *command; + Input_command *command; Identifier *id; Voice *voice; Voice_element *el; - Staff *staff; String *string; - Score *score; const char *consstr; Paperdef *paper; Request* request; @@ -42,15 +41,17 @@ svec pre_reqs, post_reqs; char c; svec * strvec; - svec *commandvec; + svec *commandvec; Voice_list *voicelist; + Input_staff *staff; + Input_score *score; } -%token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME OUTPUT +%token VOICE STAFF SCORE TITLE BAR NOTENAME OUTPUT %token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS -%token MELODICSTAFF GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND +%token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND %token KEY CLEF VIOLIN BASS MULTI TABLE CHORD VOICES -%token PARTIAL +%token PARTIAL RHYTHMIC MELODIC MUSIC %token IDENTIFIER %token NEWIDENTIFIER @@ -69,8 +70,7 @@ svec pre_reqs, post_reqs; %type voice_elt full_element %type score_command staff_command skipcommand %type score_block score_body -%type staff_block rhythmstaff_block rhythmstaff_body -%type melodicstaff_block melodicstaff_body staffdecl +%type staff_block staff_init staff_body %type int %type score_commands_block score_commands_body %type staff_commands_block staff_commands_body @@ -81,7 +81,7 @@ svec pre_reqs, post_reqs; %type music_chord music_chord_body %type horizontal_music %type music_voice_body music_voice -%type voices + %% @@ -89,7 +89,7 @@ mudela: /* empty */ | mudela score_block { add_score($2); } - | mudela add_declaration { } + | mudela add_declaration { } ; /* DECLARATIONS @@ -104,8 +104,12 @@ declaration: $$ = new Staff_id(*$1, $3); delete $1; // this sux } - | NEWIDENTIFIER '=' voices { - $$ = new Voices_id(*$1, $3); + | NEWIDENTIFIER '=' music_voice { + $$ = new M_voice_id(*$1, $3); + delete $1; + } + | NEWIDENTIFIER '=' music_chord { + $$ = new M_chord_id(*$1, $3); delete $1; } ; @@ -117,7 +121,7 @@ declaration: score_block: SCORE '{' score_body '}' { $$ = $3; } ; -score_body: { $$ = new Score; } +score_body: { $$ = new Input_score; } | score_body staff_block { $$->add($2); } | score_body score_commands_block { $$->add(*$2); @@ -132,7 +136,7 @@ score_commands_block: COMMANDS '{' score_commands_body '}' { $$ =$3;} ; -score_commands_body: { $$ = new svec; } +score_commands_body: { $$ = new svec; } | score_commands_body score_command { $$->add($2); } @@ -143,7 +147,7 @@ staff_commands_block: COMMANDS '{' staff_commands_body '}' { ; staff_commands_body: - /* empty */ { $$ = new svec; } + /* empty */ { $$ = new svec; } | staff_commands_body staff_command { $$->add($2); } @@ -151,9 +155,9 @@ staff_commands_body: staff_command: skipcommand - | KEY '$' pitch_list '$' {/*UGH*/ - $$ = get_key_interpret_command(*$3); - delete $3; + | KEY pitch_list {/*UGH*/ + $$ = get_key_interpret_command(*$2); + delete $2; } | CLEF clef_id { $$ = get_clef_interpret_command(*$2); @@ -197,56 +201,35 @@ paper_body: STAFFs */ staff_block: - staffdecl - | rhythmstaff_block - | melodicstaff_block + STAFF '{' staff_body '}' { $$ = $3; } ; -staffdecl: STAFF '{' IDENTIFIER '}' { $$ = $3->staff()->clone(); } - ; -rhythmstaff_block: - RHYTHMSTAFF '{' rhythmstaff_body '}' { $$ = $3; } - ; -rhythmstaff_body: - /* empty */ { $$ = get_new_rhythmstaff(); } - | rhythmstaff_body voices { $$->add(*$2); - delete $2; +staff_init: + IDENTIFIER { $$ = new Input_staff(*$1->staff()); } + | RHYTHMIC { + $$ = new Input_staff("rhythmic"); } - | rhythmstaff_body staff_commands_block { - $$->add(*$2); - delete $2; + | MELODIC { + $$ = new Input_staff( "melodic"); } ; -melodicstaff_block: - MELODICSTAFF '{' melodicstaff_body '}' { $$ = $3; } - ; - -melodicstaff_body: - /* empty */ { $$ = get_new_melodicstaff(); } - | melodicstaff_body voices { - $$->add(*$2); - delete $2; - } - | melodicstaff_body staff_commands_block { - $$->input_commands_.add(get_reset_command()); +staff_body: + staff_init + | staff_body horizontal_music { + $$->add($2); + } + | staff_body staff_commands_block { $$->add(*$2); delete $2; - } - ; - -voices: - '$' music_voice_body '$' { - $$ = new Voice_list($2->convert()); - } - | VOICES '{' IDENTIFIER '}' { - $$ = new Voice_list(*$3->voices()); } ; - +/* + MUSIC +*/ horizontal_music: music_voice { $$ = $1; } ; @@ -255,12 +238,15 @@ vertical_music: music_chord { $$ = $1; } ; -music_voice: VOICE '{' music_voice_body '}' { $$ = $3; } +music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; } ; music_voice_body: { $$ = new Music_voice; } + | music_voice_body IDENTIFIER { + $$->concatenate($2->mvoice()); + } | music_voice_body full_element { $$->add($2); } @@ -278,6 +264,9 @@ music_chord: CHORD '{' music_chord_body '}' { $$ = $3; } music_chord_body: { $$ = new Music_general_chord; } + | music_voice_body IDENTIFIER { + $$->concatenate($2->mchord()); + } | music_chord_body horizontal_music { $$ -> add($2); }