SCM check_scheme_arg (Lily_parser *parser, Input loc,
SCM arg, SCM args, SCM pred, SCM disp = SCM_UNDEFINED);
SCM make_music_from_simple (Lily_parser *parser, Input loc, SCM pitch);
-SCM loc_on_music (Input loc, SCM arg);
+SCM loc_on_music (Lily_parser *parser, Input loc, SCM arg);
SCM make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list);
SCM make_chord_step (SCM step, Rational alter);
SCM make_simple_markup (SCM a);
-SCM make_duration (SCM t, int dots = 0);
+SCM make_duration (SCM t, int dots = 0, SCM factor = SCM_UNDEFINED);
bool is_regular_identifier (SCM id, bool multiple=false);
SCM try_string_variants (SCM pred, SCM str);
int yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser);
$$ = parser->lexer_->eval_scm_token ($1, @1);
}
| FRACTION
+ | partial_markup
| full_markup_list
| context_modification
| score_block
| pitch_or_music
| FRACTION
| string
- | embedded_scm
+ | embedded_scm
+ | partial_markup
| full_markup_list
| context_modification
| partial_function ETC
{
$$ = MAKE_SYNTAX (partial_music_function, @$,
- scm_reverse_x (scm_car ($1), SCM_EOL),
- scm_reverse_x (scm_cdr ($1), SCM_EOL));
+ scm_reverse_x ($1, SCM_EOL));
}
;
partial_function:
MUSIC_FUNCTION function_arglist_partial
{
- $$ = scm_cons (scm_list_1 ($1), scm_list_1 ($2));
+ $$ = scm_acons ($1, $2, SCM_EOL);
}
| EVENT_FUNCTION function_arglist_partial
{
- $$ = scm_cons (scm_list_1 ($1), scm_list_1 ($2));
+ $$ = scm_acons ($1, $2, SCM_EOL);
}
| SCM_FUNCTION function_arglist_partial
{
- $$ = scm_cons (scm_list_1 ($1), scm_list_1 ($2));
+ $$ = scm_acons ($1, $2, SCM_EOL);
+ }
+ | OVERRIDE grob_prop_path '='
+ {
+ if (SCM_UNBNDP ($2))
+ $$ = scm_list_1 (SCM_BOOL_F);
+ else
+ $$ = scm_cons
+ (scm_list_3 (Syntax::property_override_function,
+ scm_cdr ($2), scm_car ($2)),
+ SCM_EOL);
+ }
+ | SET context_prop_spec '='
+ {
+ if (SCM_UNBNDP ($2))
+ $$ = scm_list_1 (SCM_BOOL_F);
+ else
+ $$ = scm_cons
+ (scm_list_3 (Syntax::property_set_function,
+ scm_cadr ($2), scm_car ($2)),
+ SCM_EOL);
}
| MUSIC_FUNCTION EXPECT_SCM function_arglist_optional partial_function
{
- $$ = scm_cons (scm_cons ($1, scm_car ($4)),
- scm_cons ($3, scm_cdr ($4)));
+ $$ = scm_acons ($1, $3, $4);
}
| EVENT_FUNCTION EXPECT_SCM function_arglist_optional partial_function
{
- $$ = scm_cons (scm_cons ($1, scm_car ($4)),
- scm_cons ($3, scm_cdr ($4)));
+ $$ = scm_acons ($1, $3, $4);
}
| SCM_FUNCTION EXPECT_SCM function_arglist_optional partial_function
{
- $$ = scm_cons (scm_cons ($1, scm_car ($4)),
- scm_cons ($3, scm_cdr ($4)));
+ $$ = scm_acons ($1, $3, $4);
+ }
+ | OVERRIDE grob_prop_path '=' partial_function
+ {
+ if (SCM_UNBNDP ($2))
+ $$ = scm_list_1 (SCM_BOOL_F);
+ else
+ $$ = scm_cons
+ (scm_list_3 (Syntax::property_override_function,
+ scm_cdr ($2), scm_car ($2)),
+ $4);
+ }
+ | SET context_prop_spec '=' partial_function
+ {
+ if (SCM_UNBNDP ($2))
+ $$ = scm_list_1 (SCM_BOOL_F);
+ else
+ $$ = scm_cons
+ (scm_list_3 (Syntax::property_set_function,
+ scm_cadr ($2), scm_car ($2)),
+ $4);
}
| MUSIC_FUNCTION EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup partial_function
{
- $$ = scm_cons (scm_cons ($1, scm_car ($5)),
- scm_cons ($4, scm_cdr ($5)));
+ $$ = scm_acons ($1, $4, $5);
}
| EVENT_FUNCTION EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup partial_function
{
- $$ = scm_cons (scm_cons ($1, scm_car ($5)),
- scm_cons ($4, scm_cdr ($5)));
+ $$ = scm_acons ($1, $4, $5);
}
| SCM_FUNCTION EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup partial_function
{
- $$ = scm_cons (scm_cons ($1, scm_car ($5)),
- scm_cons ($4, scm_cdr ($5)));
+ $$ = scm_acons ($1, $4, $5);
}
;
TEMPO steno_duration '=' tempo_range {
$$ = MAKE_SYNTAX (tempo, @$, SCM_EOL, $2, $4);
}
- | TEMPO scalar steno_duration '=' tempo_range {
+ | TEMPO text steno_duration '=' tempo_range {
$$ = MAKE_SYNTAX (tempo, @$, $2, $3, $5);
}
- | TEMPO scalar {
+ | TEMPO text {
$$ = MAKE_SYNTAX (tempo, @$, $2);
} %prec ':'
;
;
new_lyrics:
- ADDLYRICS lyric_mode_music {
- $$ = scm_list_1 ($2);
+ ADDLYRICS optional_context_mod lyric_mode_music {
+ Context_mod *ctxmod = unsmob<Context_mod> ($2);
+ SCM mods = SCM_EOL;
+ if (ctxmod)
+ mods = ctxmod->get_mods ();
+ $$ = scm_acons ($3, mods, SCM_EOL);
}
- | new_lyrics ADDLYRICS lyric_mode_music {
- $$ = scm_cons ($3, $1);
+ | new_lyrics ADDLYRICS optional_context_mod lyric_mode_music {
+ Context_mod *ctxmod = unsmob<Context_mod> ($3);
+ SCM mods = SCM_EOL;
+ if (ctxmod)
+ mods = ctxmod->get_mods ();
+ $$ = scm_acons ($4, mods, $1);
}
;
(parser, @3, $3),
$1, $2);
}
- | function_arglist_nonbackup_reparse REPARSE duration_length
+ | function_arglist_nonbackup_reparse REPARSE multiplied_duration
{
$$ = check_scheme_arg (parser, @3, $3, $1, $2);
}
$$ = scm_cons ($$, $3);
else
{
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (SCM_ARG, $4, @4);
}
}
{
$$ = scm_cons ($4, $3);
} else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (EVENT_IDENTIFIER, $4, @4);
}
}
} else if (scm_is_true (scm_call_1 ($2, $4)))
$$ = scm_cons ($4, $3);
else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (PITCH_IDENTIFIER, $4, @4);
}
}
} else if (scm_is_true (scm_call_1 ($2, $4)))
$$ = scm_cons ($4, $3);
else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (TONICNAME_PITCH, $4, @4);
}
}
if (scm_is_true (scm_call_1 ($2, $4)))
$$ = scm_cons ($4, $3);
else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (SCM_IDENTIFIER, $4, @4);
}
}
SCM d = make_duration ($4);
if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
{
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (UNSIGNED, $4, @4);
} else {
MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
$$ = $3;
MYREPARSE (@4, $2, REAL, $4);
} else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (REAL, $4, @4);
}
}
{
$$ = scm_cons ($4, $3);
} else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (NUMBER_IDENTIFIER, $4, @4);
}
}
if (scm_is_true (scm_call_1 ($2, $$)))
$$ = scm_cons ($$, $3);
else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (UNSIGNED, $5, @5);
parser->lexer_->push_extra_token (@4, '-');
}
MYREPARSE (@5, $2, REAL, n);
$$ = $3;
} else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (REAL, n, @5);
}
}
if (scm_is_true (scm_call_1 ($2, n))) {
$$ = scm_cons (n, $3);
} else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (NUMBER_IDENTIFIER, n, @5);
}
}
MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
$$ = $3;
} else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (DURATION_IDENTIFIER, $4, @4);
}
}
else
$$ = scm_cons (res, $3);
else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (SCM_IDENTIFIER, $4, @4);
}
}
else
$$ = scm_cons (res, $3);
else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
MYBACKUP (STRING, $4, @4);
}
}
$$ = check_scheme_arg (parser, @3,
$3, $1, $2);
}
- | function_arglist_backup REPARSE duration_length
+ | function_arglist_backup REPARSE multiplied_duration
{
$$ = check_scheme_arg (parser, @3,
$3, $1, $2);
function_arglist_nonbackup
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT
{
- $$ = scm_cons (loc_on_music (@4, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @4, $1), $3);
}
;
function_arglist_nonbackup
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup
{
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
}
;
$$ = check_scheme_arg (parser, @3,
$3, $1, $2);
}
- | function_arglist_common_reparse REPARSE duration_length
+ | function_arglist_common_reparse REPARSE multiplied_duration
{
$$ = check_scheme_arg (parser, @3,
$3, $1, $2);
function_arglist_backup
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup DEFAULT
{
- $$ = scm_cons (loc_on_music (@4, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @4, $1), $3);
}
| function_arglist_skip_backup BACKUP
;
function_arglist_backup
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup
{
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
}
;
OVERRIDE grob_prop_path '=' scalar {
if (SCM_UNBNDP ($2))
$$ = MAKE_SYNTAX (void_music, @$);
- else {
- $$ = MAKE_SYNTAX (property_operation, @$,
+ else
+ $$ = MAKE_SYNTAX (property_override, @$,
scm_car ($2),
- ly_symbol2scm ("OverrideProperty"),
- scm_cadr ($2),
- $4,
- scm_cddr ($2));
- }
+ scm_cdr ($2),
+ $4);
}
| REVERT simple_revert_context revert_arg {
- $$ = MAKE_SYNTAX (property_operation, @$,
- $2,
- ly_symbol2scm ("RevertProperty"),
- scm_car ($3),
- scm_cdr ($3));
+ $$ = MAKE_SYNTAX (property_revert, @$, $2, $3);
}
| SET context_prop_spec '=' scalar {
if (SCM_UNBNDP ($2))
$$ = MAKE_SYNTAX (void_music, @$);
else
- $$ = MAKE_SYNTAX (property_operation, @$,
+ $$ = MAKE_SYNTAX (property_set, @$,
scm_car ($2),
- ly_symbol2scm ("PropertySet"),
scm_cadr ($2),
$4);
}
if (SCM_UNBNDP ($2))
$$ = MAKE_SYNTAX (void_music, @$);
else
- $$ = MAKE_SYNTAX (property_operation, @$,
+ $$ = MAKE_SYNTAX (property_unset, @$,
scm_car ($2),
- ly_symbol2scm ("PropertyUnset"),
scm_cadr ($2));
}
;
string:
- STRING {
- $$ = $1;
- }
+ STRING
| full_markup
;
-simple_string: STRING {
- $$ = $1;
+text:
+ STRING
+ | full_markup
+ | embedded_scm_bare
+ {
+ if (Text_interface::is_markup ($1)) {
+ $$ = $1;
+ } else {
+ parser->parser_error (@1, (_ ("markup expected")));
+ $$ = scm_string (SCM_EOL);
+ }
}
+ ;
+
+simple_string: STRING
| embedded_scm_bare
{
if (scm_is_string ($1)) {
unsmob<Music> (scm_car (s))->set_property ("duration", dur);
es = ly_append2 (es, postevs);
- m-> set_property ("elements", es);
- m->set_spot (@$);
+ m->set_property ("elements", es);
+ m->set_spot (parser->lexer_->override_input (@$));
$$ = m->self_scm ();
} %prec ':'
;
$$ = scm_cons (scm_car (p), $$);
}
} else {
- m->set_spot (@2);
+ m->set_spot (parser->lexer_->override_input (@2));
$$ = scm_cons ($2, $$);
}
}
| '-' { $$ = SCM_UNDEFINED; }
;
-duration_length:
- multiplied_duration {
- $$ = $1;
- }
- ;
-
maybe_notemode_duration:
{
$$ = SCM_UNDEFINED;
}
}
| DURATION_IDENTIFIER dots {
- Duration *d = unsmob<Duration> ($1);
- Duration k (d->duration_log (),
- d->dot_count () + scm_to_int ($2));
- k = k.compressed (d->factor ());
- scm_remember_upto_here_1 ($1);
- $$ = k.smobbed_copy ();
+ $$ = make_duration ($1, scm_to_int ($2));
}
;
multiplied_duration:
- steno_duration {
- $$ = $1;
- }
- | multiplied_duration '*' UNSIGNED {
- $$ = unsmob<Duration> ($$)->compressed (scm_to_int ($3)).smobbed_copy ();
- }
- | multiplied_duration '*' FRACTION {
- Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
-
- $$ = unsmob<Duration> ($$)->compressed (m).smobbed_copy ();
+ steno_duration multipliers {
+ $$ = make_duration ($1, 0, $2);
}
;
}
;
+multipliers:
+ /* empty */
+ {
+ $$ = SCM_UNDEFINED;
+ }
+ | multipliers '*' UNSIGNED
+ {
+ if (!SCM_UNBNDP ($1))
+ $$ = scm_product ($1, $3);
+ else
+ $$ = $3;
+ }
+ | multipliers '*' FRACTION
+ {
+ if (!SCM_UNBNDP ($1))
+ $$ = scm_product ($1, scm_divide (scm_car ($3),
+ scm_cdr ($3)));
+ else
+ $$ = scm_divide (scm_car ($3), scm_cdr ($3));
+ }
+ ;
+
tremolo_type:
':' {
$$ = scm_from_int (parser->default_tremolo_type_);
}
;
-full_markup:
+markup_mode:
MARKUP
- { parser->lexer_->push_markup_state (); }
- markup_top {
- $$ = $3;
+ {
+ parser->lexer_->push_markup_state ();
+ }
+ ;
+
+full_markup:
+ markup_mode markup_top {
+ $$ = $2;
+ parser->lexer_->pop_state ();
+ }
+ ;
+
+partial_markup:
+ markup_mode markup_partial_function ETC
+ {
+ $$ = MAKE_SYNTAX (partial_markup, @2, $2);
parser->lexer_->pop_state ();
}
;
;
markup_scm:
- embedded_scm_bare
+ embedded_scm
{
if (Text_interface::is_markup ($1))
MYBACKUP (MARKUP_IDENTIFIER, $1, @1);
}
;
+markup_partial_function:
+ MARKUP_FUNCTION markup_arglist_partial
+ {
+ $$ = scm_list_1 (scm_cons ($1, scm_reverse_x ($2, SCM_EOL)));
+ }
+ | markup_head_1_list MARKUP_FUNCTION markup_arglist_partial
+ {
+ $$ = scm_cons (scm_cons ($2, scm_reverse_x ($3, SCM_EOL)),
+ $1);
+ }
+ ;
+
+markup_arglist_partial:
+ EXPECT_MARKUP markup_arglist_partial
+ {
+ $$ = $2;
+ }
+ | EXPECT_SCM markup_arglist_partial
+ {
+ $$= $2;
+ }
+ | EXPECT_MARKUP markup_command_list_arguments
+ {
+ $$ = $2;
+ }
+ | EXPECT_SCM markup_command_list_arguments
+ {
+ $$ = $2;
+ }
+ ;
+
markup_head_1_item:
MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
$$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
return args;
}
-SCM loc_on_music (Input loc, SCM arg)
+SCM loc_on_music (Lily_parser *parser, Input loc, SCM arg)
{
if (Music *m = unsmob<Music> (arg))
{
m = m->clone ();
- m->set_spot (loc);
+ m->set_spot (parser->lexer_->override_input (loc));
return m->unprotect ();
}
return arg;
n->set_property ("pitch", simple);
return n->unprotect ();
}
+ SCM d = simple;
+ if (scm_is_integer (simple))
+ d = make_duration (simple);
+ if (unsmob<Duration> (d)) {
+ Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
+ n->set_property ("duration", d);
+ return n->unprotect ();
+ }
return simple;
} else if (parser->lexer_->is_lyric_state ()) {
if (Text_interface::is_markup (simple))
}
SCM
-make_duration (SCM d, int dots)
+make_duration (SCM d, int dots, SCM factor)
{
- int t = scm_to_int (d);
- if (t > 0 && (t & (t-1)) == 0)
- return Duration (intlog2 (t), dots).smobbed_copy ();
- else
- return SCM_UNDEFINED;
+ Duration k;
+
+ if (Duration *dur = unsmob<Duration> (d)) {
+ if (!dots && SCM_UNBNDP (factor))
+ return d;
+ k = *dur;
+ if (dots)
+ k = Duration (k.duration_log (), k.dot_count () + dots)
+ .compressed (k.factor ());
+ } else {
+ int t = scm_to_int (d);
+ if (t > 0 && (t & (t-1)) == 0)
+ k = Duration (intlog2 (t), dots);
+ else
+ return SCM_UNDEFINED;
+ }
+
+ if (!SCM_UNBNDP (factor))
+ k = k.compressed (ly_scm2rational (factor));
+
+ return k.smobbed_copy ();
}
SCM
make_chord_step (SCM step_scm, Rational alter)
{
- int step = scm_to_int (step_scm);
+ Pitch m (0, scm_to_int (step_scm) - 1, alter);
- if (step == 7)
- alter += FLAT_ALTERATION;
+ // Notename/octave are normalized
+ if (m.get_notename () == 6)
+ m = m.transposed (Pitch (0, 0, FLAT_ALTERATION));
- while (step < 0)
- step += 7;
- Pitch m ((step -1) / 7, (step - 1) % 7, alter);
return m.smobbed_copy ();
}