#include <ctype.h>
#include <stdlib.h>
+#include <stdio.h>
#include "scm-option.hh"
#include "text-item.hh"
#include "music-list.hh"
-
#define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
make_chord_step (int step, int alter)
{
if (step == 7)
- alter--;
+ alter += FLAT;
- /* ugh: fucks up above 13 */
- Pitch m(step > 7 ? 1 : 0,(step - 1) % 7, alter);
+ while(step < 0)
+ step += 7;
+ Pitch m((step -1) / 7 , (step - 1) % 7, alter);
return m.smobbed_copy ();
}
%token DEFAULT
%token DENIES
%token DESCRIPTION
-%token DURATION
%token EXTENDER
%token FIGURES FIGURE_OPEN FIGURE_CLOSE
%token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
%token NOTES
%token OCTAVE
%token ONCE
-%token OUTPUTPROPERTY
%token OVERRIDE SET REVERT
%token PAPER
%token PARTCOMBINE
%token PARTIAL
-%token PITCH
%token PITCHNAMES
%token PROPERTY
%token RELATIVE
%type <music> note_chord_element chord_body chord_body_element
%type <scm> chord_body_elements
%type <scm> steno_duration optional_notemode_duration multiplied_duration
-%type <scm> verbose_duration
%type <scm> post_events
%type <music> gen_text_def direction_less_event direction_reqd_event
%type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
-%type <scm> explicit_pitch steno_tonic_pitch
+%type <scm> steno_tonic_pitch
%type <scm> duration_length fraction
%type <scm> new_chord step_number chord_items chord_item chord_separator step_numbers
THIS->input_file_->header_ = $1;
}
| score_block {
- THIS->input_file_->scores_.push ($1);
+ Score * sc = $1;
+
+ SCM head = ly_module_p (sc->header_) ? sc->header_ : THIS->input_file_->header_.to_SCM ();
+
+ Path p = split_path (THIS->output_basename_);
+ int *c = &THIS->input_file_->score_count_;
+ if (*c)
+ {
+ p.base += "-" + to_string (*c);
+ }
+
+ (*c)++;
+ SCM outname = scm_makfrom0str (p.to_string ().to_str0());
+
+ for (int i=0; i < sc->defs_.size (); i++)
+ default_rendering (sc->music_, sc->defs_[i]->self_scm(),head, outname);
+
+ if (sc->defs_.empty ())
+ {
+ Music_output_def *id =
+ unsmob_music_output_def (THIS->lexer_->lookup_identifier
+ ("$defaultpaper"));
+
+ id = id ? id->clone () : new Paper_def;
+
+ default_rendering (sc->music_, id->self_scm(), head, outname);
+
+ scm_gc_unprotect_object (id->self_scm ());
+ }
+ scm_gc_unprotect_object (sc->self_scm());
}
| output_def {
if (dynamic_cast<Paper_def*> ($1))
$$ = $1->self_scm ();
scm_gc_unprotect_object ($$);
}
- | verbose_duration {
- $$ = $1;
- }
| number_expression {
$$ = $1;
}
;
translator_spec_body:
- TRANSLATOR_IDENTIFIER {
+ /**/ {
+ $$ = Translator_def::make_scm ();
+ unsmob_translator_def ($$)->set_spot (THIS->here_input ());
+ }
+ | TRANSLATOR_IDENTIFIER {
$$ = $1;
unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
}
- | TYPE STRING {
- $$ = Translator_def::make_scm ();
- Translator_def*td = unsmob_translator_def ($$);
- td->translator_group_type_ = $2;
- td->set_spot (THIS->here_input ());
+ | translator_spec_body TYPE STRING {
+ unsmob_translator_def ($$)->translator_group_type_ = $3;
}
| translator_spec_body DESCRIPTION string {
unsmob_translator_def ($$)->description_ = $3;
/*cont*/ '{' score_body '}' {
THIS->pop_spot ();
$$ = $4;
- if (!$$->defs_.size ())
- {
- Music_output_def *id =
- unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
- $$->add_output (id ? id->clone () : new Paper_def );
- }
+
}
;
$$->header_ = $2;
}
| score_body output_def {
- $$->add_output ($2);
+ $$->defs_.push ($2);
}
| score_body error {
$$->set_mus_property ("procedure", $2);
$$->set_spot (THIS->here_input());
}
- | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
- SCM pred = $2;
- if (!gh_symbol_p ($3))
- {
- THIS->parser_error (_ ("Second argument must be a symbol"));
- }
- /* Should check # args */
- if (!gh_procedure_p (pred))
- {
- THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
- }
-
- Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
- m->set_mus_property ("predicate", pred);
- m->set_mus_property ("grob-property", $3);
- m->set_mus_property ("grob-value", $5);
-
- $$ = m;
- }
| MUSIC_IDENTIFIER {
$$ = unsmob_music ($1);
}
csm->set_mus_property ("context-type", scm_string_to_symbol ($2));
- SCM new_id = scm_number_to_string (gh_int2scm (new_context_count ++),
- gh_int2scm (10));
+ char s[1024];
+ snprintf (s, 1024, "uniqueContext%d", new_context_count ++);
+
+ SCM new_id = scm_makfrom0str (s);
csm->set_mus_property ("context-id", new_id);
$$ = csm;
}
}
| APPLY embedded_scm Music {
if (!ly_input_procedure_p ($2))
+ {
THIS->parser_error (_ ("\\apply takes function argument"));
-
- SCM ret = gh_call1 ($2, $3->self_scm ());
- Music *m = unsmob_music (ret);
- if (!m) {
- THIS->parser_error ("\\apply must return a Music");
- m = MY_MAKE_MUSIC("Music");
+ $$ = $3;
+ }
+ else
+ {
+ SCM ret = gh_call1 ($2, $3->self_scm ());
+ Music *m = unsmob_music (ret);
+ if (!m) {
+ THIS->parser_error ("\\apply must return a Music");
+ m = MY_MAKE_MUSIC("Music");
+ }
+ $$ = m;
}
- $$ = m;
}
| NOTES
{ THIS->lexer_->push_note_state (); }
}
| open_event {
$$ = $1;
- dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
+ dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP));
}
| EVENT_IDENTIFIER {
$$ = unsmob_music ($1);
steno_pitch {
$$ = $1;
}
- | explicit_pitch {
- $$ = $1;
- }
;
pitch_also_in_chords:
| steno_tonic_pitch
;
-explicit_pitch:
- PITCH embedded_scm {
- $$ = $2;
- if (!unsmob_pitch ($2)) {
- THIS->parser_error (_f ("Expecting musical-pitch value", 3));
- $$ = Pitch ().smobbed_copy ();
- }
- }
- ;
-verbose_duration:
- DURATION embedded_scm {
- $$ = $2;
- if (!unsmob_duration ($2))
- {
- THIS->parser_error (_ ("Must have duration object"));
- $$ = Duration ().smobbed_copy ();
- }
- }
- ;
+
+
extender_req:
EXTENDER {
multiplied_duration {
$$ = $1;
}
- | verbose_duration {
- $$ = $1;
- }
;
optional_notemode_duration:
THIS->beam_check ($$);
}
- | verbose_duration {
- $$ = $1;
- THIS->default_duration_ = *unsmob_duration ($$);
- }
;
steno_duration:
| UNSIGNED {
$$ = scm_number_to_string (gh_int2scm ($1), gh_int2scm (10));
}
- | STRING { $$ = $1 }
+ | STRING { $$ = $1; }
;
bass_mod:
- '-' { $$ = -1; }
- | '+' { $$ = 1; }
+ '-' { $$ = -2; }
+ | '+' { $$ = 2; }
| '!' { $$ = 0; }
;
;
lyric_element:
- full_markup { $$ = $1 }
+ full_markup { $$ = $1; }
| STRING { $$ = $1 ; }
;
$$ = make_chord_step ($1, 0);
}
| bare_unsigned '+' {
- $$ = make_chord_step ($1, 1);
+ $$ = make_chord_step ($1, SHARP);
}
| bare_unsigned CHORD_MINUS {
- $$ = make_chord_step ($1,-1);
+ $$ = make_chord_step ($1, FLAT);
}
;