static Music *make_music_with_input (SCM name, Input where);
SCM check_scheme_arg (Lily_parser *parser, Input loc,
SCM arg, SCM args, SCM pred);
+SCM make_music_from_simple (Lily_parser *parser, Input loc, SCM pitch);
SCM loc_on_music (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);
bool is_duration (int t);
bool is_regular_identifier (SCM id);
int yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser);
-void set_music_properties (Music *p, SCM a);
%}
%token FRACTION
%token LYRICS_STRING
%token LYRIC_ELEMENT
-%token LYRIC_MARKUP_IDENTIFIER
%token MARKUP_FUNCTION
%token MARKUP_LIST_FUNCTION
%token MARKUP_IDENTIFIER
SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
scm_call_2 (proc, parser->self_scm (), $1);
}
+ | SCM_TOKEN {
+ // Evaluate and ignore #xxx, as opposed to \xxx
+ parser->lexer_->eval_scm_token ($1);
+ }
+ | embedded_scm_active
+ {
+ SCM out = SCM_UNDEFINED;
+ if (Text_interface::is_markup ($1))
+ out = scm_list_1 ($1);
+ else if (Text_interface::is_markup_list ($1))
+ out = $1;
+ if (scm_is_pair (out))
+ {
+ SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
+ scm_call_2 (proc, parser->self_scm (), out);
+ } else if (!scm_is_eq ($1, SCM_UNSPECIFIED))
+ parser->parser_error (@1, _("bad expression type"));
+ }
| output_def {
SCM id = SCM_EOL;
Output_def * od = unsmob_output_def ($1);
| SCM_IDENTIFIER
;
+embedded_scm_active:
+ SCM_IDENTIFIER
+ | scm_function_call
+ ;
+
embedded_scm_bare_arg:
embedded_scm_bare
| STRING
/* empty */ { $$ = SCM_UNSPECIFIED; }
| lilypond_header_body assignment {
+ }
+ | lilypond_header_body embedded_scm {
+
}
;
parser->lexer_->set_identifier (path, $4);
$$ = SCM_UNSPECIFIED;
}
- | embedded_scm { $$ = SCM_UNSPECIFIED; }
;
SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
scm_call_2 (proc, $1, $2);
}
+ | book_body SCM_TOKEN {
+ // Evaluate and ignore #xxx, as opposed to \xxx
+ parser->lexer_->eval_scm_token ($2);
+ }
+ | book_body embedded_scm_active
+ {
+ SCM out = SCM_UNDEFINED;
+ if (Text_interface::is_markup ($2))
+ out = scm_list_1 ($2);
+ else if (Text_interface::is_markup_list ($2))
+ out = $2;
+ if (scm_is_pair (out))
+ {
+ SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
+ scm_call_2 (proc, $1, out);
+ } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
+ parser->parser_error (@2, _("bad expression type"));
+ }
| book_body
{
parser->lexer_->add_scope (unsmob_book ($1)->header_);
} lilypond_header
- | book_body embedded_scm { }
| book_body error {
Book *book = unsmob_book ($1);
book->paper_ = 0;
SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
scm_call_2 (proc, $1, $2);
}
+ | bookpart_body SCM_TOKEN {
+ // Evaluate and ignore #xxx, as opposed to \xxx
+ parser->lexer_->eval_scm_token ($2);
+ }
+ | bookpart_body embedded_scm_active
+ {
+ SCM out = SCM_UNDEFINED;
+ if (Text_interface::is_markup ($2))
+ out = scm_list_1 ($2);
+ else if (Text_interface::is_markup_list ($2))
+ out = $2;
+ if (scm_is_pair (out))
+ {
+ SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
+ scm_call_2 (proc, $1, out);
+ } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
+ parser->parser_error (@2, _("bad expression type"));
+ }
| bookpart_body
{
Book *book = unsmob_book ($1);
book->header_ = ly_make_module (false);
parser->lexer_->add_scope (book->header_);
} lilypond_header
- | bookpart_body embedded_scm { }
| bookpart_body error {
Book *book = unsmob_book ($1);
book->paper_ = 0;
}
| output_def_body assignment {
+ }
+ | output_def_body embedded_scm {
+
}
| output_def_body
{
music_arg:
simple_music
{
- if (unsmob_pitch ($1)) {
- Music *n = MY_MAKE_MUSIC ("NoteEvent", @1);
- n->set_property ("pitch", $1);
- n->set_property ("duration",
- parser->default_duration_.smobbed_copy ());
- $$ = n->unprotect ();
- }
+ $$ = make_music_from_simple (parser, @1, $1);
+ if (!unsmob_music ($$))
+ parser->parser_error (@1, _ ("music expected"));
}
| composite_music %prec COMPOSITE
;
| LYRICS_STRING {
$$ = $1;
}
- | MARKUP_IDENTIFIER
- {
- if (scm_is_string ($1)) {
- $$ = $1;
- } else {
- parser->parser_error (@1, (_ ("simple string expected")));
- $$ = scm_string (SCM_EOL);
- }
- }
- | LYRIC_MARKUP_IDENTIFIER
+ | embedded_scm_bare
{
if (scm_is_string ($1)) {
$$ = $1;
simple_element post_events {
// Let the rhythmic music iterator sort this mess out.
if (scm_is_pair ($2)) {
- if (unsmob_pitch ($1)) {
- Music *n = MY_MAKE_MUSIC ("NoteEvent", @1);
- n->set_property ("pitch", $1);
- n->set_property ("duration",
- parser->default_duration_.smobbed_copy ());
- $$ = n->unprotect ();
- }
- unsmob_music ($$)->set_property ("articulations",
- scm_reverse_x ($2, SCM_EOL));
+ $$ = make_music_from_simple (parser, @1, $1);
+ if (unsmob_music ($$))
+ unsmob_music ($$)->set_property ("articulations",
+ scm_reverse_x ($2, SCM_EOL));
+ else
+ parser->parser_error (@1, _("music expected"));
}
}
| simple_chord_elements post_events {
make_simple_markup ($1));
$$ = t->unprotect ();
}
+ | embedded_scm_bare
+ {
+ Music *m = unsmob_music ($1);
+ if (m && m->is_mus_type ("post-event"))
+ $$ = $1;
+ else if (Text_interface::is_markup ($1)) {
+ Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
+ t->set_property ("text", $1);
+ $$ = t->unprotect ();
+ } else
+ parser->parser_error (@1, _ ("not an articulation"));
+ }
;
fingering:
UNSIGNED { $$ = $1; }
| STRING { $$ = $1; }
| full_markup { $$ = $1; }
+ | embedded_scm_bare
+ {
+ // as an integer, it needs to be non-negative, and otherwise
+ // it needs to be suitable as a markup.
+ if (scm_is_integer ($1)
+ ? scm_is_true (scm_negative_p ($1))
+ : !Text_interface::is_markup ($1))
+ {
+ parser->parser_error (@1, _ ("bass number expected"));
+ $$ = SCM_INUM0;
+ }
+ }
;
figured_bass_alteration:
*/
lyric_markup:
- LYRIC_MARKUP_IDENTIFIER {
- $$ = $1;
- }
- | LYRIC_MARKUP
+ LYRIC_MARKUP
{ parser->lexer_->push_markup_state (); }
markup_top {
$$ = $3;
;
full_markup_list:
- MARKUPLIST_IDENTIFIER {
- $$ = $1;
- }
- | MARKUPLIST
+ MARKUPLIST
{ parser->lexer_->push_markup_state (); }
markup_list {
$$ = $3;
;
full_markup:
- MARKUP_IDENTIFIER {
- $$ = $1;
- }
- | MARKUP
+ MARKUP
{ parser->lexer_->push_markup_state (); }
markup_top {
$$ = $3;
markup_list:
- MARKUPLIST_IDENTIFIER {
- $$ = $1;
- }
- | markup_composed_list {
+ markup_composed_list {
$$ = $1;
}
| markup_braced_list {
STRING {
$$ = make_simple_markup ($1);
}
- | MARKUP_IDENTIFIER {
- $$ = $1;
- }
- | LYRIC_MARKUP_IDENTIFIER {
- $$ = $1;
- }
| SCORE {
SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
parser->lexer_->push_note_state (nn);
*destination = p->self_scm ();
p->unprotect ();
return OUTPUT_DEF_IDENTIFIER;
- } else if (Text_interface::is_markup (sid)) {
- *destination = sid;
- if (is_lyric_state ())
- return LYRIC_MARKUP_IDENTIFIER;
- return MARKUP_IDENTIFIER;
- } else if (Text_interface::is_markup_list (sid)) {
- *destination = sid;
- return MARKUPLIST_IDENTIFIER;
}
return -1;
return v;
}
+SCM
+make_music_from_simple (Lily_parser *parser, Input loc, SCM simple)
+{
+ if (unsmob_music (simple))
+ return simple;
+ if (parser->lexer_->is_note_state ()) {
+ Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
+ n->set_property ("duration", parser->default_duration_.smobbed_copy ());
+ if (scm_is_symbol (simple))
+ n->set_property ("drum-type", simple);
+ else if (unsmob_pitch (simple))
+ n->set_property ("pitch", simple);
+ else {
+ n->unprotect ();
+ return simple;
+ }
+ return n->unprotect ();
+ } else if (parser->lexer_->is_lyric_state ()) {
+ if (Text_interface::is_markup (simple))
+ return MAKE_SYNTAX ("lyric-event", loc, simple,
+ 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 simple;
+}
+
Music *
make_music_with_input (SCM name, Input where)
{
return t && t == 1 << intlog2 (t);
}
-void
-set_music_properties (Music *p, SCM a)
-{
- for (SCM k = a; scm_is_pair (k); k = scm_cdr (k))
- p->set_property (scm_caar (k), scm_cdar (k));
-}
-
-
SCM
make_chord_step (SCM step_scm, Rational alter)
{