#include "lookup.hh"
#include "misc.hh"
#include "lexer.hh"
-#include "paper.hh"
+#include "paperdef.hh"
+#include "mididef.hh"
#include "inputscore.hh"
#include "main.hh"
#include "keyword.hh"
-#include "inputcommand.hh"
#include "debug.hh"
#include "parseconstruct.hh"
#include "dimen.hh"
#include "identifier.hh"
+#include "commandrequest.hh"
+#include "musicalrequest.hh"
#ifndef NDEBUG
#define YYDEBUG 1
%union {
Request * request;
Real real;
- Input_command *command;
Identifier *id;
- Voice *voice;
+ Voice *voice;
Voice_element *el;
String *string;
const char *consstr;
Paperdef *paper;
+ Midi_def* midi;
Input_music *music;
Music_general_chord *chord;
Music_voice *mvoice;
Moment *moment;
Array<String> * strvec;
- Array<Input_command*> *commandvec;
Array<int> *intvec;
-
+ Array<Melodic_req*> *melreqvec;
Input_staff *staff;
Input_score *score;
Symtables * symtables;
}
%token VOICE STAFF SCORE TITLE BAR OUTPUT MULTIVOICE
-%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND
+%token CM_T IN_T PT_T MM_T PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND
%token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND
%token KEY CLEF TABLE VOICES STEM
%token PARTIAL MUSIC GROUPING CADENZA
%token END SYMBOLTABLES TEXID TABLE NOTENAMES SCRIPT TEXTSTYLE PLET
-%token MARK GOTO
+%token GOTO
+%token MIDI TEMPO
%token <id> IDENTIFIER
%token <string> PITCHMOD DURATION RESTNAME
%token <string> STRING
%token <i> DOTS INT
-%type <consstr> unit
-%type <intvec> pitch_list
-%type <c> open_request_parens close_request_parens
+%type <real> unit
+%type <melreqvec> pitch_list
+%type <c> open_request_parens close_request_parens close_plet_parens
%type <id> declaration
%type <string> declarable_identifier
%type <paper> paper_block paper_body
+%type <midi> midi_block midi_body
%type <real> dim real
%type <ii> default_duration explicit_duration notemode_duration mudela_duration
%type <ii> notename
%type <moment> duration_length
-%type <el> voice_elt full_element lyrics_elt
-%type <command> score_command staff_command position_command
+%type <el> voice_elt full_element lyrics_elt command_elt
+
%type <score> score_block score_body
%type <staff> staff_block staff_init staff_body
%type <i> int
-%type <intvec> int_list intastint_list
-%type <commandvec> score_commands_block score_commands_body
-%type <commandvec> staff_commands_block staff_commands_body
-%type <request> post_request pre_request
+%type <intvec> intastint_list
+%type <request> post_request pre_request command_req
%type <string> pitchmod
%type <music> music
%type <chord> music_chord music_chord_body
declaration:
declarable_identifier '=' staff_block {
$$ = new Staff_id(*$1, $3);
- delete $1; // this sux
+ delete $1;
}
| declarable_identifier '=' music_voice {
$$ = new M_voice_id(*$1, $3);
delete $1;
}
| declarable_identifier error '}' {
-// warning( "parse error", lexer->here_ch_c_l() );
+
}
;
/*
SCORE
*/
-score_block: SCORE
- { define_spots.push(lexer->here_ch_c_l()); }
- '{' score_body '}' {
+score_block:
+ SCORE { define_spots.push(lexer->here_ch_c_l()); }
+ /*cont*/ '{' score_body '}' {
$$ = $4;
$$->defined_ch_c_l_ = define_spots.pop();
- if (!$$->paper_)
- $$->paper_ = default_paper();
+ if (!$$->paper_p_ && ! $$->midi_p_)
+ $$->paper_p_ = default_paper();
/* handle error levels. */
$$->errorlevel_i_ = lexer->errorlevel_i_;
$$ = new Input_score;
}
| score_body staff_block { $$->add($2); }
- | score_body score_commands_block {
- $$->add(*$2);
- delete $2;
+ | score_body COMMANDS '{' music_voice_body '}' {
+ $$->set($4);
}
| score_body paper_block { $$->set($2); }
- ;
-/*
- COMMANDS
-*/
-score_commands_block:
- COMMANDS '{' score_commands_body '}' { $$ =$3;}
- | COMMANDS '{' error '}' {
-// warning( "parse error", lexer->here_ch_c_l() );
- }
- ;
+ | score_body midi_block { $$->set($2); }
+ | score_body error {
-score_commands_body: { $$ = new Array<Input_command*>; }
- | score_commands_body score_command {
- $$->push($2);
- }
- | score_commands_body position_command {
- $$->push($2);
}
;
-staff_commands_block: COMMANDS '{' staff_commands_body '}' {
- $$ = $3; }
- ;
-
-staff_commands_body:
- /* empty */ { $$ = new Array<Input_command*>; }
- | staff_commands_body staff_command {
- $$->push($2);
- }
- | staff_commands_body position_command {
- $$->push($2);
- }
- ;
-
-staff_command:
- KEY pitch_list {/*UGH*/
- $$ = get_key_interpret_command(*$2);
- delete $2;
- }
- | CLEF STRING {
- $$ = get_clef_interpret_command(*$2);
- delete $2;
- }
- ;
-
-position_command:
- SKIP int ':' duration_length {
- $$ = get_skip_command($2, *$4);
- delete $4;
- }
- | GOTO STRING {
- $$ = get_goto_command(*$2);
- delete $2;
- }
- ;
-
-
intastint_list:
/* */ { $$ =new Array<int>; }
| intastint_list int '*' int {
}
;
-score_command:
- BAR STRING {
- $$ = get_bar_command(*$2);
- delete $2;
- }
- | METER int '*' int {
- $$ = get_meterchange_command($2, $4);
- }
- | PARTIAL duration_length {
- $$ = get_partial_command(*$2);
- delete $2;
- }
- | GROUPING intastint_list {
- $$ = get_grouping_command(*$2);
- delete $2;
- }
- | CADENZA int {
- $$ = get_cadenza_toggle($2);
- }
- ;
-
-
/*
PAPER
| paper_body UNITSPACE dim { $$->whole_width = $3; }
| paper_body GEOMETRIC REAL { $$->geometric_ = $3; }
| paper_body error {
-// warning( "parse error", lexer->here_ch_c_l() );
+
+ }
+ ;
+
+/*
+ MIDI
+*/
+midi_block:
+ MIDI
+
+ '{' midi_body '}' { $$ = $3; }
+ ;
+
+midi_body: {
+ $$ = new Midi_def;
+ }
+ | midi_body OUTPUT STRING {
+ $$->outfile_str_ = *$3;
+ delete $3;
+ }
+ | midi_body TEMPO mudela_duration ':' int {
+ $$->set_tempo( wholes( $3[0], $3[1] ), $5 );
+ }
+ | midi_body error {
+
}
;
staff_body:
staff_init
+ | staff_body COMMANDS '{' music_voice_body '}' {
+ $$->set_score_wide($4);
+ }
| staff_body music {
$2->set_default_group( "staff_music" + String($$->music_.size()));
$$->add($2);
}
- | staff_body staff_commands_block {
- $$->add(*$2);
- delete $2;
- }
| staff_body error {
-// warning( "parse error", lexer->here_ch_c_l() );
}
;
$$->add($2);
}
| music_voice_body error {
-// warning( "parse error", lexer->here_ch_c_l() );
}
;
$$->concatenate($2->mchord(true));
}
| music_chord_body music {
- $$ -> add($2);
+ $$->add($2);
}
| music_chord_body full_element {
$$ ->add_elt($2);
}
| music_chord_body error {
-// warning( "parse error", lexer->here_ch_c_l() );
}
;
-
/*
VOICE ELEMENTS
*/
add_requests($2, post_reqs);
$$ = $2;
}
- | MARK STRING {
- $$ = get_mark_element(*$2);
+ | pre_requests lyrics_elt post_requests {
+ add_requests($2, pre_reqs);
+ add_requests($2, post_reqs);
+ $$ = $2;
+ }
+ | command_elt
+ ;
+
+command_elt:
+/* empty */ {
+ $$ = new Voice_element;
+ $$-> defined_ch_c_l_ = lexer->here_ch_c_l();
+ }
+/* cont: */
+ command_req {
+ $2-> defined_ch_c_l_ = $$->defined_ch_c_l_;
+ $$->add($2);
+
+ }
+ ;
+
+command_req:
+ '|' {
+ $$ = new Barcheck_req;
+ }
+ | BAR STRING {
+ $$ = new Bar_req(*$2);
delete $2;
}
- | COMMAND '{' staff_command '}' { $$=get_command_element($3); }
- | COMMAND '{' score_command '}' { $$=get_command_element($3); }
- | '|' {
- req_defined_ch_c_l = lexer->here_ch_c_l();
- $$ = get_barcheck_element();
+ | METER '{' int '*' int '}' {
+ Meter_change_req *m = new Meter_change_req;
+ m->set($3,$5);
+ $$ = m;
+ }
+ | SKIP '{' duration_length '}' {
+ Skip_req * skip_p = new Skip_req;
+ skip_p->duration_ = *$3;
+ delete $3;
+ $$ = skip_p;
+ }
+ | CADENZA '{' int '}' {
+ $$ = new Cadenza_req($3);
+ }
+ | PARTIAL '{' duration_length '}' {
+ $$ = new Partial_measure_req(*$3);
+ delete $3;
}
| STEM '{' int '}' {
- req_defined_ch_c_l = lexer->here_ch_c_l();
- $$ = get_stemdir_element($3);
+ $$ = get_stemdir_req($3);
+ }
+ | CLEF STRING {
+ $$ = new Clef_change_req(*$2);
+ delete $2;
+ }
+ | KEY '{' pitch_list '}' {
+ Key_change_req *key_p= new Key_change_req;
+ key_p->melodic_p_arr_ = *$3;
+ $$ = key_p;
+ delete $3;
+ }
+ | GROUPING '{' intastint_list '}' {
+ $$ = get_grouping_req(*$3); delete $3;
}
- | lyrics_elt
-/*
-+ | pre_requests voice_elt post_requests error '|' {
-+ warning( "parse error", lexer->here_ch_c_l() );
-+ }
-+ */
;
-
+
post_requests:
{
assert(post_reqs.empty());
}
| post_requests post_request {
+ $2->defined_ch_c_l_ = lexer->here_ch_c_l();
post_reqs.push($2);
}
+ | post_requests close_plet_parens INT '/' INT {
+ post_reqs.push( get_request($2) );
+ req_defined_ch_c_l = lexer->here_ch_c_l();
+ post_reqs.push( get_plet_request( $2, $3, $5 ) );
+ }
;
post_request:
close_request_parens {
- req_defined_ch_c_l = lexer->here_ch_c_l();
$$ = get_request($1);
}
| script_req
| textscript_req
;
+close_plet_parens:
+ ']' {
+ req_defined_ch_c_l = lexer->here_ch_c_l();
+ $$ = ']';
+ }
+ ;
+
close_request_parens:
'(' {
- req_defined_ch_c_l = lexer->here_ch_c_l();
$$='(';
}
| ']' {
- req_defined_ch_c_l = lexer->here_ch_c_l();
$$ = ']';
}
;
open_request_parens:
')' {
- req_defined_ch_c_l = lexer->here_ch_c_l();
$$=')';
}
| '[' {
- req_defined_ch_c_l = lexer->here_ch_c_l();
$$='[';
}
;
;
script_req:
- script_dir mudela_script { $$ = get_script_req($1, $2); }
+ script_dir mudela_script {
+ $$ = get_script_req($1, $2);
+ }
;
mudela_script:
pre_requests:
| pre_requests pre_request {
pre_reqs.push($2);
+ $2->defined_ch_c_l_ = lexer->here_ch_c_l();
}
;
set_default_octave(*$3);
delete $3;
}
- | TEXTSTYLE STRING {
+ | TEXTSTYLE STRING {
set_text_style(*$2);
delete $2;
}
/*
UTILITIES
-*/
+ */
pitch_list: {
- $$ = new Array<int>;
+ $$ = new Array<Melodic_req*>;
}
| pitch_list NOTENAME {
- $$->push($2[0]);
- $$->push($2[1]);
+ Melodic_req *m_p = new Melodic_req;
+ m_p->notename_i_ = $2[0];
+ m_p->accidental_i_ = $2[1];
+ $$->push(m_p);
}
;
;
-int_list: {
- $$ = new Array<int>;
- }
- | int_list int {
- $$->push($2);
- }
- ;
-
dim:
- real unit { $$ = convert_dimen($1,$2); }
+ real unit { $$ = $1*$2; }
;
-unit: CM { $$ = "cm"; }
- |IN { $$ = "in"; }
- |MM { $$ = "mm"; }
- |PT { $$ = "pt"; }
+unit: CM_T { $$ = 1 CM; }
+ |IN_T { $$ = 1 INCH; }
+ |MM_T { $$ = 1 MM; }
+ |PT_T { $$ = 1 PT; }
;
/*
void
yyerror(const char *s)
{
-// if ( YYRECOVERING() )
-// return;
lexer->LexerError(s);
if ( fatal_error_i )
lexer = new My_flex_lexer;
#ifdef YYDEBUG
- yydebug = !monitor.silence("InitParser") && check_debug;
- lexer->set_debug( !monitor.silence("InitLexer") && check_debug);
+ yydebug = !monitor->silence("InitParser") && check_debug;
+ lexer->set_debug( !monitor->silence("InitLexer") && check_debug);
#endif
lexer->new_input(init);
yyparse();
#ifdef YYDEBUG
- yydebug = !monitor.silence("Parser") && check_debug;
- lexer->set_debug( !monitor.silence("Lexer") && check_debug);
+ yydebug = !monitor->silence("Parser") && check_debug;
+ lexer->set_debug( !monitor->silence("Lexer") && check_debug);
#endif
lexer->new_input(s);
delete lexer;
lexer = 0;
- assert(define_spots.empty());
+ if(!define_spots.empty())
+ warning("Braces don't match.",0);
}
Paperdef*