]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lily-parser.cc
(triangle): add s to 0triangle.
[lilypond.git] / lily / lily-parser.cc
index 355791e7191c0865ab5560d88d3f37b9ec4ad887..fd982bc65928fd4b7abba84f18b44f1a655444f3 100644 (file)
@@ -7,14 +7,16 @@
        Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
+#include "lily-parser.hh"
+
 #include "book.hh"
+#include "lilypond-key.hh"
 #include "file-name.hh"
 #include "file-path.hh"
 #include "lily-version.hh"
 #include "ly-module.hh"
 #include "main.hh"
 #include "lily-lexer.hh"
-#include "lily-parser.hh"
 #include "output-def.hh"
 #include "paper-book.hh"
 #include "parser.hh"
@@ -22,7 +24,6 @@
 #include "source.hh"
 #include "warn.hh"
 
-
 Lily_parser::Lily_parser (Sources *sources)
 {
   book_count_ = 0;
@@ -101,10 +102,15 @@ Lily_parser::parse_file (String init, String name, String out_name)
 
   lexer_->new_input (init, sources_);
 
+  File_name f (name);
+  String s = global_path.find (f.base_ + ".twy");
+  s = gulp_file_to_string (s, false);
+  scm_eval_string (scm_makfrom0str (s.to_str0 ()));
+
   /* Read .ly IN_FILE, lex, parse, write \score blocks from IN_FILE to
      OUT_FILE (unless IN_FILE redefines output file name).  */
   do_yyparse ();
-  
+
   if (!define_spots_.is_empty ())
     {
       define_spots_.top ().warning (_ ("Braces don't match"));
@@ -140,8 +146,9 @@ Lily_parser::parse_string (String ly_code)
   
   if (!define_spots_.is_empty ())
     {
-      define_spots_.top ().warning (_ ("Braces don't match"));
-      error_level_ = 1;
+      if (define_spots_.is_empty()
+         && !error_level_ )
+       programming_error ("Braces don't match, but error_level_ not set.");
     }
 
   error_level_ = error_level_ | lexer_->error_level_;
@@ -281,7 +288,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
       Sources sources;
       sources.set_path (&global_path);
   
-      progress_indication (_f ("Now processing `%s'", file_name.to_str0 ()));
+      progress_indication (_f ("Processing `%s'", file_name.to_str0 ()));
       progress_indication ("\n");
 
       Lily_parser *parser = new Lily_parser (&sources);
@@ -351,7 +358,7 @@ LY_DEFINE (ly_parser_lookup, "ly:parser-lookup",
   SCM_ASSERT_TYPE (scm_is_symbol (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
   SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");  
 
-  SCM val= parser->lexer_->lookup_identifier (ly_scm2string (scm_symbol_to_string (symbol)));
+  SCM val = parser->lexer_->lookup_identifier (ly_scm2string (scm_symbol_to_string (symbol)));
   if (val != SCM_UNDEFINED)
     return val;
   else
@@ -418,6 +425,8 @@ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score",
   Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
   Score *score = unsmob_score (score_smob);
 
+  Object_key * key = new Lilypond_general_key (0, score->user_key_, 0);
+  
   if (score->error_found_)
     return SCM_UNSPECIFIED;
   
@@ -438,16 +447,19 @@ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score",
   for (int i = 0; i < score->defs_.size (); i++)
     default_rendering (score->get_music (), score->defs_[i]->self_scm (),
                       paper,
-                      header, os);
+                      header, os,
+                      key->self_scm ());
 
   if (score->defs_.is_empty ())
     {
       Output_def *layout = get_layout (parser);
       default_rendering (score->get_music(), layout->self_scm (),
                         get_paper (parser)->self_scm (),
-                        header, os);
+                        header, os, key->self_scm ());
       scm_gc_unprotect_object (layout->self_scm ());
     }
+
+  scm_gc_unprotect_object (key->self_scm ());
   return SCM_UNSPECIFIED;
 }
 
@@ -491,8 +503,8 @@ LY_DEFINE (ly_parser_print_book, "ly:parser-print-book",
   (*c)++;
 
   Output_def *layout = get_layout (parser);
-
   Paper_book* pb = book->process (outname.to_string (), layout);
+  
   if (pb)
     {
       pb->output (outname.to_string ());