using namespace std;
#include "book.hh"
+#include "context.hh"
#include "context-def.hh"
#include "context-mod.hh"
#include "dimensions.hh"
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 (Lily::name, \
- ##__VA_ARGS__, SCM_UNDEFINED))
+ LOWLEVEL_MAKE_SYNTAX (location, Syntax::name, ##__VA_ARGS__)
#define START_MAKE_SYNTAX(name, ...) \
- scm_list_n (Lily::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 ();
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);
%token DESCRIPTION "\\description"
%token DRUMMODE "\\drummode"
%token DRUMS "\\drums"
+%token ETC "\\etc"
%token FIGUREMODE "\\figuremode"
%token FIGURES "\\figures"
%token HEADER "\\header"
%token CHORD_REPETITION
%token CONTEXT_MOD_IDENTIFIER
%token DRUM_PITCH
-%token PITCH_IDENTIFIER
+ /* Artificial token for durations in argument lists */
+%token DURATION_ARG
%token DURATION_IDENTIFIER
%token EVENT_IDENTIFIER
%token EVENT_FUNCTION
%token FRACTION
+%token LOOKUP_IDENTIFIER
%token LYRIC_ELEMENT
%token MARKUP_FUNCTION
%token MARKUP_LIST_FUNCTION
%token MUSIC_IDENTIFIER
%token NOTENAME_PITCH
%token NUMBER_IDENTIFIER
+%token PITCH_IDENTIFIER
%token REAL
%token RESTNAME
%token SCM_ARG
}
;
+lookup:
+ LOOKUP_IDENTIFIER
+ | LOOKUP_IDENTIFIER '.' symbol_list_rev
+ {
+ $$ = loc_on_music (parser, @$,
+ nested_property ($1, scm_reverse_x ($3, SCM_EOL)));
+ }
+ ;
+
embedded_scm_bare:
SCM_TOKEN
{
embedded_scm_active:
SCM_IDENTIFIER
| scm_function_call
+ | lookup
;
embedded_scm_bare_arg:
$$ = parser->lexer_->eval_scm_token ($1, @1);
}
| FRACTION
+ | partial_markup
| full_markup_list
| context_modification
| score_block
| book_block
| bookpart_block
| output_def
+ | lookup
;
/* The generic version may end in music, or not */
embedded_scm:
embedded_scm_bare
| scm_function_call
+ | lookup
;
/* embedded_scm_arg is _not_ casting pitches to music by default, this
parser->lexer_->set_identifier ($1, $3);
$$ = SCM_UNSPECIFIED;
}
- | assignment_id property_path '=' identifier_init {
- SCM path = scm_cons (scm_string_to_symbol ($1), $2);
- parser->lexer_->set_identifier (path, $4);
+ | assignment_id '.' property_path '=' identifier_init {
+ SCM path = scm_cons (scm_string_to_symbol ($1), $3);
+ parser->lexer_->set_identifier (path, $5);
$$ = SCM_UNSPECIFIED;
}
- | assignment_id '.' property_path '=' identifier_init {
+ | assignment_id ',' property_path '=' identifier_init {
SCM path = scm_cons (scm_string_to_symbol ($1), $3);
parser->lexer_->set_identifier (path, $5);
$$ = SCM_UNSPECIFIED;
| 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 ($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:
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);
}
;
{
$$ = scm_append (scm_list_2 ($1, scm_reverse_x ($3, SCM_EOL)));
}
+ | SYMBOL_LIST ',' symbol_list_rev
+ {
+ $$ = scm_append (scm_list_2 ($1, scm_reverse_x ($3, SCM_EOL)));
+ }
;
symbol_list_rev:
{
$$ = scm_append_x (scm_list_2 ($3, $1));
}
+ | symbol_list_rev ',' symbol_list_part
+ {
+ $$ = scm_append_x (scm_list_2 ($3, $1));
+ }
;
// symbol_list_part delivers elements in reverse copy.
symbol_list_part:
symbol_list_element
{
- $$ = try_string_variants (Lily::symbol_list_p, $1);
+ $$ = try_string_variants (Lily::key_list_p, $1);
if (SCM_UNBNDP ($$)) {
- parser->parser_error (@1, _("not a symbol"));
+ parser->parser_error (@1, _("not a key"));
$$ = SCM_EOL;
} else
$$ = scm_reverse ($$);
symbol_list_element:
STRING
| embedded_scm_bare
+ | UNSIGNED
;
(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);
+ }
+ | function_arglist_nonbackup_reparse REPARSE reparsed_rhythm
{
$$ = check_scheme_arg (parser, @3, $3, $1, $2);
}
}
;
+
+reparsed_rhythm:
+ DURATION_ARG dots multipliers post_events
+ {
+ $$ = make_music_from_simple (parser, @$,
+ make_duration ($1, scm_to_int ($2), $3));
+ Music *m = unsmob<Music> ($$);
+ assert (m);
+ if (scm_is_pair ($4))
+ m->set_property ("articulations",
+ scm_reverse_x ($4, SCM_EOL));
+ } %prec ':'
+ ;
+
function_arglist_nonbackup_reparse:
EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SCM_IDENTIFIER
{
{
$$ = $3;
if (scm_is_true (scm_call_1 ($2, $4)))
+ // May be 3 \cm or similar
MYREPARSE (@4, $2, REAL, $4);
+ else if (scm_is_true (scm_call_1 ($2, scm_list_1 ($4))))
+ MYREPARSE (@4, $2, SYMBOL_LIST, scm_list_1 ($4));
else {
SCM d = make_duration ($4);
- if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
- MYREPARSE (@4, $2, REAL, $4); // trigger error
- else
- MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
+ if (!SCM_UNBNDP (d)) {
+ if (scm_is_true (scm_call_1 ($2, d)))
+ MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
+ else if (scm_is_true
+ (scm_call_1
+ ($2, make_music_from_simple (parser, @4, d))))
+ MYREPARSE (@4, $2, DURATION_ARG, d);
+ else
+ MYREPARSE (@4, $2, SCM_ARG, $4); // trigger error
+ } else
+ MYREPARSE (@4, $2, SCM_ARG, $4); // trigger error
}
}
- | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup DURATION_IDENTIFIER {
+ | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup DURATION_IDENTIFIER
+ {
$$ = $3;
- MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
+ if (scm_is_true (scm_call_1 ($2, $4)))
+ MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
+ else if (scm_is_true
+ (scm_call_1
+ ($2, make_music_from_simple (parser, @4, $4))))
+ MYREPARSE (@4, $2, DURATION_ARG, $4);
+ else
+ MYREPARSE (@4, $2, SCM_ARG, $4); // trigger error
}
;
$$ = 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);
}
}
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup UNSIGNED
{
+ $$ = $3;
if (scm_is_true (scm_call_1 ($2, $4)))
- {
+ // May be 3 \cm or similar
MYREPARSE (@4, $2, REAL, $4);
- $$ = $3;
- } else {
+ else if (scm_is_true (scm_call_1 ($2, scm_list_1 ($4))))
+ MYREPARSE (@4, $2, SYMBOL_LIST, scm_list_1 ($4));
+ else {
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);
- MYBACKUP (UNSIGNED, $4, @4);
+ if (!SCM_UNBNDP (d)) {
+ if (scm_is_true (scm_call_1 ($2, d)))
+ MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
+ else if (scm_is_true
+ (scm_call_1
+ ($2, make_music_from_simple (parser, @4, d))))
+ MYREPARSE (@4, $2, DURATION_ARG, d);
+ else {
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
+ MYBACKUP (UNSIGNED, $4, @4);
+ }
} else {
- MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
- $$ = $3;
+ $$ = scm_cons (loc_on_music (parser, @3, $1), $3);
+ MYBACKUP (UNSIGNED, $4, @4);
}
}
}
$$ = $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);
}
}
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup DURATION_IDENTIFIER
{
+ $$ = $3;
if (scm_is_true (scm_call_1 ($2, $4)))
- {
MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
- $$ = $3;
- } else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
+ else if (scm_is_true
+ (scm_call_1
+ ($2, make_music_from_simple (parser, @4, $4))))
+ MYREPARSE (@4, $2, DURATION_ARG, $4);
+ else {
+ $$ = 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_backup REPARSE reparsed_rhythm
{
$$ = 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);
+ }
+ ;
+
+// 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;
}
;
$$ = 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_common_reparse REPARSE reparsed_rhythm
{
$$ = check_scheme_arg (parser, @3,
$3, $1, $2);
{
$$ = $2;
if (scm_is_true (scm_call_1 ($1, $3)))
+ // May be 3 \cm or similar
MYREPARSE (@3, $1, REAL, $3);
+ else if (scm_is_true (scm_call_1 ($1, scm_list_1 ($3))))
+ MYREPARSE (@3, $1, SYMBOL_LIST, scm_list_1 ($3));
else {
SCM d = make_duration ($3);
- if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($1, d)))
- MYREPARSE (@3, $1, REAL, $3);
- else
- MYREPARSE (@3, $1, DURATION_IDENTIFIER, d);
+ if (!SCM_UNBNDP (d)) {
+ if (scm_is_true (scm_call_1 ($1, d)))
+ MYREPARSE (@3, $1, DURATION_IDENTIFIER, d);
+ else if (scm_is_true
+ (scm_call_1
+ ($1, make_music_from_simple (parser, @3, d))))
+ MYREPARSE (@3, $1, DURATION_ARG, d);
+ else
+ MYREPARSE (@3, $1, SCM_ARG, $3); // trigger error
+ } else
+ MYREPARSE (@3, $1, SCM_ARG, $3); // trigger error
}
}
| EXPECT_SCM function_arglist_optional DURATION_IDENTIFIER
{
$$ = $2;
- MYREPARSE (@3, $1, DURATION_IDENTIFIER, $3);
+ if (scm_is_true (scm_call_1 ($1, $3)))
+ MYREPARSE (@3, $1, DURATION_IDENTIFIER, $3);
+ else if (scm_is_true
+ (scm_call_1
+ ($1, make_music_from_simple (parser, @3, $3))))
+ MYREPARSE (@3, $1, DURATION_ARG, $3);
+ else
+ MYREPARSE (@3, $1, SCM_ARG, $3); // trigger error
}
| EXPECT_SCM function_arglist_optional '-' UNSIGNED
{
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);
}
;
symbol_list_rev {
$$ = scm_reverse_x ($1, SCM_EOL);
}
- | symbol_list_rev property_path {
- $$ = scm_reverse_x ($1, $2);
- }
;
property_operation:
| UNSET symbol {
$$ = scm_list_2 (ly_symbol2scm ("unset"), $2);
}
- | OVERRIDE property_path '=' scalar {
+ | OVERRIDE revert_arg '=' scalar {
if (scm_ilength ($2) < 2) {
parser->parser_error (@2, _("bad grob property path"));
$$ = SCM_UNDEFINED;
{
$$ = scm_append_x (scm_list_2 ($5, $3));
}
+ | revert_arg_backup BACKUP SCM_ARG ',' symbol_list_part
+ {
+ $$ = scm_append_x (scm_list_2 ($5, $3));
+ }
| revert_arg_backup BACKUP SCM_ARG symbol_list_part
{
$$ = scm_append_x (scm_list_2 ($4, $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));
} else if (unsmob<Score> (sid)) {
*destination = unsmob<Score> (sid)->clone ()->unprotect ();
return SCM_IDENTIFIER;
+ } else if (scm_is_pair (sid)
+ && scm_is_true (Lily::key_list_p (sid))) {
+ *destination = sid;
+ return LOOKUP_IDENTIFIER;
}
-
return -1;
}
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;
if (scm_is_true (scm_call_1 (pred, str)))
return str;
// a symbol may be interpreted as a list of symbols if it helps
- if (scm_is_symbol (str)) {
+ if (scm_is_true (Lily::key_p (str))) {
str = scm_list_1 (str);
if (scm_is_true (scm_call_1 (pred, str)))
return str;
return SCM_UNDEFINED;
str = scm_string_split (str, SCM_MAKE_CHAR ('.'));
+ for (SCM p = str; scm_is_pair (p); p = scm_cdr (p))
+ scm_set_car_x (p, scm_string_split (scm_car (p),
+ SCM_MAKE_CHAR (',')));
+ str = scm_append_x (str);
for (SCM p = str; scm_is_pair (p); p = scm_cdr (p))
scm_set_car_x (p, scm_string_to_symbol (scm_car (p)));
|| (c >= 'A' && c <= 'Z')
|| c > 0x7f)
middle = true;
- else if (middle && (c == '-' || c == '_' || (multiple && c == '.')))
+ else if (middle && (c == '-' || c == '_' || (multiple &&
+ (c == '.' || c == ','))))
middle = false;
else
return false;
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 ();
}