#include "book.hh"
#include "context-def.hh"
#include "dimensions.hh"
-#include "music.hh"
#include "file-path.hh"
#include "input-smob.hh"
#include "input.hh"
+#include "international.hh"
#include "lily-guile.hh"
+#include "lily-lexer.hh"
+#include "lily-parser.hh"
#include "lilypond-input-version.hh"
#include "main.hh"
#include "misc.hh"
-#include "lily-lexer.hh"
-#include "lily-parser.hh"
-#include "paper-book.hh"
+#include "music.hh"
+#include "music.hh"
#include "output-def.hh"
-#include "scm-hash.hh"
+#include "paper-book.hh"
#include "program-option.hh"
+#include "scm-hash.hh"
#include "score.hh"
#include "text-interface.hh"
#include "warn.hh"
-#include "music.hh"
%}
Book *book;
Output_def *outputdef;
SCM scm;
- String *string;
+ std::string *string;
Music *music;
Score *score;
int i;
#define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
Music *property_op_to_music (SCM op);
-Music *context_spec_music (SCM type, SCM id, Music *m, SCM ops);
+Music *context_spec_music (SCM type, SCM id, Music *m, SCM ops, bool create_new);
SCM get_next_unique_context_id ();
SCM get_next_unique_lyrics_context_id ();
%type <outputdef> output_def_body
%type <outputdef> output_def_head
+%type <outputdef> output_def_head_with_mode_switch
%type <outputdef> output_def
%type <outputdef> paper_block
%type <scm> object_id_setting
%type <scm> octave_check
%type <scm> optional_context_mod
+%type <scm> optional_id
%type <scm> optional_notemode_duration
%type <scm> pitch
%type <scm> pitch_also_in_chords
toplevel_expression:
lilypond_header {
THIS->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1);
- }
- | add_quote {
-
}
| book_block {
Book *book = $1;
assignment_id '=' identifier_init {
if (! is_regular_identifier ($1))
{
+#if 0
+ /* no longer valid with dashes in \paper{} block. */
@1.warning (_ ("identifier should have alphabetic characters only"));
+#endif
}
+
THIS->lexer_->set_identifier ($1, $3);
/*
}
else
{
- $$->defs_.push ($2);
+ $$->add_output_def ($2);
}
$2->unprotect ();
}
}
;
+output_def_head_with_mode_switch:
+ output_def_head {
+ THIS->lexer_->push_initial_state ();
+ $$ = $1;
+ }
+ ;
output_def_body:
- output_def_head '{' {
+ output_def_head_with_mode_switch '{' {
$$ = $1;
$$->input_origin_.set_spot (@$);
- THIS->lexer_->push_initial_state ();
}
- | output_def_head '{' OUTPUT_DEF_IDENTIFIER {
+ | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER {
$1->unprotect ();
Output_def *o = unsmob_output_def ($3);
o->input_origin_.set_spot (@$);
$$ = o;
THIS->lexer_->remove_scope ();
THIS->lexer_->add_scope (o->scope_);
- THIS->lexer_->push_initial_state ();
}
| output_def_body assignment {
Repeated_music:
REPEAT simple_string bare_unsigned Music Alternative_music
{
+ /*TODO: move to Scheme.*/
Music *beg = $4;
int times = $3;
SCM alts = scm_is_pair ($5) ? scm_car ($5) : SCM_EOL;
| context_change
;
-
optional_context_mod:
/**/ { $$ = SCM_EOL; }
| WITH { THIS->lexer_->push_initial_state (); }
}
;
-
Composite_music:
Prefix_composite_music { $$ = $1; }
| Grouped_music_list { $$ = $1; }
| Sequential_music { $$ = $1; }
;
-
function_scm_argument:
embedded_scm
| simple_string
}
;
+optional_id:
+ /**/ { $$ = SCM_EOL; }
+ | '=' simple_string {
+ $$ = $2;
+ }
+ ;
+
+
Prefix_composite_music:
Generic_prefix_music_scm {
$$ = run_music_function (THIS, $1);
}
- | CONTEXT simple_string '=' simple_string optional_context_mod Music {
- $$ = context_spec_music ($2, $4, $6, $5);
-
- }
- | CONTEXT simple_string optional_context_mod Music {
- $$ = context_spec_music ($2, SCM_UNDEFINED, $4, $3);
+ | CONTEXT simple_string optional_id optional_context_mod Music {
+ $$ = context_spec_music ($2, $3, $5, $4, false);
}
- | NEWCONTEXT simple_string optional_context_mod Music {
- $$ = context_spec_music ($2, get_next_unique_context_id (), $4,
- $3);
+ | NEWCONTEXT simple_string optional_id optional_context_mod Music {
+ $$ = context_spec_music ($2, $3, $5, $4, true);
}
| TIMES fraction Music
-
{
- int n = scm_to_int (scm_car ($2)); int d = scm_to_int (scm_cdr ($2));
+ int n = scm_to_int (scm_car ($2));
+ int d = scm_to_int (scm_cdr ($2));
Music *mp = $3;
$$= MY_MAKE_MUSIC ("TimeScaledMusic");
THIS->lexer_->pop_state ();
}
| mode_changing_head_with_context optional_context_mod Grouped_music_list {
- $$ = context_spec_music ($1, get_next_unique_context_id (),
- $3, $2);
+ $$ = context_spec_music ($1, SCM_UNDEFINED, $3, $2, true);
if ($1 == ly_symbol2scm ("ChordNames"))
{
Music *chm = MY_MAKE_MUSIC ("UnrelativableMusic");
name = get_next_unique_lyrics_context_id ();
voice = context_spec_music (scm_makfrom0str ("Voice"),
name,
- voice, SCM_EOL);
+ voice, SCM_EOL, false);
}
SCM context = scm_makfrom0str ("Lyrics");
Music *music = unsmob_music (scm_car (s));
Music *com = make_lyric_combine_music (name, music);
Music *csm = context_spec_music (context,
- get_next_unique_context_id (), com, SCM_EOL);
+ SCM_UNDEFINED, com, SCM_EOL, true);
lst = scm_cons (csm->self_scm (), lst);
}
all->set_property ("elements", scm_cons (voice->self_scm (),
ly_symbol2scm ("push"),
scm_cadr ($2),
$5, $3));
- $$ = context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL);
+ $$ = context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL, false);
}
| OVERRIDE context_prop_spec embedded_scm embedded_scm '=' scalar {
$$ = property_op_to_music (scm_list_5 (
ly_symbol2scm ("push"),
scm_cadr ($2),
$6, $4, $3));
- $$ = context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL);
+ $$ = context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL, false);
}
| REVERT context_prop_spec embedded_scm {
$$ = property_op_to_music (scm_list_3 (
scm_cadr ($2),
$3));
- $$= context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL);
+ $$= context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL, false);
}
| SET context_prop_spec '=' scalar {
$$ = property_op_to_music (scm_list_3 (
ly_symbol2scm ("assign"),
scm_cadr ($2),
$4));
- $$= context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL);
+ $$= context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL, false);
}
| UNSET context_prop_spec {
$$ = property_op_to_music (scm_list_2 (
ly_symbol2scm ("unset"),
scm_cadr ($2)));
- $$= context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL);
+ $$= context_spec_music (scm_car ($2), SCM_UNDEFINED, $$, SCM_EOL, false);
}
| ONCE music_property_def {
SCM e = $2->get_property ("element");
;
-add_quote:
- ADDQUOTE string Music {
- SCM adder = ly_lily_module_constant ("add-quotable");
-
- scm_call_2 (adder, $2, $3->self_scm ());
- $3->unprotect();
- }
- ;
-
command_element:
command_event {
$$ = MY_MAKE_MUSIC ("EventChord");
skip->set_spot (@$);
$$ = skip;
}
- | OCTAVE pitch {
- Music *m = MY_MAKE_MUSIC ("RelativeOctaveCheck");
- $$ = m;
- $$->set_spot (@$);
- $$->set_property ("pitch", $2);
- }
| E_BRACKET_OPEN {
Music *m = MY_MAKE_MUSIC ("LigatureEvent");
m->set_property ("span-direction", scm_from_int (START));
sounds_as_c.smobbed_copy());
$$->set_spot (@$);
$$ = context_spec_music (ly_symbol2scm ("Staff"), SCM_UNDEFINED,
- $$, SCM_EOL);
+ $$, SCM_EOL, false);
}
| PARTIAL duration_length {
Moment m = - unsmob_duration ($2)->get_length ();
Music *p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
p->set_spot (@$);
p = context_spec_music (ly_symbol2scm ("Timing"), SCM_UNDEFINED,
- p, SCM_EOL);
+ p, SCM_EOL, false);
p = context_spec_music (ly_symbol2scm ("Score"), SCM_UNDEFINED,
- p, SCM_EOL);
+ p, SCM_EOL, false);
$$ = p;
}
}
Music*
-context_spec_music (SCM type, SCM id, Music *m, SCM ops)
+context_spec_music (SCM type, SCM id, Music *m, SCM ops, bool create_new)
{
Music *csm = MY_MAKE_MUSIC ("ContextSpeccedMusic");
csm->set_property ("context-type",
scm_is_symbol (type) ? type : scm_string_to_symbol (type));
csm->set_property ("property-operations", ops);
+ if (create_new)
+ csm->set_property ("create-new", SCM_BOOL_T);
if (scm_is_string (id))
csm->set_property ("context-id", id);
bool
is_regular_identifier (SCM id)
{
- String str = ly_scm2string (id);
- char const *s = str.to_str0 ();
+ string str = ly_scm2string (id);
+ char const *s = str.c_str ();
bool v = true;
#if 0