From 7192c2b8e9b46ee4bbcf94cda29f05ec0164f2d7 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 24 Apr 2004 21:48:02 +0000 Subject: [PATCH] (ly:parser-parse-string): New function. --- ChangeLog | 4 ++++ lily/ly-module.cc | 4 ++-- lily/my-lily-parser.cc | 36 +++++++++++++++++++++++++++++------- scm/lily.scm | 2 ++ 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6efc1d0054..c4bb553538 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-04-24 Jan Nieuwenhuizen + + * lily/my-lily-parser.cc (ly:parser-parse-string): New function. + 2004-04-21 Jan Nieuwenhuizen * input/regression/newaddlyrics.ly: Remove lilypond-book kludge. diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 1921c9084e..e536e9503a 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -17,7 +17,7 @@ static int module_count; void -ly_init_anonymous_module (void * data) +ly_init_anonymous_module (void *data) { (void) data; scm_c_use_module ("lily"); @@ -27,7 +27,7 @@ SCM ly_make_anonymous_module () { String s = "*anonymous-ly-" + to_string (module_count++) + "*"; - SCM mod = scm_c_define_module (s.to_str0(), ly_init_anonymous_module, 0); + SCM mod = scm_c_define_module (s.to_str0 (), ly_init_anonymous_module, 0); return mod; } diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index 47cbade68e..5148a238d1 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -174,25 +174,22 @@ My_lily_parser::here_input () const */ bool store_locations_global_b; -/* - no ! suffix since it doesn't modify 1st argument. - */ +/* Do not append `!' suffix, since 1st argument is not modified. */ LY_DEFINE (ly_set_point_and_click, "ly:set-point-and-click", 1, 0, 0, (SCM what), "Set the options for Point-and-click source specials output. The\n" "argument is a symbol. Possible options are @code{none} (no source specials),\n" "@code{line} and @code{line-column}") { - /* - UGH. - */ + /* UGH. */ SCM val = SCM_BOOL_F; if (ly_symbol2scm ("line-column") == what) val = scm_c_eval_string ("line-column-location"); else if (what == ly_symbol2scm ("line")) val = scm_c_eval_string ("line-location"); - scm_module_define (global_lily_module, ly_symbol2scm ("point-and-click"), val); + scm_module_define (global_lily_module, ly_symbol2scm ("point-and-click"), + val); store_locations_global_b = ly_c_procedure_p (val); return SCM_UNSPECIFIED; } @@ -282,6 +279,8 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", progress_indication ("\n"); My_lily_parser *parser = new My_lily_parser (&sources); + scm_module_define (global_lily_module, ly_symbol2scm ("parser"), + parser->self_scm ()); parser->parse_file (init, in_file, out_file); bool error = parser->error_level_; @@ -305,12 +304,35 @@ LY_DEFINE (ly_parse_string, "ly:parse-string", Sources sources; sources.set_path (&global_path); My_lily_parser *parser = new My_lily_parser (&sources); + scm_module_define (global_lily_module, ly_symbol2scm ("parser"), + parser->self_scm ()); parser->parse_string (ly_scm2string (ly_code)); parser = 0; return SCM_UNSPECIFIED; } +LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string", + 2, 0, 0, + (SCM parser_smob, SCM ly_code), + "Parse the string LY_CODE with PARSER_SMOB." + "Upon failure, throw @code{ly-file-failed} key.") +{ +#if 0 + SCM_ASSERT_TYPE (ly_c_parser_p (parser), music, SCM_ARG1, __FUNCTION__, "parser"); +#endif + SCM_ASSERT_TYPE (ly_c_string_p (ly_code), ly_code, SCM_ARG1, __FUNCTION__, "string"); + +#if 1 + My_lily_parser *parser = unsmob_my_lily_parser (parser_smob); +#else + /* New parser, copy vars but no state? */ +#endif + parser->parse_string (ly_scm2string (ly_code)); + + return SCM_UNSPECIFIED; +} + static Music_output_def* get_paper (My_lily_parser *parser) { diff --git a/scm/lily.scm b/scm/lily.scm index 5ca36f86f8..f217072603 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -45,6 +45,8 @@ (define-public point-and-click #f) +(define-public parser #f) + (define-public (lilypond-version) (string-join (map (lambda (x) (if (symbol? x) -- 2.39.5