]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/lexer.ll: accept EOF in all states.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 1 Sep 2006 11:57:55 +0000 (11:57 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 1 Sep 2006 11:57:55 +0000 (11:57 +0000)
* lily/tempo-performer.cc (Tempo_performer): initialize last_tempo_.

* lily/source-file.cc (Source_file): always 0-terminate character
array, to prevent Flex from barfing.

* lily/global-context.cc (get_output): robustness: don't crash if
no Score context found.

ChangeLog
lily/global-context-scheme.cc
lily/global-context.cc
lily/lexer.ll
lily/lily-parser-scheme.cc
lily/lily-parser.cc
lily/parser.yy
lily/source-file.cc
lily/tempo-performer.cc
scm/parser-ly-from-scheme.scm

index 9f753356b513c4f6c369dbd36a899c31267e2d61..076b9ea9a18337de682832ad3e76b20a2cd310fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2006-09-01  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * lily/lexer.ll: accept EOF in all states.
+
+       * lily/tempo-performer.cc (Tempo_performer): initialize last_tempo_.
+
+       * lily/source-file.cc (Source_file): always 0-terminate character
+       array, to prevent Flex from barfing.
+
+       * lily/global-context.cc (get_output): robustness: don't crash if
+       no Score context found.
+
        * lily/include/book.hh (class Book): idem.
 
        * lily/include/context-def.hh (struct Context_def): idem.
index 273ae10b1d27de99abc899e782bcba432c7cabe8..219dc267c1d3762f0a0c19f314f415833001f976 100644 (file)
@@ -27,7 +27,10 @@ LY_DEFINE (ly_format_output, "ly:format-output",
 
   SCM output = g->get_output ();
   progress_indication ("\n");
-  unsmob_music_output (output)->process ();
+
+  if (Music_output *od = unsmob_music_output (output))
+    od->process ();
+  
   return output;
 }
 
index 40fe3a61cdb7a0b657398fc459bde7a7e6a87ed7..ddcec501ba4ec521d56176387d004405210fd96e 100644 (file)
@@ -114,7 +114,11 @@ Global_context::get_score_context () const
 SCM
 Global_context::get_output ()
 {
-  return get_score_context ()->get_property ("output");
+  Context * c = get_score_context ();
+  if (c)
+    return c->get_property ("output");
+  else
+    return SCM_EOL;
 }
 
 void
index 98332a1eb3679fe26fb07d619ed37a2c90f1b9f1..178ea88e97eb9d070e22359aa0458f2487158fab 100644 (file)
@@ -227,6 +227,7 @@ BOM_UTF8    \357\273\277
        int i;
        sscanf (YYText (), "%d", &i);
 
+//     this->set_debug (1); 
        yy_pop_state ();
        this->here_input ().get_source_file ()->set_line (here_input ().start (), i);
 }
@@ -550,7 +551,7 @@ BOM_UTF8    \357\273\277
        }
 }
 
-<<EOF>> {
+<*><<EOF>> {
        if (is_main_input_)
        {
                is_main_input_ = false;
index 7c6650799751039f84e5d4de681a00619c63899a..30062e14ff61706141e529a30a20e48a8898ca8f 100644 (file)
@@ -130,8 +130,8 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
       parser->parse_file (init, file_name, out_file);
 
       bool error = parser->error_level_;
+
       parser->unprotect ();
-      parser = 0;
       if (error)
        /* TODO: pass renamed input file too.  */
        scm_throw (ly_symbol2scm ("ly-file-failed"),
index 65160851e16ee39ceb01f7805f7112fd228676b3..1f073fb07a3b7cff5a0bf60efe519fd16b3b46bf 100644 (file)
@@ -141,7 +141,6 @@ Lily_parser::parse_string (string ly_code)
   lexer_->main_input_name_ = "<string>";
   lexer_->is_main_input_ = true;
 
-  set_yydebug (0);
   lexer_->new_input (lexer_->main_input_name_, ly_code, sources_);
 
   SCM mod = lexer_->set_current_scope ();
index dff3ee921df7746974d42a129b52594a1ea464ed..ef215c327a2cf24e024abff0e422be17e9dece18 100644 (file)
@@ -9,6 +9,7 @@
 
 %{
 
+#define YYDEBUG 1
 #define YYERROR_VERBOSE 1
 #define YYPARSE_PARAM my_lily_parser
 #define YYLEX_PARAM my_lily_parser
@@ -2324,11 +2325,9 @@ markup:
 %%
 
 void
-Lily_parser::set_yydebug (bool )
+Lily_parser::set_yydebug (bool x)
 {
-#if 0
-       yydebug = 1;
-#endif
+       yydebug = x;
 }
 
 void
index cead386ae9166eddde96d50be24ce949baac4b0e..f1dd4a36942ed73d973f5f139795f4ae23ef0512 100644 (file)
@@ -38,10 +38,11 @@ Source_file::load_stdin ()
   int c;
   while ((c = fgetc (stdin)) != EOF)
     characters_.push_back (c);
-
-  characters_.push_back (0);
 }
 
+/*
+  return contents of FILENAME. *Not 0-terminated!* 
+ */
 vector<char>
 gulp_file (string filename, int desired_size)
 {
@@ -101,9 +102,10 @@ Source_file::Source_file (string filename, string data)
   name_ = filename;
 
   characters_.resize (data.length ());
-
   copy (data.begin (), data.end (), characters_.begin ());
 
+  characters_.push_back (0);
+  
   init_port ();
 
   for (vsize i = 0; i < characters_.size (); i++)
@@ -122,9 +124,10 @@ Source_file::Source_file (string filename_string)
   else
     {
       characters_ = gulp_file (filename_string, -1);
-      characters_.push_back (0);
     }
 
+  characters_.push_back (0);
+
   init_port ();
 
   for (vsize i = 0; i < characters_.size (); i++)
@@ -198,7 +201,6 @@ Source_file::name_string () const
 Source_file::~Source_file ()
 {
   delete istream_;
-  istream_ = 0;
 }
 
 Slice
index 19a453f01bbb8cf6240ec196c563320bec19e3c8..23ea8fa74f459eebdd40feff3e22dba3daf35e64 100644 (file)
@@ -38,6 +38,7 @@ Tempo_performer::derived_mark () const
 
 Tempo_performer::Tempo_performer ()
 {
+  last_tempo_ = SCM_EOL;
   audio_ = 0;
 }
 
index d7a83a1f4d513d8d496f17ca77a616b629c6fc23..9d2b3b5d47e000468ec82308eb3c598a6221316f 100644 (file)
@@ -17,8 +17,9 @@
                                                                         (char->integer #\0)))))
                                                  (string->list (number->string var-idx)))))))))
 
-(define-public (ly:parse-string-result str parser)
+(define-public (parse-string-result str parser)
   "Parse `str', which is supposed to contain a music expression."
+
   (ly:parser-parse-string
    parser
    (format #f "parseStringResult = \\notemode { ~a }" str))
@@ -81,6 +82,6 @@ character."
          ,@(map (lambda (binding)
                   `(ly:parser-define! parser-clone ',(car binding) ,(cdr binding)))
                 (reverse bindings))
-         (ly:parse-string-result ,lily-string parser-clone)))))
+         (parse-string-result ,lily-string parser-clone)))))
 
 (read-hash-extend #\{ read-lily-expression)