X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Flily-parser-scheme.cc;h=83c3826dbdf7bf625f4becc951695b18e19a2d01;hb=8c84fff95418b3797c5c866fa569f9bb6f786949;hp=7c6650799751039f84e5d4de681a00619c63899a;hpb=cfb0511f85f9691bfeebecaaaf962f7e0feb3ce0;p=lilypond.git diff --git a/lily/lily-parser-scheme.cc b/lily/lily-parser-scheme.cc index 7c66507997..83c3826dbd 100644 --- a/lily/lily-parser-scheme.cc +++ b/lily/lily-parser-scheme.cc @@ -11,7 +11,6 @@ #include "file-name-map.hh" #include "file-name.hh" #include "file-path.hh" -#include "input.hh" #include "international.hh" #include "lily-lexer.hh" #include "lily-parser.hh" @@ -110,11 +109,12 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", exit (2); } - if ((file_name != "-") && global_path.find (file_name).empty ()) + + bool error = false; + if ((file_name != "-") && file_name.empty ()) { - warning (_f ("can't find file: `%s'", file_name)); - scm_throw (ly_symbol2scm ("ly-file-failed"), - scm_list_1 (scm_makfrom0str (file_name.c_str ()))); + warning (_f ("can't find file: `%s'", file)); + error = true; } else { @@ -129,14 +129,20 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", parser->parse_file (init, file_name, out_file); - bool error = parser->error_level_; + error = parser->error_level_; + + parser->clear (); parser->unprotect (); - parser = 0; - if (error) - /* TODO: pass renamed input file too. */ - scm_throw (ly_symbol2scm ("ly-file-failed"), - scm_list_1 (scm_makfrom0str (file_name.c_str ()))); } + + /* + outside the if-else to ensure cleanup fo Sources object, + */ + if (error) + /* TODO: pass renamed input file too. */ + scm_throw (ly_symbol2scm ("ly-file-failed"), + scm_list_1 (scm_makfrom0str (file_name.c_str ()))); + return SCM_UNSPECIFIED; } @@ -157,7 +163,15 @@ LY_DEFINE (ly_parse_string, "ly:parse-string", return SCM_UNSPECIFIED; } -LY_DEFINE (ly_clone_parser, "ly:clone-parser", +LY_DEFINE (ly_parser_lexer, "ly:parser-lexer", + 1, 0, 0, (SCM parser_smob), + "Return the lexer for PARSER_SMOB.") +{ + Lily_parser *parser = unsmob_lily_parser (parser_smob); + return parser->lexer_->self_scm (); +} + +LY_DEFINE (ly_parser_clone, "ly:parser-clone", 1, 0, 0, (SCM parser_smob), "Return a clone of PARSER_SMOB.") {