*/
#include <iostream.h>
+#include "translator-def.hh"
#include "lily-guile.hh"
#include "translation-property.hh"
#include "lookup.hh"
#include "musical-request.hh"
#include "my-lily-parser.hh"
#include "context-specced-music.hh"
-#include "translator-group.hh"
#include "score.hh"
#include "music-list.hh"
#include "change-translator.hh"
#include "file-results.hh"
+#include "input.hh"
#include "scope.hh"
#include "relative-music.hh"
#include "lyric-combine-music.hh"
#include "mudela-version.hh"
#include "grace-music.hh"
#include "auto-change-music.hh"
+#include "part-combine-music.hh"
#include "output-property.hh"
+#include "chord.hh"
bool
is_duration_b (int t)
Identifier *id;
String * string;
Music *music;
- Music_list *music_list;
Score *score;
Scope *scope;
- Interval *interval;
+
Musical_req* musreq;
Music_output_def * outputdef;
Musical_pitch * pitch;
Midi_def* midi;
- Moment *moment;
Real real;
Request * request;
SCM scm;
Tempo_req *tempo;
- Translator_group* trans;
int i;
}
%{
%token SEQUENTIAL
%token SIMULTANEOUS
%token CONSISTSEND
+%token DENIES
%token DURATION
%token EXTENDER
%token FONT
%token PARTIAL
%token PENALTY
%token PROPERTY
+%token PUSHPROPERTY POPPROPERTY
+%token PUSH POP
%token PT_T
%token RELATIVE
%token REMOVE
%token REPEAT
%token ADDLYRICS
+%token PARTCOMBINE
%token SCM_T
%token SCORE
%token SCRIPT
%token <pitch> CHORDMODIFIER_PITCH
%token <id> DURATION_IDENTIFIER
%token <id> IDENTIFIER
-%token <id> MUSIC_IDENTIFIER
-%token <id> REQUEST_IDENTIFIER
-%token <id> TRANS_IDENTIFIER
-%token <scm> NUMBER_IDENTIFIER
+
%token <id> SCORE_IDENTIFIER
%token <id> MUSIC_OUTPUT_DEF_IDENTIFIER
+%token <scm> NUMBER_IDENTIFIER
+%token <scm> REQUEST_IDENTIFIER
+%token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
%token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
%token <scm> DURATION RESTNAME
%token <scm> STRING
%type <scm> embedded_scm scalar
%type <music> Music Sequential_music Simultaneous_music Music_sequence
-%type <music> relative_music re_rhythmed_music
+%type <music> relative_music re_rhythmed_music part_combined_music
%type <music> property_def translator_change
-%type <music_list> Music_list
+%type <scm> Music_list
%type <outputdef> music_output_def_body
%type <request> shorthand_command_req
%type <request> post_request
%type <scm> string bare_number number_expression
%type <score> score_block score_body
-%type <trans> translator_spec_block translator_spec_body
+%type <scm> translator_spec_block translator_spec_body
%type <tempo> tempo_request
%type <scm> notenames_body notenames_block chordmodifiers_block
%type <scm> script_abbreviation
Identifier * id = new
Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER);
if (dynamic_cast<Paper_def*> ($1))
- THIS->lexer_p_->set_identifier ("$defaultpaper", smobify (id));
+ THIS->lexer_p_->set_identifier ("$defaultpaper", id->self_scm ());
else if (dynamic_cast<Midi_def*> ($1))
- THIS->lexer_p_->set_identifier ("$defaultmidi", smobify (id));
+ THIS->lexer_p_->set_identifier ("$defaultmidi", id->self_scm ());
}
| embedded_scm {
// junk value
THIS->remember_spot ();
}
/* cont */ '=' identifier_init {
- THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
+ THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
+
+/*
+ TODO: devise standard for protection in parser.
+
+ The parser stack lives on the C-stack, which means that
+all objects can be unprotected as soon as they're here.
+*/
Identifier * id =unsmob_identifier ($4);
Input spot = THIS->pop_spot ();
if (id) id->set_spot (spot);
identifier_init:
score_block {
- $$ = smobify (new Score_identifier ($1, SCORE_IDENTIFIER));
+ $$ = (new Score_identifier ($1, SCORE_IDENTIFIER))->self_scm();
}
| output_def {
- $$ = smobify (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER));
+ $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
}
| translator_spec_block {
- $$ = smobify (new Translator_group_identifier ($1, TRANS_IDENTIFIER));
+ $$ = $1;
}
| Music {
- $$ = smobify (new Music_identifier ($1, MUSIC_IDENTIFIER));
+ $$ = $1->self_scm ();
+ scm_unprotect_object ($$);
}
-
| post_request {
- $$ = smobify (new Request_identifier ($1, REQUEST_IDENTIFIER));
+ $$ = $1->self_scm ();
+ scm_unprotect_object ($$);
}
| explicit_duration {
- $$ = smobify (new Duration_identifier ($1, DURATION_IDENTIFIER));
+ $$ = (new Duration_identifier ($1, DURATION_IDENTIFIER))->self_scm ();
}
| number_expression {
$$ = $1;
;
translator_spec_body:
- TRANS_IDENTIFIER {
- $$ = $1->access_content_Translator_group (true);
- $$-> set_spot (THIS->here_input ());
+ TRANSLATOR_IDENTIFIER {
+ $$ = unsmob_translator_def ($1)->clone_scm ();
+ unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
}
| TYPE STRING semicolon {
- Translator* t = get_translator_l (ly_scm2string ($2));
- Translator_group * tg = dynamic_cast<Translator_group*> (t);
-
- if (!tg)
- THIS->parser_error (_("Need a translator group for a context"));
-
- tg = dynamic_cast<Translator_group*> (t->clone ());
- tg->set_spot (THIS->here_input ());
- $$ = tg;
+ $$ = Translator_def::make_scm ();
+ Translator_def*td = unsmob_translator_def ($$);
+ td->translator_group_type_ = $2;
+ td->set_spot (THIS->here_input ());
}
| translator_spec_body STRING '=' embedded_scm {
- Translator_group* tg = $$;
- tg->set_property (ly_scm2string ($2), $4);
+ unsmob_translator_def ($$)->add_property_assign ($2, $4);
+ }
+ | translator_spec_body STRING PUSH embedded_scm '=' embedded_scm {
+ unsmob_translator_def ($$)
+ ->add_push_property (scm_string_to_symbol ($2), $4, $6);
+ }
+ | translator_spec_body STRING POP embedded_scm {
+ unsmob_translator_def($$)->add_pop_property (
+ scm_string_to_symbol ($2), $4);
}
| translator_spec_body STRING '=' identifier_init semicolon {
SCM v = gh_int2scm (0);
THIS->parser_error (_("Wrong type for property value"));
/* ugh*/
- Translator_group* tg = dynamic_cast<Translator_group*> ($$);
-
- tg->set_property (ly_scm2string ($2), v);
+ unsmob_translator_def($$)->add_property_assign ($2, v);
}
| translator_spec_body NAME STRING semicolon {
- $$->type_str_ = ly_scm2string ($3);
+ unsmob_translator_def ($$)->type_name_ = $3;
}
| translator_spec_body CONSISTS STRING semicolon {
- dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
+ unsmob_translator_def ($$)->add_element ($3);
}
| translator_spec_body CONSISTSEND STRING semicolon {
- dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
+ unsmob_translator_def ($$)->add_last_element ( $3);
}
| translator_spec_body ACCEPTS STRING semicolon {
- dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
+ unsmob_translator_def ($$)->set_acceptor ($3,true);
+ }
+ | translator_spec_body DENIES STRING semicolon {
+ unsmob_translator_def ($$)->set_acceptor ($3,false);
}
| translator_spec_body REMOVE STRING semicolon {
- dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
+ unsmob_translator_def ($$)->remove_element ($3);
}
;
score_body:
Music {
$$ = new Score;
+
$$->set_spot (THIS->here_input ());
- $$->music_p_ = $1;
+ SCM m = $1->self_scm ();
+ scm_unprotect_object (m);
+ $$->music_ = m;
}
| SCORE_IDENTIFIER {
$$ = $1->access_content_Score (true);
}
| music_output_def_body translator_spec_block {
- $$-> assign_translator ($2);
+ $$->assign_translator ($2);
}
| music_output_def_body tempo_request semicolon {
/*
music.
*/
dynamic_cast<Midi_def*> ($$)->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
- delete $2;
}
| music_output_def_body bare_int '=' FONT STRING { // ugh, what a syntax
- Lookup * l =unsmob_lookup (Lookup::make_lookup());
+ SCM sl = Lookup::make_lookup();
+ Lookup * l =unsmob_lookup (sl);
l->font_name_ = ly_scm2string ($5);
- dynamic_cast<Paper_def*> ($$)->set_lookup ($2, l);
+ dynamic_cast<Paper_def*> ($$)->set_lookup ($2, sl);
}
| music_output_def_body error {
;
Music_list: /* empty */ {
- $$ = new Music_list;
- $$->set_spot (THIS->here_input ());
+ $$ = gh_cons (SCM_EOL, SCM_EOL);
}
| Music_list Music {
- $$->add_music ($2);
+ SCM s = $$;
+ SCM c = gh_cons ($2->self_scm (), SCM_EOL);
+ scm_unprotect_object ($2->self_scm ()); /* UGH */
+
+
+ if (gh_pair_p (gh_cdr (s)))
+ gh_set_cdr_x (gh_cdr (s), c); /* append */
+ else
+ gh_set_car_x (s, c); /* set first cons */
+ gh_set_cdr_x (s, c) ; /* remember last cell */
}
| Music_list error {
}
{
Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
if (m && $3 < m->length_i ())
- $5->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
+ $5->origin ()->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
$$ = r;
r->type_ = ly_scm2string ($2);
r->fold_b_ = (r->type_ == "fold");
r->volta_fold_b_ = (r->type_ == "volta");
- r->set_spot ($4->spot ());
+ r->set_spot (*$4->origin ());
}
;
Music_sequence: '{' Music_list '}' {
- $$ = new Music_sequence ($2);
- $$->set_spot ($2->spot ());
+ $$ = new Music_sequence (gh_car ($2));
}
;
Sequential_music:
SEQUENTIAL '{' Music_list '}' {
- $$ = new Sequential_music ($3);
- $$->set_spot ($3->spot ());
+ $$ = new Sequential_music (gh_car ($3));
}
| '{' Music_list '}' {
- $$ = new Sequential_music ($2);
- $$->set_spot ($2->spot ());
+ $$ = new Sequential_music (gh_car ($2));
}
;
Simultaneous_music:
SIMULTANEOUS '{' Music_list '}'{
- $$ = new Simultaneous_music ($3);
- $$->set_spot ($3->spot ());
+ $$ = new Simultaneous_music (gh_car ($3));
}
| '<' Music_list '>' {
- $$ = new Simultaneous_music ($2);
- $$->set_spot ($2->spot ());
+ $$ = new Simultaneous_music (gh_car ($2));
}
;
$$ = new Output_property (pred,$3, $5);
}
- | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
+ | MUSIC_IDENTIFIER { $$ = unsmob_music ($1)->clone (); }
| property_def
+/* | PUSHPROPERTY embedded_scm embedded_scm embedded_scm {
+ $$ = new Push_translation_property;
+ $$->set_mus_property ("symbols", $2);
+ $$->set_mus_property ("element-property", $3);
+ $$->set_mus_property ("element-value", $4);
+ }
+ | POPPROPERTY embedded_scm embedded_scm {
+ $$ = new Pop_translation_property;
+ $$->set_mus_property ("symbols", $2);
+ $$->set_mus_property ("element-property", $3);
+ }
+*/
| translator_change
| Simple_music '*' bare_unsigned '/' bare_unsigned {
$$ = $1;
Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
$$ = chm;
- chm->set_spot ($3->spot ());
+ chm->set_spot (*$3->origin ());
}
| GRACE Music {
$$ = new Grace_music ($2);
| Sequential_music { $$ = $1; }
| TRANSPOSE musical_pitch Music {
$$ = new Transposed_music ($3, *$2);
- delete $2;
+ delete $2; // ugh
}
| TRANSPOSE steno_tonic_pitch Music {
$$ = new Transposed_music ($3, *$2);
- delete $2;
+ delete $2; // ugh
}
| NOTES
{ THIS->lexer_p_->push_note_state (); }
}
| relative_music { $$ = $1; }
| re_rhythmed_music { $$ = $1; }
+ | part_combined_music { $$ = $1; }
;
relative_music:
RELATIVE absolute_musical_pitch Music {
$$ = new Relative_octave_music ($3, *$2);
- delete $2;
+ delete $2; // ugh
}
;
}
;
+part_combined_music:
+ PARTCOMBINE STRING Music Music {
+ Part_combine_music * p = new Part_combine_music (ly_scm2string ($2), $3, $4);
+ $$ = p;
+ }
+ ;
+
translator_change:
TRANSLATOR STRING '=' STRING {
Change_translator * t = new Change_translator;
PROPERTY STRING '.' STRING '=' scalar {
Translation_property *t = new Translation_property;
- t->var_str_ = ly_scm2string ($4);
- t->value_ = $6;
+ t->set_mus_property ("symbol", scm_string_to_symbol ($4));
+ t->set_mus_property ("value", $6);
+
+ Context_specced_music *csm = new Context_specced_music (t);
+ $$ = csm;
+ $$->set_spot (THIS->here_input ());
+
+ csm-> translator_type_str_ = ly_scm2string ($2);
+ }
+ | PROPERTY STRING '.' STRING PUSH embedded_scm '=' embedded_scm {
+ Push_translation_property *t = new Push_translation_property;
+ t->set_mus_property ("symbols", scm_string_to_symbol ($4));
+ t->set_mus_property ("element-property", $6);
+ t->set_mus_property ("element-value", $8);
Context_specced_music *csm = new Context_specced_music (t);
$$ = csm;
$$->set_spot (THIS->here_input ());
csm-> translator_type_str_ = ly_scm2string ($2);
}
+ | PROPERTY STRING POP embedded_scm {
+ $$ = new Pop_translation_property;
+ $$->set_mus_property ("symbols", scm_string_to_symbol ($2));
+ $$->set_mus_property ("element-property", $4);
+ }
;
scalar:
Music_sequence *l = dynamic_cast<Music_sequence*>($2);
if (l) {
for (int i=0; i < $1->size(); i++)
- l->add_music ($1->elem(i));
+ l->append_music ($1->elem(i));
for (int i=0; i < $3->size(); i++)
- l->add_music ($3->elem(i));
+ l->append_music ($3->elem(i));
}
else
programming_error ("Need Sequence to add music to");
command_element:
command_req {
- $$ = new Request_chord;
+ $$ = new Request_chord (gh_cons ($1->self_scm (), SCM_EOL));
$$-> set_spot (THIS->here_input ());
$1-> set_spot (THIS->here_input ());
- ((Simultaneous_music*)$$) ->add_music ($1);//ugh
}
| PARTIAL duration_length ';' {
Translation_property * p = new Translation_property;
- p->var_str_ = "measurePosition";
- p->value_ = (new Moment (-$2->length_mom ()))->smobify_self ();
- delete $2;
+ p->set_mus_property ("symbol", ly_symbol2scm ( "measurePosition"));
+ Moment m = - $2->length_mom ();
+ p->set_mus_property ("value", m.make_scm());
+ delete $2; // ugh
Context_specced_music * sp = new Context_specced_music (p);
$$ =sp ;
sp-> translator_type_str_ = "Score";
}
| MARK STRING {
Mark_req *m = new Mark_req;
- m->mark_label_ = $2;
+ m->set_mus_property ("label", $2);
$$ = m;
}
| MARK bare_unsigned {
Mark_req *m = new Mark_req;
- m->mark_label_ = gh_int2scm ($2);
+ m->set_mus_property ("label", gh_int2scm ($2));
$$ = m;
}
| SKIP duration_length {
Skip_req * skip_p = new Skip_req;
skip_p->duration_ = *$2;
- delete $2;
+ delete $2; // ugh
$$ = skip_p;
}
| tempo_request {
| KEY NOTENAME_PITCH SCM_IDENTIFIER {
Key_change_req *key_p= new Key_change_req;
- key_p->pitch_alist_ = $3;
+ key_p->set_mus_property ("pitch-alist", $3);
((Music* )key_p)->transpose (* $2);
$$ = key_p;
}
if (Script_req * gs = dynamic_cast<Script_req*> ($2))
gs->dir_ = Direction ($1);
else if ($1)
- $2->warning (_ ("Can't specify direction for this request"));
+ $2->origin ()->warning (_ ("Can't specify direction for this request"));
$$ = $2;
}
;
verbose_request:
REQUEST_IDENTIFIER {
- $$ = (Request*)$1->access_content_Request (true);
+ $$ = dynamic_cast<Request*> (unsmob_music ($1)->clone ());
$$->set_spot (THIS->here_input ());
}
| TEXTSCRIPT STRING STRING {
n->cautionary_b_ = $3 % 2;
n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
- Simultaneous_music*v = new Request_chord;
+
+ Simultaneous_music*v = new Request_chord (gh_list (n->self_scm (), SCM_UNDEFINED));
v->set_spot ($1->spot ());
n->set_spot ($1->spot ());
-
- v->add_music (n);
-
$$ = v;
delete $1;
delete $4;
}
| RESTNAME optional_notemode_duration {
- Simultaneous_music* velt_p = new Request_chord;
- velt_p->set_spot (THIS->here_input());
+ SCM e = SCM_UNDEFINED;
if (ly_scm2string ($1) =="s")
{ /* Space */
Skip_req * skip_p = new Skip_req;
skip_p->duration_ = *$2;
skip_p->set_spot (THIS->here_input());
- velt_p->add_music (skip_p);
+ e = skip_p->self_scm ();
}
else
{
Rest_req * rest_req_p = new Rest_req;
rest_req_p->duration_ = *$2;
rest_req_p->set_spot (THIS->here_input());
-
- velt_p->add_music (rest_req_p);
+ e = rest_req_p->self_scm ();
}
+ Simultaneous_music* velt_p = new Request_chord (gh_list (e,SCM_UNDEFINED));
+ velt_p->set_spot (THIS->here_input());
- delete $2;
+ delete $2; // ugh
$$ = velt_p;
}
| MEASURES optional_notemode_duration {
Skip_req * sk = new Skip_req;
sk->duration_ = *$2;
- Music_list * ms = new Music_list;
- Request_chord * rqc1 = new Request_chord;
- Request_chord * rqc2 = new Request_chord;
- Request_chord * rqc3 = new Request_chord;
+
Span_req *sp1 = new Span_req;
Span_req *sp2 = new Span_req;
sp1-> span_dir_ = START;
sp2-> span_dir_ = STOP;
sp1->span_type_str_ = sp2->span_type_str_ = "rest";
- rqc1->add_music (sp1);
- rqc2->add_music (sk);
- rqc3->add_music (sp2);
-
- ms->add_music (rqc1);
- ms->add_music (rqc2);
- ms->add_music (rqc3);
+
+ Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
+ Request_chord * rqc2 = new Request_chord (gh_list (sk->self_scm (), SCM_UNDEFINED));;
+ Request_chord * rqc3 = new Request_chord(gh_list (sp2->self_scm (), SCM_UNDEFINED));;
+
+ SCM ms = gh_list (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
$$ = new Sequential_music (ms);
}
| STRING optional_notemode_duration {
if (!THIS->lexer_p_->lyric_state_b ())
THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
- Simultaneous_music* velt_p = new Request_chord;
-
Lyric_req* lreq_p = new Lyric_req;
lreq_p ->text_str_ = ly_scm2string ($1);
lreq_p->duration_ = *$2;
lreq_p->set_spot (THIS->here_input());
+ Simultaneous_music* velt_p = new Request_chord (gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
- velt_p->add_music (lreq_p);
-
- delete $2;
+ delete $2; // ugh
$$= velt_p;
}
chord:
steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
- $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
+ $$ = get_chord (*$1, $3, $4, $5, $6, *$2);
+ $$->set_spot (THIS->here_input ());
};
chord_additions: