*/
#include <ctype.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <stdio.h>
#include "scm-option.hh"
#define yyerror THIS->parser_error
+/*
+ Add symbols to the TAGS field of a music object.
+*/
+void
+tag_music (Music*m, SCM tag, Input ip)
+{
+ SCM tags = m->get_mus_property ("tags");
+ if (gh_symbol_p (tag))
+ tags = scm_cons (tag, tags);
+ else if (gh_list_p (tag))
+ tags = gh_append2 (tag, tags);
+ else
+ ip.warning (_("Tag must be symbol or list of symbols."));
+
+ m->set_mus_property ("tags", tags);
+}
%token BREATHE
%token CHORDMODIFIERS
%token CHORDS
-%token CHORD_CLOSE
-%token CHORD_OPEN
+%token LESSLESS
+%token MOREMORE
%token CLEF
%token COMMANDSPANREQUEST
%token CONSISTS
%token DEFAULT
%token DENIES
%token DESCRIPTION
-%token DURATION
%token EXTENDER
%token FIGURES FIGURE_OPEN FIGURE_CLOSE
%token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
%token GRACE
-%token ACCIACATURA
+%token ACCIACCATURA
%token APPOGGIATURA
%token GROBDESCRIPTIONS
%token HEADER
%token NOTES
%token OCTAVE
%token ONCE
-%token OUTPUTPROPERTY
%token OVERRIDE SET REVERT
%token PAPER
%token PARTCOMBINE
%token PARTIAL
-%token PITCH
%token PITCHNAMES
%token PROPERTY
%token RELATIVE
%token SIMULTANEOUS
%token SKIP
%token SPANREQUEST
+%token TAG
%token TEMPO
%token TIMES
%token TIME_T
%type <music> note_chord_element chord_body chord_body_element
%type <scm> chord_body_elements
%type <scm> steno_duration optional_notemode_duration multiplied_duration
-%type <scm> verbose_duration
-%type <scm> post_events
+%type <scm> post_events
%type <music> gen_text_def direction_less_event direction_reqd_event
%type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
-%type <scm> explicit_pitch steno_tonic_pitch
+%type <scm> steno_tonic_pitch
%type <scm> duration_length fraction
%type <scm> new_chord step_number chord_items chord_item chord_separator step_numbers
%type <scm> Music_list
%type <outputdef> music_output_def_body
%type <music> shorthand_command_req
-%type <music> post_event
+%type <music> post_event tagged_post_event
%type <music> command_req verbose_command_req
%type <music> extender_req
%type <music> hyphen_req
$$ = $1->self_scm ();
scm_gc_unprotect_object ($$);
}
- | verbose_duration {
- $$ = $1;
- }
| number_expression {
$$ = $1;
}
$$->set_spot(THIS->here_input());
}
- | '<' Music_list '>' {
+ | simul_open Music_list simul_close {
$$ = MY_MAKE_MUSIC("SimultaneousMusic");
$$->set_mus_property ("elements", ly_car ($2));
$$->set_spot(THIS->here_input());
$$->set_mus_property ("procedure", $2);
$$->set_spot (THIS->here_input());
}
- | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
- SCM pred = $2;
- if (!gh_symbol_p ($3))
- {
- THIS->parser_error (_ ("Second argument must be a symbol"));
- }
- /* Should check # args */
- if (!gh_procedure_p (pred))
- {
- THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
- }
-
- Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
- m->set_mus_property ("predicate", pred);
- m->set_mus_property ("grob-property", $3);
- m->set_mus_property ("grob-value", $5);
-
- $$ = m;
- }
| MUSIC_IDENTIFIER {
$$ = unsmob_music ($1);
}
grace_head:
GRACE { $$ = scm_makfrom0str ("Grace"); }
- | ACCIACATURA { $$ = scm_makfrom0str ("Acciaccatura"); }
+ | ACCIACCATURA { $$ = scm_makfrom0str ("Acciaccatura"); }
| APPOGGIATURA { $$ = scm_makfrom0str ("Appoggiatura"); }
;
csm->set_mus_property ("context-type", scm_string_to_symbol ($2));
- SCM new_id = scm_number_to_string (gh_int2scm (new_context_count ++),
- gh_int2scm (10));
+ char s[1024];
+ snprintf (s, 1024, "uniqueContext%d", new_context_count ++);
+
+ SCM new_id = scm_makfrom0str (s);
csm->set_mus_property ("context-id", new_id);
$$ = csm;
}
}
| APPLY embedded_scm Music {
if (!ly_input_procedure_p ($2))
+ {
THIS->parser_error (_ ("\\apply takes function argument"));
-
- SCM ret = gh_call1 ($2, $3->self_scm ());
- Music *m = unsmob_music (ret);
- if (!m) {
- THIS->parser_error ("\\apply must return a Music");
- m = MY_MAKE_MUSIC("Music");
+ $$ = $3;
+ }
+ else
+ {
+ SCM ret = gh_call1 ($2, $3->self_scm ());
+ Music *m = unsmob_music (ret);
+ if (!m) {
+ THIS->parser_error ("\\apply must return a Music");
+ m = MY_MAKE_MUSIC("Music");
+ }
+ $$ = m;
}
- $$ = m;
}
| NOTES
{ THIS->lexer_->push_note_state (); }
}
| relative_music { $$ = $1; }
| re_rhythmed_music { $$ = $1; }
- | part_combined_music { $$ = $1; }
+ | part_combined_music { $$ = $1; }
+ | TAG embedded_scm Music {
+ tag_music ($3, $2, THIS->here_input ());
+ $$ = $3;
+ }
;
relative_music:
}
;
+chord_open: '<'
+ ;
+
+chord_close: '>'
+ ;
+
+simul_open: LESSLESS
+ ;
+
+simul_close: MOREMORE
+ ;
+
chord_body:
- CHORD_OPEN chord_body_elements CHORD_CLOSE
+ chord_open chord_body_elements chord_close
{
$$ = MY_MAKE_MUSIC("EventChord");
$$->set_mus_property ("elements",
$$ = gh_cons ($2->self_scm(), $$);
scm_gc_unprotect_object ($2->self_scm());
}
+ | post_events tagged_post_event {
+ $2 -> set_spot (THIS->here_input ());
+ $$ = scm_cons ($2->self_scm(), $$);
+ scm_gc_unprotect_object ($2->self_scm());
+ }
;
+tagged_post_event:
+ '-' TAG embedded_scm post_event {
+ tag_music ($4, $3, THIS->here_input ());
+ $$ = $4;
+ }
+ ;
post_event:
direction_less_event {
$$ = $1;
}
| script_dir direction_reqd_event {
- $2->set_mus_property ("direction", gh_int2scm ($1));
+ if ($1)
+ $2->set_mus_property ("direction", gh_int2scm ($1));
$$ = $2;
}
| script_dir direction_less_event {
- $2->set_mus_property ("direction", gh_int2scm ($1));
+ if ($1)
+ $2->set_mus_property ("direction", gh_int2scm ($1));
$$ = $2;
}
| string_number_event
}
| open_event {
$$ = $1;
- dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
+ dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP));
}
| EVENT_IDENTIFIER {
$$ = unsmob_music ($1);
steno_pitch {
$$ = $1;
}
- | explicit_pitch {
- $$ = $1;
- }
;
pitch_also_in_chords:
| steno_tonic_pitch
;
-explicit_pitch:
- PITCH embedded_scm {
- $$ = $2;
- if (!unsmob_pitch ($2)) {
- THIS->parser_error (_f ("Expecting musical-pitch value", 3));
- $$ = Pitch ().smobbed_copy ();
- }
- }
- ;
-verbose_duration:
- DURATION embedded_scm {
- $$ = $2;
- if (!unsmob_duration ($2))
- {
- THIS->parser_error (_ ("Must have duration object"));
- $$ = Duration ().smobbed_copy ();
- }
- }
- ;
+
+
extender_req:
EXTENDER {
multiplied_duration {
$$ = $1;
}
- | verbose_duration {
- $$ = $1;
- }
;
optional_notemode_duration:
THIS->beam_check ($$);
}
- | verbose_duration {
- $$ = $1;
- THIS->default_duration_ = *unsmob_duration ($$);
- }
;
steno_duration:
| UNSIGNED {
$$ = scm_number_to_string (gh_int2scm ($1), gh_int2scm (10));
}
- | STRING { $$ = $1 }
+ | STRING { $$ = $1; }
;
bass_mod:
;
lyric_element:
- full_markup { $$ = $1 }
+ full_markup { $$ = $1; }
| STRING { $$ = $1 ; }
;
;
markup_list:
- CHORD_OPEN markup_list_body CHORD_CLOSE { $$ = scm_reverse_x ($2, SCM_EOL); }
+ chord_open markup_list_body chord_close { $$ = scm_reverse_x ($2, SCM_EOL); }
;
markup_line: