%token REST "\\rest"
%token REVERT "\\revert"
%token SCORE "\\score"
+%token SCORELINES "\\score-lines"
%token SEQUENTIAL "\\sequential"
%token SET "\\set"
%token SIMULTANEOUS "\\simultaneous"
%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
}
;
+embedded_lilypond_number:
+ '-' embedded_lilypond_number
+ {
+ $$ = scm_difference ($2, SCM_UNDEFINED);
+ }
+ | bare_number_common
+ | UNSIGNED NUMBER_IDENTIFIER
+ {
+ $$ = scm_product ($1, $2);
+ }
+ ;
+
embedded_lilypond:
/* empty */
{
// contains no source location.
$$ = MAKE_SYNTAX ("void-music", @$);
}
- | identifier_init
+ | identifier_init_nonumber
+ | embedded_lilypond_number
+ | post_event post_events
+ {
+ $$ = scm_reverse_x ($2, SCM_EOL);
+ if (Music *m = unsmob_music ($1))
+ {
+ if (m->is_mus_type ("post-event-wrapper"))
+ $$ = scm_append
+ (scm_list_2 (m->get_property ("elements"),
+ $$));
+ else
+ $$ = scm_cons ($1, $$);
+ }
+ if (scm_is_pair ($$)
+ && scm_is_null (scm_cdr ($$)))
+ $$ = scm_car ($$);
+ else
+ {
+ Music * m = MY_MAKE_MUSIC ("PostEvents", @$);
+ m->set_property ("elements", $$);
+ $$ = m->unprotect ();
+ }
+ }
+ | multiplied_duration
| music_embedded music_embedded music_list {
$3 = scm_reverse_x ($3, SCM_EOL);
if (unsmob_music ($2))
identifier_init:
- score_block
- | book_block
- | bookpart_block
- | output_def
- | context_def_spec_block
- | music_assign
+ identifier_init_nonumber
+ | number_expression
| post_event_nofinger post_events
{
$$ = scm_reverse_x ($2, SCM_EOL);
$$ = m->unprotect ();
}
}
- | number_expression
+ ;
+
+identifier_init_nonumber:
+ score_block
+ | book_block
+ | bookpart_block
+ | output_def
+ | context_def_spec_block
+ | music_assign
| FRACTION
| string
| embedded_scm
{
$$ = $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:
;
markup_top:
- simple_markup_list {
+ markup_list {
$$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
}
| markup_head_1_list simple_markup
;
-simple_markup_list:
+markup_list:
markup_composed_list {
$$ = $1;
}
{
$$ = $2;
}
- ;
-
-markup_list:
- simple_markup_list
- | markup_score
- {
- $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $1));
- }
- ;
-
-markup_score:
- SCORE {
+ | SCORELINES {
SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
parser->lexer_->push_note_state (nn);
} '{' score_body '}' {
- $$ = $4;
+ $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $4));
parser->lexer_->pop_state ();
}
;
| markup_braced_list_body markup {
$$ = scm_cons ($2, $1);
}
- | markup_braced_list_body simple_markup_list {
+ | markup_braced_list_body markup_list {
$$ = scm_reverse_x ($2, $1);
}
;
STRING {
$$ = make_simple_markup ($1);
}
+ | SCORE {
+ SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
+ parser->lexer_->push_note_state (nn);
+ } '{' score_body '}' {
+ $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $4);
+ parser->lexer_->pop_state ();
+ }
| MARKUP_FUNCTION markup_command_basic_arguments {
$$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
}
{
$$ = $2;
}
- | markup_score
- {
- $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $1);
- }
;
markup:
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;
}