]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/my-lily-parser.cc
* lily/new-slur.cc (avoid_staff_line): new function: avoid
[lilypond.git] / lily / my-lily-parser.cc
index 1abe0fe85a9f3c62a8a8619bd670d424c35a09af..36e11abf0363344847759e836937ddafd5e60efb 100644 (file)
@@ -47,7 +47,8 @@ My_lily_parser::My_lily_parser (My_lily_parser const &src)
   last_beam_start_ = src.last_beam_start_;
 
   smobify_self ();
-  lexer_ = new My_lily_lexer (*src.lexer_);
+  if (src.lexer_)
+    lexer_ = new My_lily_lexer (*src.lexer_);
 }
 
 My_lily_parser::~My_lily_parser ()
@@ -85,6 +86,9 @@ void
 My_lily_parser::parse_file (String init, String name, String out_name)
 {
   lexer_ = new My_lily_lexer (sources_);
+  // TODO: use $parser 
+  lexer_->set_identifier (ly_symbol2scm ("parser"),
+                         self_scm ());
   output_basename_ = out_name;
   
   lexer_->main_input_name_ = name;
@@ -117,6 +121,14 @@ My_lily_parser::parse_string (String ly_code)
   lexer_ = (parent == 0 ? new My_lily_lexer (sources_)
            : new My_lily_lexer (*parent));
 
+
+  SCM oldmod = scm_current_module ();
+  scm_set_current_module (ly_car (lexer_->scopes_));
+  
+  // TODO: use $parser 
+  lexer_->set_identifier (ly_symbol2scm ("parser"),
+                         self_scm ());
+  
   lexer_->main_input_name_ = "<string>";
   lexer_->main_input_b_ = true;
 
@@ -144,6 +156,7 @@ My_lily_parser::parse_string (String ly_code)
       parent->main_input_b_ = lexer_->main_input_b_;
     }
 
+  scm_set_current_module (oldmod);
   delete lexer_;
   lexer_ = 0;
 }
@@ -235,12 +248,16 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
   SCM_ASSERT_TYPE (ly_c_string_p (name), name, SCM_ARG1, __FUNCTION__, "string");
   char const *file = SCM_STRING_CHARS (name);
   char const *extensions[] = {"ly", "", 0};
+
   String file_name = global_path.find (file, extensions);
-  
+
   /* By default, use base name of input file for output file name,
      write output to cwd; do not use root and directory parts of input
      file name.  */
   File_name out_file_name (file_name);
+
+  global_path.append (out_file_name.dir_);
+  
   out_file_name.ext_ = "";
   out_file_name.root_ = "";
   out_file_name.dir_ = "";
@@ -280,9 +297,6 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
 
       My_lily_parser *parser = new My_lily_parser (&sources);
 
-      // TODO: use $parser 
-      parser->lexer_->set_identifier (ly_symbol2scm ("parser"),
-                                     parser->self_scm ());
       parser->parse_file (init, file_name, out_file);
 
       bool error = parser->error_level_;
@@ -332,7 +346,6 @@ LY_DEFINE (ly_parser_define, "ly:parser-define",
   SCM_ASSERT_TYPE (ly_c_symbol_p (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
   SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");  
 
-
   parser->lexer_->set_identifier (scm_symbol_to_string (symbol), val);
   return SCM_UNSPECIFIED;
 }