1 %{ // -*-Fundamental-*-
9 #include "inputstaff.hh"
10 #include "inputscore.hh"
11 #include "inputmusic.hh"
14 #include "inputcommand.hh"
16 #include "parseconstruct.hh"
18 #include "identifier.hh"
24 svec<Request*> pre_reqs, post_reqs;
26 Paperdef*default_paper();
33 Input_command *command;
41 Music_general_chord *chord;
47 svec<String> * strvec;
48 svec<Input_command*> *commandvec;
53 Symtables * symtables;
59 Notename_tab *notename_tab;
62 %token VOICE STAFF SCORE TITLE BAR NOTENAME OUTPUT
63 %token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS
64 %token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND
65 %token KEY CLEF VIOLIN BASS MULTI TABLE CHORD VOICES
66 %token PARTIAL RHYTHMIC MELODIC MUSIC GROUPING
67 %token END SYMBOLTABLES TEXID TABLE NOTENAMES
69 %token <id> IDENTIFIER
70 %token <string> NEWIDENTIFIER
71 %token <string> PITCHMOD DURATION RESTNAME
74 %token <string> STRING
75 %token <c> OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS
78 %type <intvec> pitch_list
80 %type <id> declaration
81 %type <string> declarable_identifier
82 %type <paper> paper_block paper_body
85 %type <real> duration_length
86 %type <el> voice_elt full_element
87 %type <command> score_command staff_command skipcommand
88 %type <score> score_block score_body
89 %type <staff> staff_block staff_init staff_body
91 %type <intvec> int_list
92 %type <commandvec> score_commands_block score_commands_body
93 %type <commandvec> staff_commands_block staff_commands_body
94 %type <request> post_request pre_request
95 %type <string> clef_id pitchmod
97 %type <chord> music_chord music_chord_body
99 %type <mvoice> music_voice_body music_voice
101 %type <interval> dinterval
103 %type <symtable> symtable symtable_body
104 %type <lookup> symtables symtables_body
105 %type <symbol> symboldef
106 %type <notename_tab> notename_tab notename_tab_body
111 | mudela score_block {
114 | mudela add_declaration { }
115 | mudela mudela_command {}
119 notename_tab { lexer->set($1); }
125 add_declaration: declaration {
126 lexer->add_identifier($1);
130 declarable_identifier:
131 NEWIDENTIFIER { $$ = $1; }
132 | IDENTIFIER { $$ = new String($1->name); }
136 declarable_identifier '=' staff_block {
137 $$ = new Staff_id(*$1, $3);
138 delete $1; // this sux
140 | declarable_identifier '=' music_voice {
141 $$ = new M_voice_id(*$1, $3);
144 | declarable_identifier '=' music_chord {
145 $$ = new M_chord_id(*$1, $3);
148 | declarable_identifier '=' symtables {
149 $$ = new Lookup_id(*$1, $3);
152 | declarable_identifier '=' notename_tab {
153 $$ = new Notetab_id(*$1, $3);
159 NOTENAMES '{' notename_tab_body '}' { $$ = $3; }
163 $$ = new Notename_tab;
166 $$ = $1->notename_tab(true);
168 | notename_tab_body STRING int int {
169 $$->set($3, $4, *$2);
177 score_block: SCORE '{' score_body '}' { $$ = $3;
179 $$->paper_ = default_paper();
183 score_body: { $$ = new Input_score; }
184 | score_body staff_block { $$->add($2); }
185 | score_body score_commands_block {
189 | score_body paper_block { $$->set($2); }
194 score_commands_block:
195 COMMANDS '{' score_commands_body '}' { $$ =$3;}
198 score_commands_body: { $$ = new svec<Input_command*>; }
199 | score_commands_body score_command {
204 staff_commands_block: COMMANDS '{' staff_commands_body '}' {
209 /* empty */ { $$ = new svec<Input_command*>; }
210 | staff_commands_body staff_command {
217 | KEY pitch_list {/*UGH*/
218 $$ = get_key_interpret_command(*$2);
222 $$ = get_clef_interpret_command(*$2);
229 $$ = wholes($1[0], $1[1]);
234 SKIP int ':' duration_length {
235 $$ = get_skip_command($2, $4);
241 $$ = get_meterchange_command($2, $3);
243 | PARTIAL duration_length {
244 $$ = get_partial_command($2);
246 | GROUPING int_list {
247 $$ = get_grouping_command(*$2);
258 PAPER '{' paper_body '}' { $$ = $3; }
263 $$ = default_paper();
265 | paper_body WIDTH dim { $$->linewidth = $3;}
266 | paper_body OUTPUT STRING { $$->outfile = *$3;
269 | paper_body symtables { $$->set($2); }
270 | paper_body UNITSPACE dim { $$->whole_width = $3; }
271 | paper_body GEOMETRIC REAL { $$->geometric_ = $3; }
278 STAFF '{' staff_body '}' { $$ = $3; }
284 IDENTIFIER { $$ = $1->staff(true); }
286 $$ = new Input_staff("rhythmic");
289 $$ = new Input_staff( "melodic");
298 | staff_body staff_commands_block {
308 music_voice { $$ = $1; }
309 | music_chord { $$ = $1; }
312 music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; }
316 $$ = new Music_voice;
318 | music_voice_body IDENTIFIER {
319 $$->concatenate($2->mvoice());
321 | music_voice_body full_element {
324 | music_voice_body voice_command {
326 | music_voice_body music {
332 music_chord: '{' music_chord_body '}' { $$ = $2; }
336 $$ = new Music_general_chord;
338 | music_chord_body IDENTIFIER {
339 $$->concatenate($2->mchord());
341 | music_chord_body music {
344 | music_chord_body full_element {
354 full_element: pre_requests voice_elt post_requests {
355 add_requests($2, pre_reqs);
356 add_requests($2, post_reqs);
363 assert(post_reqs.empty());
365 | post_requests post_request {
371 CLOSE_REQUEST_PARENS { $$ = get_request($1); }
375 | pre_requests pre_request {
381 OPEN_REQUEST_PARENS { $$ = get_request($1); }
387 DURATIONCOMMAND '{' duration '}' {
388 set_default_duration($3);
390 | OCTAVECOMMAND '{' pitchmod '}' {
391 set_default_octave(*$3);
397 get_default_duration($$);
400 get_default_duration($$);
409 pitchmod: { $$ = new String; }
414 pitchmod NOTENAME duration {
415 $$ = get_note_element(*$1, $2, $3);
418 | RESTNAME duration {
419 $$ = get_rest_element(*$1, $2);
431 | pitch_list NOTENAME {
440 if (ABS($1-Real(int($$))) > 1e-8)
441 error("expecting integer number");
456 REAL unit { $$ = convert_dimen($1,$2); }
460 unit: CM { $$ = "cm"; }
467 VIOLIN { $$ = new String("violin"); }
468 | BASS { $$ = new String("bass"); }
474 SYMBOLTABLES '{' symtables_body '}' { $$ = $3; }
482 $$ = new Lookup(*$1->lookup(true));
484 | symtables_body TEXID STRING {
485 $$->texsetting = *$3;
488 | symtables_body STRING '=' symtable {
495 TABLE '{' symtable_body '}' { $$ = $3; }
499 { $$ = new Symtable; }
500 | symtable_body STRING symboldef {
509 $$ = new Symbol(*$1, *$2);
515 $$ = new Symbol(*$1, b);
521 dinterval dinterval {
522 $$ = new Box(*$1, *$2);
529 $$ = new Interval($1, $2);
538 *mlog << "Parsing ... ";
541 yydebug = !monitor.silence("Parser") && check_debug;
545 lexer->new_input("symbol.ini");
555 return new Paperdef(lexer->lookup_identifier("default_table")->lookup(true));