+LY_DEFINE (ly_parse_string, "ly:parse-string",
+ 1, 0, 0,
+ (SCM ly_code),
+ "Parse the string LY_CODE. "
+ "Upon failure, throw @code{ly-file-failed} key.")
+{
+ SCM_ASSERT_TYPE (ly_c_string_p (ly_code), ly_code, SCM_ARG1, __FUNCTION__, "string");
+
+ Sources sources;
+ sources.set_path (&global_path);
+ My_lily_parser *parser = new My_lily_parser (&sources);
+ parser->parse_string (ly_scm2string (ly_code));
+ parser = 0;
+
+ return SCM_UNSPECIFIED;
+}
+
+
+LY_DEFINE (ly_parser_add_book_and_score, "ly:parser-add-book-and-score",
+ 2, 0, 0,
+ (SCM purple, SCM music),
+ "Handle the toplevel-music MUSIC by adding BOOK and SCORE.")
+{
+#if 0
+ SCM_ASSERT_TYPE (ly_c_parser_p (parser), music, SCM_ARG1, __FUNCTION__, "parser");
+ SCM_ASSERT_TYPE (ly_c_music_p (music), music, SCM_ARG1, __FUNCTION__, "music");
+#endif
+ My_lily_parser *parser = unsmob_my_lily_parser (purple);
+ Score *score = new Score;
+
+ /* URG? */
+ SCM check_funcs = ly_scheme_function ("toplevel-music-functions");
+ for (; ly_c_pair_p (check_funcs); check_funcs = ly_cdr (check_funcs))
+ music = scm_call_1 (ly_car (check_funcs), music);
+ score->music_ = music;
+ Book *book = new Book;
+ book->scores_.push (score);
+ scm_gc_unprotect_object (score->self_scm ());
+
+ SCM header = parser->header_;
+ Path outname = split_path (parser->output_basename_);
+ int *c = &parser->book_count_;
+ if (*c)
+ outname.base += "-" + to_string (*c);
+ (*c)++;
+ My_lily_lexer *lexer = parser->lexer_;
+ Music_output_def *dp
+ = unsmob_music_output_def (lexer->lookup_identifier ("$defaultpaper"));
+ book->process (outname.to_string (),
+ dp ? dp->clone () : new Paper_def, header);
+ scm_gc_unprotect_object (book->self_scm ());
+ return SCM_UNDEFINED;
+}