parser->lexer_->override_input (spot))
/* ES TODO:
-- Don't use lily module, create a new module instead.
- delay application of the function
*/
-static SCM
-syntax_call (void *arg)
-{
- SCM sarg = reinterpret_cast <SCM> (arg);
- return scm_apply_0 (scm_car (sarg), scm_cdr (sarg));
-}
-
-#define LOWLEVEL_MAKE_SYNTAX(location, args) \
- scm_c_with_fluid \
- (Lily::f_location, \
- parser->lexer_->override_input (location).smobbed_copy (), \
- syntax_call, \
- reinterpret_cast <void*> (args))
+#define LOWLEVEL_MAKE_SYNTAX(location, proc, ...) \
+ with_location \
+ (parser->lexer_->override_input (location).smobbed_copy (), \
+ proc, \
+ ##__VA_ARGS__)
/* Syntactic Sugar. */
#define MAKE_SYNTAX(name, location, ...) \
- LOWLEVEL_MAKE_SYNTAX (location, \
- scm_list_n (Syntax::name, \
- ##__VA_ARGS__, SCM_UNDEFINED))
+ LOWLEVEL_MAKE_SYNTAX (location, Syntax::name, ##__VA_ARGS__)
#define START_MAKE_SYNTAX(name, ...) \
- scm_list_n (Syntax::name, \
- ##__VA_ARGS__, SCM_UNDEFINED)
+ scm_list_n (Syntax::name, ##__VA_ARGS__, SCM_UNDEFINED)
#define FINISH_MAKE_SYNTAX(start, location, ...) \
- LOWLEVEL_MAKE_SYNTAX (location, \
- scm_append_x \
- (scm_list_2 (start, scm_list_n \
- (__VA_ARGS__, SCM_UNDEFINED))))
+ LOWLEVEL_MAKE_SYNTAX \
+ (location, \
+ Guile_user::apply, \
+ scm_car (start), \
+ scm_append_x \
+ (scm_list_2 (scm_cdr (start), \
+ scm_list_n (__VA_ARGS__, SCM_UNDEFINED))))
SCM get_next_unique_context_id ();
SCM get_next_unique_lyrics_context_id ();
%token DESCRIPTION "\\description"
%token DRUMMODE "\\drummode"
%token DRUMS "\\drums"
+%token ETC "\\etc"
%token FIGUREMODE "\\figuremode"
%token FIGURES "\\figures"
%token HEADER "\\header"
$$ = parser->lexer_->eval_scm_token ($1, @1);
}
| FRACTION
+ | partial_markup
| full_markup_list
| context_modification
| score_block
| FRACTION
| string
| embedded_scm
+ | partial_markup
| full_markup_list
| context_modification
+ | partial_function ETC
+ {
+ $$ = MAKE_SYNTAX (partial_music_function, @$,
+ scm_reverse_x ($1, SCM_EOL));
+ }
+ ;
+
+// Partial functions
+partial_function:
+ MUSIC_FUNCTION function_arglist_partial
+ {
+ $$ = scm_acons ($1, $2, SCM_EOL);
+ }
+ | EVENT_FUNCTION function_arglist_partial
+ {
+ $$ = scm_acons ($1, $2, SCM_EOL);
+ }
+ | SCM_FUNCTION function_arglist_partial
+ {
+ $$ = 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_acons ($1, $3, $4);
+ }
+ | EVENT_FUNCTION EXPECT_SCM function_arglist_optional partial_function
+ {
+ $$ = scm_acons ($1, $3, $4);
+ }
+ | SCM_FUNCTION EXPECT_SCM function_arglist_optional partial_function
+ {
+ $$ = 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_acons ($1, $4, $5);
+ }
+ | EVENT_FUNCTION EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup partial_function
+ {
+ $$ = scm_acons ($1, $4, $5);
+ }
+ | SCM_FUNCTION EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup partial_function
+ {
+ $$ = scm_acons ($1, $4, $5);
+ }
;
context_def_spec_block:
;
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);
}
;
}
;
+// Partial function arglists are returned just in their incomplete
+// state: when combined with the music function, the missing parts of
+// the signature can be reconstructed
+//
+// To serve as a partial arglist, the argument list must absolutely
+// _not_ be in "skipping optional arguments" mode since then there is
+// some backup token that has nowhere to go before \etc.
+//
+// So we can skim off an arbitrary number of arguments from the end of
+// the argument list. The argument list remaining afterwards has to
+// be in not-skipping-optional-arguments mode.
+
+function_arglist_partial:
+ EXPECT_SCM function_arglist_optional
+ {
+ $$ = $2;
+ }
+ | EXPECT_SCM function_arglist_partial_optional
+ {
+ $$ = $2;
+ }
+ | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup
+ {
+ $$ = $3;
+ }
+ | EXPECT_OPTIONAL EXPECT_SCM function_arglist_partial
+ {
+ $$ = $3;
+ }
+ ;
+
+function_arglist_partial_optional:
+ EXPECT_SCM function_arglist_optional
+ {
+ $$ = $2;
+ }
+ | EXPECT_SCM function_arglist_partial_optional
+ {
+ $$ = $2;
+ }
+ | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup
+ {
+ $$ = $3;
+ }
+ | EXPECT_OPTIONAL EXPECT_SCM function_arglist_partial_optional
+ {
+ $$ = $3;
+ }
+ ;
+
function_arglist_common:
EXPECT_NO_MORE_ARGS {
$$ = SCM_EOL;
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));
}
;
}
;
-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_head_1_list ETC
+ {
+ $$ = MAKE_SYNTAX (partial_markup, @2, $2);
parser->lexer_->pop_state ();
}
;
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 ();
}