#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"
if (dir != "" && dir != "." && dir != get_working_directory ())
{
global_path.prepend (get_working_directory ());
- message (_f ("Changing working directory to `%s'",
+ message (_f ("Changing working directory to: `%s'",
dir.c_str ()));
chdir (dir.c_str ());
}
if (init.length () && global_path.find (init).empty ())
{
- warning (_f ("can't find init file: `%s'", init));
+ warning (_f ("cannot find init file: `%s'", init));
warning (_f ("(search path: `%s')",
global_path.to_string ().c_str ()));
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 ("cannot find file: `%s'", file));
+ error = true;
}
else
{
parser->parse_file (init, file_name, out_file);
- bool error = parser->error_level_;
+ error = parser->error_level_;
+ parser->clear ();
parser->unprotect ();
- 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;
}
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.")
{