%token CONTEXT_MOD_IDENTIFIER
%token DRUM_PITCH
%token PITCH_IDENTIFIER
+%token PITCH_ARG
%token DURATION_IDENTIFIER
%token EVENT_IDENTIFIER
%token EVENT_FUNCTION
{
$$ = parser->lexer_->eval_scm_token ($1);
}
+ | FRACTION
| full_markup_list
| context_modification
| score_block
{
$$ = $3;
}
+ | multiplied_duration post_events
+ {
+ Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
+
+ parser->default_duration_ = *unsmob_duration ($1);
+ n->set_property ("duration", $1);
+
+ if (scm_is_pair ($2))
+ n->set_property ("articulations",
+ scm_reverse_x ($2, SCM_EOL));
+ $$ = n->unprotect ();
+ }
;
music_embedded_backup:
*/
function_arglist_nonbackup_common:
- EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup FRACTION
- {
- $$ = check_scheme_arg (parser, @4, $4, $3, $2);
- }
- | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup post_event_nofinger
+ EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup post_event_nofinger
{
$$ = check_scheme_arg (parser, @4, $4, $3, $2);
}
;
+// function_arglist_backup can't occur at the end of an argument
+// list. It needs to be careful about avoiding lookahead only until
+// it has made a decision whether or not to accept the parsed entity.
+// At that point of time, music requiring lookahead to parse becomes
+// fine.
function_arglist_backup:
- function_arglist_backup_common
- | function_arglist_common
- ;
-
-function_arglist_backup_common:
- EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup embedded_scm_arg_closed
+ function_arglist_common
+ | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup embedded_scm_arg_closed
{
if (scm_is_true (scm_call_1 ($2, $4)))
{
MYBACKUP (NUMBER_IDENTIFIER, $4, @4);
}
}
- | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup FRACTION
- {
- if (scm_is_true (scm_call_1 ($2, $4)))
- {
- $$ = scm_cons ($4, $3);
- } else {
- $$ = scm_cons (loc_on_music (@3, $1), $3);
- MYBACKUP (FRACTION, $4, @4);
- }
- }
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup '-' UNSIGNED
{
SCM n = scm_difference ($5, SCM_UNDEFINED);
}
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup PITCH_IDENTIFIER
{
- if (scm_is_true (scm_call_1 ($2, $4)))
+ SCM m = make_music_from_simple (parser, @4, $4);
+ if (unsmob_music (m) && scm_is_true (scm_call_1 ($2, m)))
{
- $$ = scm_cons ($4, $3);
+ MYREPARSE (@4, $2, PITCH_IDENTIFIER, $4);
+ $$ = $3;
+ } else if (scm_is_true (scm_call_1 ($2, $4)))
+ {
+ MYREPARSE (@4, $2, PITCH_ARG, $4);
+ $$ = $3;
} else {
$$ = scm_cons (loc_on_music (@3, $1), $3);
MYBACKUP (PITCH_IDENTIFIER, $4, @4);
}
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup NOTENAME_PITCH
{
- if (scm_is_true (scm_call_1 ($2, $4)))
+ SCM m = make_music_from_simple (parser, @4, $4);
+ if (unsmob_music (m) && scm_is_true (scm_call_1 ($2, m)))
{
MYREPARSE (@4, $2, NOTENAME_PITCH, $4);
$$ = $3;
+ } else if (scm_is_true (scm_call_1 ($2, $4)))
+ {
+ MYREPARSE (@4, $2, PITCH_ARG, $4);
+ $$ = $3;
} else {
$$ = scm_cons (loc_on_music (@3, $1), $3);
MYBACKUP (NOTENAME_PITCH, $4, @4);
}
| EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup TONICNAME_PITCH
{
- if (scm_is_true (scm_call_1 ($2, $4)))
+ SCM m = make_music_from_simple (parser, @4, $4);
+ if (unsmob_music (m) && scm_is_true (scm_call_1 ($2, m)))
{
MYREPARSE (@4, $2, TONICNAME_PITCH, $4);
$$ = $3;
+ } else if (scm_is_true (scm_call_1 ($2, $4)))
+ {
+ MYREPARSE (@4, $2, PITCH_ARG, $4);
+ $$ = $3;
} else {
$$ = scm_cons (loc_on_music (@3, $1), $3);
MYBACKUP (TONICNAME_PITCH, $4, @4);
(parser, @3, $3),
$1, $2);
}
+ | function_arglist_backup REPARSE pitch_arg
+ {
+ $$ = check_scheme_arg (parser, @3,
+ $3, $1, $2);
+ }
| function_arglist_backup REPARSE bare_number_common
{
$$ = check_scheme_arg (parser, @3,
$$ = check_scheme_arg (parser, @3,
$3, $2, $1);
}
- | EXPECT_SCM function_arglist_optional FRACTION
- {
- $$ = check_scheme_arg (parser, @3,
- $3, $2, $1);
- }
| EXPECT_SCM function_arglist_optional post_event_nofinger
{
$$ = check_scheme_arg (parser, @3,
$$ = check_scheme_arg (parser, @3,
$3, $2, $1);
}
- | EXPECT_SCM function_arglist_optional FRACTION
- {
- $$ = check_scheme_arg (parser, @3,
- $3, $2, $1);
- }
| function_arglist_common_reparse REPARSE SCM_ARG
{
$$ = check_scheme_arg (parser, @3,
;
context_change:
- CHANGE STRING '=' STRING {
- $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2), $4);
+ CHANGE symbol '=' simple_string {
+ $$ = MAKE_SYNTAX ("context-change", @$, $2, $4);
}
;
{
$$ = scm_difference ($2, SCM_UNDEFINED);
}
- | FRACTION
| STRING
| full_markup
;
}
} %prec ':'
| simple_chord_elements post_events {
- SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
-
- Input i;
- /* why is this giving wrong start location? -ns
- * i = @$; */
- i.set_location (@1, @2);
- $$ = MAKE_SYNTAX ("event-chord", i, elts);
+ if (scm_is_pair ($2)) {
+ if (unsmob_pitch ($1))
+ $1 = make_chord_elements (@1,
+ $1,
+ parser->default_duration_.smobbed_copy (),
+ SCM_EOL);
+
+ SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
+
+ $$ = MAKE_SYNTAX ("event-chord", @1, elts);
+ } else if (!unsmob_pitch ($1))
+ $$ = MAKE_SYNTAX ("event-chord", @1, $1);
+ // A mere pitch drops through.
} %prec ':'
| CHORD_REPETITION optional_notemode_duration post_events {
Input i;
}
| script_abbreviation {
SCM s = parser->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
- Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
- if (scm_is_string (s))
+ if (scm_is_string (s)) {
+ Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
a->set_property ("articulation-type", s);
- else parser->parser_error (@1, _ ("expecting string as script definition"));
- $$ = a->unprotect ();
+ $$ = a->unprotect ();
+ } else if (ly_prob_type_p (s, ly_symbol2scm ("ArticulationEvent"))) {
+ $$ = s;
+ if (Music *original = unsmob_music (s)) {
+ Music *a = original->clone ();
+ a->set_spot (parser->lexer_->override_input (@$));
+ $$ = a->unprotect ();
+ }
+ } else parser->parser_error (@1, _ ("expecting string or ArticulationEvent as script definition"));
}
;
pitch:
steno_pitch
- | PITCH_IDENTIFIER
+ | PITCH_IDENTIFIER quotes {
+ if (!scm_is_eq (SCM_INUM0, $2))
+ {
+ Pitch p = *unsmob_pitch ($1);
+ p = p.transposed (Pitch (scm_to_int ($2),0,0));
+ $$ = p.smobbed_copy ();
+ }
+ }
+ ;
+
+pitch_arg:
+ PITCH_ARG quotes {
+ if (!scm_is_eq (SCM_INUM0, $2))
+ {
+ Pitch p = *unsmob_pitch ($1);
+ p = p.transposed (Pitch (scm_to_int ($2),0,0));
+ $$ = p.smobbed_copy ();
+ }
+ }
;
gen_text_def:
}
;
+// Can return a single pitch rather than a list.
simple_chord_elements:
new_chord {
if (!parser->lexer_->is_chord_state ())
} %prec ':'
;
+// Can return a single pitch rather than a list.
new_chord:
- steno_tonic_pitch optional_notemode_duration {
- $$ = make_chord_elements (@$, $1, $2, SCM_EOL);
+ steno_tonic_pitch maybe_notemode_duration {
+ if (SCM_UNBNDP ($2))
+ $$ = $1;
+ else
+ $$ = make_chord_elements (@$, $1, $2, SCM_EOL);
}
| steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
SCM its = scm_reverse_x ($4, SCM_EOL);
;
tempo_range:
- UNSIGNED {
+ unsigned_number {
$$ = $1;
- }
- | UNSIGNED '-' UNSIGNED {
+ } %prec ':'
+ | unsigned_number '-' unsigned_number {
$$ = scm_cons ($1, $3);
}
;
unsigned_number:
UNSIGNED
| NUMBER_IDENTIFIER
+ {
+ if (!scm_is_integer ($1)
+ || scm_is_true (scm_negative_p ($1)))
+ {
+ parser->parser_error (@1, _("not an unsigned integer"));
+ $$ = SCM_INUM0;
+ }
+ }
+ | embedded_scm
+ {
+ if (!scm_is_integer ($1)
+ || scm_is_true (scm_negative_p ($1)))
+ {
+ parser->parser_error (@1, _("not an unsigned integer"));
+ $$ = SCM_INUM0;
+ }
+ }
;
exclamations:
parser->default_duration_.smobbed_copy ());
} else if (parser->lexer_->is_chord_state ()) {
if (unsmob_pitch (simple))
- return make_chord_elements (loc, simple,
- parser->default_duration_.smobbed_copy (),
- SCM_EOL);
+ return MAKE_SYNTAX
+ ("event-chord",
+ loc,
+ make_chord_elements (loc, simple,
+ parser->default_duration_.smobbed_copy (),
+ SCM_EOL));
}
return simple;
}