%{ // -*-Fundamental-*-
#include <iostream.h>
-#include "lookup.hh"
+#include "lookup.hh"
+#include "misc.hh"
#include "lexer.hh"
#include "paper.hh"
-#include "inputstaff.hh"
#include "inputscore.hh"
-#include "inputmusic.hh"
#include "main.hh"
#include "keyword.hh"
#include "inputcommand.hh"
#include "dimen.hh"
#include "identifier.hh"
-
#ifndef NDEBUG
#define YYDEBUG 1
#endif
-svec<Request*> pre_reqs, post_reqs;
+Array<Request*> pre_reqs, post_reqs;
+sstack<String> define_spots;
Paperdef*default_paper();
%}
String *string;
const char *consstr;
Paperdef *paper;
- Horizontal_music *horizontal;
- Vertical_music *vertical;
+ Input_music *music;
Music_general_chord *chord;
Music_voice *mvoice;
int i;
char c;
+ int ii[10];
+ Moment *moment;
- svec<String> * strvec;
- svec<Input_command*> *commandvec;
- svec<int> *intvec;
+ Array<String> * strvec;
+ Array<Input_command*> *commandvec;
+ Array<int> *intvec;
Input_staff *staff;
Input_score *score;
Lookup*lookup;
Interval *interval;
Box *box;
+ Notename_tab *notename_tab;
+ Script_def * script;
+ Text_def * textdef;
}
%token VOICE STAFF SCORE TITLE BAR NOTENAME OUTPUT
-%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS
+%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND
%token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND
-%token KEY CLEF VIOLIN BASS MULTI TABLE CHORD VOICES
-%token PARTIAL RHYTHMIC MELODIC MUSIC GROUPING
-
-%token END SYMBOLTABLES TEXID TABLE
+o%token KEY CLEF MULTI TABLE CHORD VOICES
+%token PARTIAL RHYTHMIC MELODIC MUSIC LYRIC GROUPING CADENZA
+%token END SYMBOLTABLES TEXID TABLE NOTENAMES SCRIPT TEXTSTYLE PLET
+%token MARK GOTO
%token <id> IDENTIFIER
%token <string> NEWIDENTIFIER
-%token <string> PITCH DURATION RESTNAME
+%token <string> PITCHMOD DURATION RESTNAME
+%token <ii> NOTENAME
%token <real> REAL
%token <string> STRING
-%token <i> OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS
+%token <i> DOTS INT
%type <consstr> unit
-
-%type <id> declaration
+%type <intvec> pitch_list
+%type <c> open_request_parens close_request_parens
+%type <id> declaration
+%type <string> declarable_identifier
%type <paper> paper_block paper_body
%type <real> dim
-
-%type <el> voice_elt full_element
-%type <command> score_command staff_command skipcommand
+%type <ii> duration
+%type <moment> duration_length
+%type <el> voice_elt full_element lyrics_elt
+%type <command> score_command staff_command position_command
%type <score> score_block score_body
%type <staff> staff_block staff_init staff_body
%type <i> int
%type <intvec> int_list
%type <commandvec> score_commands_block score_commands_body
%type <commandvec> staff_commands_block staff_commands_body
-%type <request> post_request pre_request
-%type <strvec> pitch_list
-%type <string> clef_id
-%type <vertical> vertical_music
+%type <request> post_request pre_request
+%type <string> pitchmod
+%type <music> music
%type <chord> music_chord music_chord_body
-%type <horizontal> horizontal_music
-%type <mvoice> music_voice_body music_voice
+
+%type <mvoice> music_voice_body music_voice
%type <interval> dinterval
%type <box> box
%type <symtable> symtable symtable_body
%type <lookup> symtables symtables_body
%type <symbol> symboldef
+%type <notename_tab> notename_tab notename_tab_body
+%type <i> script_dir
+%type <script> script_definition script_body mudela_script
+%type <request> script_req textscript_req
+%type <textdef> mudela_text
%%
add_score($2);
}
| mudela add_declaration { }
+ | mudela mudela_command {}
+ ;
+
+mudela_command:
+ notename_tab { lexer->set($1); }
;
/*
DECLARATIONS
*/
add_declaration: declaration {
- add_identifier($1);
+ lexer->add_identifier($1);
}
;
+declarable_identifier:
+ NEWIDENTIFIER { $$ = $1; }
+ | IDENTIFIER { $$ = new String($1->name); }
+ ;
+
declaration:
- NEWIDENTIFIER '=' staff_block {
+ declarable_identifier '=' staff_block {
$$ = new Staff_id(*$1, $3);
delete $1; // this sux
}
- | NEWIDENTIFIER '=' music_voice {
+ | declarable_identifier '=' music_voice {
$$ = new M_voice_id(*$1, $3);
delete $1;
}
- | NEWIDENTIFIER '=' music_chord {
+ | declarable_identifier '=' script_definition {
+ $$ = new Script_id(*$1, $3);
+ delete $1;
+ }
+ | declarable_identifier '=' music_chord {
$$ = new M_chord_id(*$1, $3);
delete $1;
}
- | NEWIDENTIFIER '=' symtables {
+ | declarable_identifier '=' symtables {
$$ = new Lookup_id(*$1, $3);
delete $1;
}
+ | declarable_identifier '=' notename_tab {
+ $$ = new Notetab_id(*$1, $3);
+ delete $1;
+ }
+ ;
+
+notename_tab:
+ NOTENAMES '{' notename_tab_body '}' { $$ = $3; }
;
+notename_tab_body: {
+ $$ = new Notename_tab;
+ }
+ | IDENTIFIER {
+ $$ = $1->notename_tab(true);
+ }
+ | notename_tab_body STRING int int {
+ $$->set($3, $4, *$2);
+ delete $2;
+ }
+ ;
/*
SCORE
*/
-score_block: SCORE '{' score_body '}' { $$ = $3;
+score_block: SCORE
+ { define_spots.push(lexer->spot()); }
+ '{' score_body '}' {
+ $$ = $4;
+ $$->define_spot_str_ = define_spots.pop();
if (!$$->paper_)
$$->paper_ = default_paper();
}
COMMANDS '{' score_commands_body '}' { $$ =$3;}
;
-score_commands_body: { $$ = new svec<Input_command*>; }
+score_commands_body: { $$ = new Array<Input_command*>; }
| score_commands_body score_command {
$$->add($2);
}
+ | score_commands_body position_command {
+ $$->add($2);
+ }
;
-staff_commands_block: COMMANDS '{' staff_commands_body '}' {
+staff_commands_block: COMMANDS '{' staff_commands_body '}' {
$$ = $3; }
;
staff_commands_body:
- /* empty */ { $$ = new svec<Input_command*>; }
+ /* empty */ { $$ = new Array<Input_command*>; }
| staff_commands_body staff_command {
$$->add($2);
}
+ | staff_commands_body position_command {
+ $$->add($2);
+ }
;
staff_command:
- skipcommand
- | KEY pitch_list {/*UGH*/
+ KEY pitch_list {/*UGH*/
$$ = get_key_interpret_command(*$2);
delete $2;
}
- | CLEF clef_id {
+ | CLEF STRING {
$$ = get_clef_interpret_command(*$2);
delete $2;
}
;
-skipcommand:
- SKIP int ':' REAL {
- $$ = get_skip_command($2, $4);
+duration_length:
+ duration {
+ $$ = new Moment(wholes($1[0], $1[1]));
+ }
+ |int '*' duration {
+ $$ = new Moment($1 * wholes($3[0], $3[1]));
}
+ ;
+
+position_command:
+ SKIP int ':' duration_length {
+ $$ = get_skip_command($2, *$4);
+ delete $4;
+ }
+ | GOTO STRING {
+ $$ = get_goto_command(*$2);
+ delete $2;
+ }
+ ;
score_command:
- skipcommand
- | METER int int {
- $$ = get_meterchange_command($2, $3);
+ BAR STRING {
+ $$ = get_bar_command(*$2);
+ delete $2;
+ }
+ | METER int '*' int {
+ $$ = get_meterchange_command($2, $4);
}
- | PARTIAL REAL {
- $$ = get_partial_command($2);
+ | PARTIAL duration_length {
+ $$ = get_partial_command(*$2);
+ delete $2;
}
| GROUPING int_list {
$$ = get_grouping_command(*$2);
delete $2;
}
+ | CADENZA int {
+ $$ = get_cadenza_toggle($2);
+ }
;
PAPER
*/
paper_block:
- PAPER '{' paper_body '}' { $$ = $3; }
+ PAPER
+
+ '{' paper_body '}' { $$ = $3; }
;
paper_body:
STAFFs
*/
staff_block:
- STAFF '{' staff_body '}' { $$ = $3; }
+ STAFF { define_spots.push(lexer->spot()); }
+/*cont*/ '{' staff_body '}' {
+ $$ = $4;
+ $$->define_spot_str_ = define_spots.pop();
+ }
;
| MELODIC {
$$ = new Input_staff( "melodic");
}
+ | LYRIC {
+ $$ = new Input_staff( "lyric");
+ }
;
staff_body:
staff_init
- | staff_body horizontal_music {
+ | staff_body music {
$$->add($2);
}
| staff_body staff_commands_block {
/*
MUSIC
*/
-horizontal_music:
+music:
music_voice { $$ = $1; }
+ | music_chord { $$ = $1; }
;
-vertical_music:
- music_chord { $$ = $1; }
- ;
-
-music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; }
+music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; }
;
music_voice_body: {
$$->concatenate($2->mvoice());
}
| music_voice_body full_element {
- $$->add($2);
+ $$->add_elt($2);
}
| music_voice_body voice_command {
}
- | music_voice_body vertical_music {
+ | music_voice_body music {
$$->add($2);
}
;
-
-music_chord: CHORD '{' music_chord_body '}' { $$ = $3; }
+music_chord: '{' music_chord_body '}' { $$ = $2; }
;
music_chord_body: {
$$ = new Music_general_chord;
}
- | music_voice_body IDENTIFIER {
+ | music_chord_body IDENTIFIER {
$$->concatenate($2->mchord());
}
- | music_chord_body horizontal_music {
+ | music_chord_body music {
$$ -> add($2);
}
+ | music_chord_body full_element {
+ $$ ->add_elt($2);
+ }
;
add_requests($2, post_reqs);
$$ = $2;
}
+ | MARK STRING {
+ $$ = get_mark_element(*$2);
+ delete $2;
+ }
+ | COMMAND '{' staff_command '}' { $$=get_command_element($3); }
+ | COMMAND '{' score_command '}' { $$=get_command_element($3); }
+ | '|' { $$ = get_barcheck_element(); }
+ | lyrics_elt
;
-
+
post_requests:
{
assert(post_reqs.empty());
;
post_request:
- CLOSE_REQUEST_PARENS { $$ = get_request($1); }
+ close_request_parens { $$ = get_request($1); }
+ | script_req
+ | textscript_req
+ ;
+close_request_parens:
+ '(' { $$='('; }
+ |']' { $$ = ']' }
+ ;
+
+open_request_parens:
+ ')' {$$=')'}
+ |'[' {$$='['}
+ ;
+
+script_definition:
+ SCRIPT '{' script_body '}' { $$ = $3; }
+ ;
+
+script_body:
+ STRING int int int {
+ $$ = new Script_def(*$1,$2, $3,$4);
+ delete $1;
+ }
+ ;
+
+textscript_req:
+ script_dir mudela_text { $$ = get_text_req($1,$2); }
+ ;
+
+mudela_text:
+ STRING { $$ = get_text(*$1); delete $1; }
+ ;
+
+script_req:
+ script_dir mudela_script { $$ = get_script_req($1, $2); }
+ ;
+
+mudela_script:
+ IDENTIFIER { $$ = $1->script(true); }
+ | script_definition { $$ = $1; }
+ | '^' { $$ = get_scriptdef('^'); }
+ | '+' { $$ = get_scriptdef('+'); }
+ | '-' { $$ = get_scriptdef('-'); }
+ | '|' { $$ = get_scriptdef('|'); }
+ | 'o' { $$ = get_scriptdef('o'); }
+ | '>' { $$ = get_scriptdef('>'); }
+ | '.' { $$ = get_scriptdef('.'); }
+ | DOTS {
+ if ($1>1) error("too many staccato reqs");
+ $$ = get_scriptdef('.');
+ }
+ ;
+
+script_dir:
+ '_' { $$ = -1; }
+ |'^' { $$ = 1; }
+ |'-' { $$ = 0; }
;
-pre_requests:
+pre_requests:
| pre_requests pre_request {
pre_reqs.add($2);
}
;
pre_request:
- OPEN_REQUEST_PARENS { $$ = get_request($1); }
+ open_request_parens { $$ = get_request($1); }
;
+
+
voice_command:
- DURATIONCOMMAND '{' DURATION '}' {
- set_default_duration(*$3);
- delete $3;
+ PLET '{' INT '/' INT '}' {
+ set_plet($3,$5);
}
- | OCTAVECOMMAND '{' PITCH '}' {
- set_default_pitch(*$3);
+ | DURATIONCOMMAND '{' duration '}' {
+ set_default_duration($3);
+ }
+ | OCTAVECOMMAND '{' pitchmod '}' {
+ set_default_octave(*$3);
delete $3;
}
+ | TEXTSTYLE STRING {
+ set_text_style(*$2);
+ delete $2;
+ }
;
-voice_elt:
- PITCH DURATION {
- $$ = get_note_element(*$1, *$2);
- delete $1;
- delete $2;
+duration: {
+ get_default_duration($$);
}
- | RESTNAME DURATION {
- $$ = get_rest_element(*$1, *$2);
- delete $1;
- delete $2;
+ | int {
+ get_default_duration($$);
+ $$[0] = $1;
+ $$[1] = 0;
+ }
+ | int DOTS {
+ $$[0] = $1;
+ $$[1] = $2;
}
- | PITCH { $$ = get_note_element(*$1, "");
+ | DOTS {
+ get_default_duration($$);
+ $$[1] = $1;
+ }
+ ;
+
+pitchmod: { $$ = new String; }
+ |PITCHMOD
+ ;
+
+voice_elt:
+ pitchmod NOTENAME duration {
+ $$ = get_note_element(*$1, $2, $3);
delete $1;
}
- | RESTNAME { $$ = get_rest_element(*$1, "");
+ | RESTNAME duration {
+ $$ = get_rest_element(*$1, $2);
delete $1;
+
}
;
+
+lyrics_elt:
+ mudela_text duration {
+ $$ = get_word_element($1, $2);
+ };
+
/*
UTILITIES
*/
pitch_list: {
- $$ = new svec<String>;
+ $$ = new Array<int>;
}
- | pitch_list PITCH {
- $$->add(*$2);
- delete $2;
+ | pitch_list NOTENAME {
+ $$->add($2[0]);
+ $$->add($2[1]);
}
+ ;
int:
REAL {
$$ = int($1);
- if (ABS($1-Real(int($$))) > 1e-8)
- yyerror("expecting integer number");
-
+ if ( distance($1,Real(int($$)) ) > 1e-8)
+ error("expecting integer number");
}
+ | INT
;
+
int_list:
/* */ {
- $$ = new svec<int>;
+ $$ = new Array<int>;
}
- | int {
- $$->add($1);
+ | int_list int {
+ $$->add($2);
}
;
|PT { $$ = "pt"; }
;
-clef_id:
- VIOLIN { $$ = new String("violin"); }
- | BASS { $$ = new String("bass"); }
- ;
/*
symbol tables
*/
;
symboldef:
- STRING box {
+ STRING box {
$$ = new Symbol(*$1, *$2);
delete $1;
delete $2;
}
+ | STRING {
+ Box b;
+ $$ = new Symbol(*$1, b);
+ delete $1;
+ }
;
box:
*mlog << "Parsing ... ";
#ifdef YYDEBUG
- yydebug = !monitor.silence("Parser") && check_debug;
+ yydebug = !monitor.silence("InitParser") && check_debug;
#endif
- new_input("symbol.ini");
- yyparse();
- new_input(s);
+ set_lexer();
+ lexer->new_input("symbol.ini");
yyparse();
- delete_identifiers();
+#ifdef YYDEBUG
+ yydebug = !monitor.silence("Parser") && check_debug;
+#endif
+
+ lexer->new_input(s);
+ yyparse();
kill_lexer();
- *mlog << "\n";
+ assert(define_spots.empty());
}
Paperdef*
default_paper()
{
- return new Paperdef(
- lookup_identifier("default_table")->lookup(true));
+ return new Paperdef(
+ lexer->lookup_identifier("default_table")->lookup(true));
}
+
+