]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/lexer.ll: Add \sourcefileline command
authorErik Sandberg <mandolaerik@gmail.com>
Mon, 7 Aug 2006 09:31:10 +0000 (09:31 +0000)
committerErik Sandberg <mandolaerik@gmail.com>
Mon, 7 Aug 2006 09:31:10 +0000 (09:31 +0000)
* scripts/lilypond-book.py: insert \sourcefileline command in
output, so lilypond error messages refer to the spot in the
original .lytex / .itely sourcefile.

ChangeLog
lily/include/source-file.hh
lily/lexer.ll
lily/source-file.cc
scripts/lilypond-book.py

index 4e400a8e1e37a87f7a2bfca8fb657d7cf1896057..4e060b01310eac8c36092ea558a5512e0a96ef5d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-08-07  Erik Sandberg  <mandolaerik@gmail.com>
+
+       * lily/lexer.ll, lily/source-file.cc: Add \sourcefileline command
+
+       * scripts/lilypond-book.py: insert \sourcefileline command in
+       output, so lilypond error messages refer to the spot in the
+       original .lytex / .itely sourcefile.
+
 2006-08-04  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
        * lily/spacing-loose-columns.cc (set_loose_columns): oops: use
        conversion of files older than 1.3.117.
        Fix escape error in the description for 2.9.6.
 
-2006-08-02  Han-Wen Nienhuys  <hanwen@lilypond.org>
+2006-08-02  Erik Sandberg  <mandolaerik@gmail.com>
+
+       * lily/*-engraver.cc: convert all try_music functions to listen_*
+       functions.
 
-       * lily/*-engraver.cc: convert all try_music functions in
-       *-engraver.cc. (Patch by Erik S.; please elaborate)
+       * lily/piano-pedal-engraver.cc: some additional cleanups: use
+       enums to represent pedal types, and calculate more data statically.
+
+       * scm/part-combiner.scm (recording-group-emulate): create a
+       softcoded substitute for recording-group-engraver.cc.
+
+       * lily/music.cc: make a common transpose function for events and
+       music
+
+       * ly/declarations-init.ly: change melisma/melismaEnd. Eliminates
+       ManualMelismaEvent, and obsoletes Melisma_translator.
+
+2006-08-02  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
        * input/test/instrument-name-align.ly: update version.
 
index dd88a2c65ae2255263dcf8c467bc7ec58120fed3..33b4051c4cc2e97190429acc3d1a1f7148d7f59a 100644 (file)
@@ -39,6 +39,7 @@ public:
   bool contains (char const *pos_str0) const;
   int length () const;
   virtual int get_line (char const *pos_str0) const;
+  void set_line (char const *pos_str0, int i);
   string name_string () const;
   string file_line_column_string (char const *str0) const;
 
@@ -66,6 +67,9 @@ public:
   SCM get_port () const;
   string name_;
 
+protected:
+  int line_offset_;
+
 private:
   vector<char*> newline_locations_;
   istream *istream_;
index c6be4382d47aae37b479091ebaf0506af7153554..2fd018ff1b2afa0ee6846d385057e7ff58ef3534 100644 (file)
@@ -112,6 +112,7 @@ SCM (* scm_parse_error_handler) (void *);
 %x markup
 %x notes
 %x quote
+%x sourcefileline
 %x sourcefilename
 %x version
 
@@ -191,6 +192,9 @@ BOM_UTF8    \357\273\277
 <INITIAL,chords,lyrics,notes,figures>\\sourcefilename{WHITE}*  {
        yy_push_state (sourcefilename);
 }
+<INITIAL,chords,lyrics,notes,figures>\\sourcefileline{WHITE}*  {
+       yy_push_state (sourcefileline);
+}
 <version>\"[^"]*\"     { /* got the version number */
        string s (YYText () + 1);
        s = s.substr (0, s.rfind ('\"'));
@@ -218,6 +222,15 @@ BOM_UTF8   \357\273\277
                     scm_makfrom0str (s.c_str ()));
 
 }
+
+<sourcefileline>{INT}  {
+       int i;
+       sscanf (YYText (), "%d", &i);
+
+       yy_pop_state ();
+       this->here_input ().get_source_file ()->set_line (here_input ().start (), i);
+}
+
 <version>.     {
        LexerError (_ ("quoted string expected after \\version").c_str ());
        yy_pop_state ();
@@ -226,6 +239,10 @@ BOM_UTF8   \357\273\277
        LexerError (_ ("quoted string expected after \\sourcefilename").c_str ());
        yy_pop_state ();
 }
+<sourcefileline>.      {
+       LexerError (_ ("integer expected after \\sourcefileline").c_str ());
+       yy_pop_state ();
+}
 <longcomment>{
        [^\%]*          {
        }
index 902baa0e47b4a50dec5a7a6f19062791daef3b0c..b44066f2673b8e598a63703624a67c661c1a3c34 100644 (file)
@@ -82,6 +82,7 @@ Source_file::Source_file (string filename, string data)
 {
   name_ = filename;
   istream_ = 0;
+  line_offset_ = 0;
   length_ = data.length ();
   contents_str0_ = string_copy (data);
   pos_str0_ = c_str ();
@@ -96,6 +97,7 @@ Source_file::Source_file (string filename_string)
 {
   name_ = filename_string;
   istream_ = 0;
+  line_offset_ = 0;
   contents_str0_ = 0;
 
   if (filename_string == "-")
@@ -329,7 +331,16 @@ Source_file::get_line (char const *pos_str0) const
 
   if (*pos_str0 == '\n')
     lo--;
-  return lo + 2;
+  return lo + 2 + line_offset_;
+}
+
+void
+Source_file::set_line (char const *pos_str0, int line)
+{
+  int current_line = get_line (pos_str0);
+  line_offset_ += line - current_line;
+
+  assert (line == get_line (pos_str0));
 }
 
 int
index 7861c524a568b6ef30b0497bbd6cdad1e4e17ff7..c81e103177ec269c8ea7c60bf13a415fe634ab17 100644 (file)
@@ -827,7 +827,9 @@ class Lilypond_snippet (Snippet):
         self.do_options (os, self.type)
 
     def ly (self):
-        return self.substring ('code')
+        contents = self.substring ('code')
+        return ('\\sourcefileline %d\n%s'
+                % (self.line_number - 1, contents))
 
     def full_ly (self):
         s = self.ly ()
@@ -1206,8 +1208,8 @@ class Lilypond_file_snippet (Lilypond_snippet):
         ## strip version string to make automated regtest comparisons
         ## across versions easier.
         contents = re.sub (r'\\version *"[^"]*"', '', contents)
-        
-        return ('\\sourcefilename \"%s\"\n%s'
+
+        return ('\\sourcefilename \"%s\"\n\\sourcefileline 0\n%s'
                 % (name, contents))
 
 snippet_type_to_class = {
@@ -1476,11 +1478,9 @@ def write_file_map (lys, name):
 #(ly:add-file-name-alist '(
 """)
     for ly in lys:
-        snippet_map.write ('("%s.ly" . "%s:%d (%s.ly)")\n'
+        snippet_map.write ('("%s.ly" . "%s")\n'
                  % (ly.basename (),
-                   name,
-                   ly.line_number,
-                   ly.basename ()))
+                   name))
 
     snippet_map.write ('))\n')