]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4421/1: Deal sensibly with non-existent parser/location
authorDavid Kastrup <dak@gnu.org>
Tue, 2 Jun 2015 09:51:32 +0000 (11:51 +0200)
committerDavid Kastrup <dak@gnu.org>
Tue, 9 Jun 2015 13:55:30 +0000 (15:55 +0200)
This concerns ly:parser-error and note-name->lily-string, and in
consequence also display-lily-music.

lily/lily-parser-scheme.cc
scm/define-music-display-methods.scm

index 6e706f29f711abfc5a33c23f40b9705d1c4eaab0..b9e0407d46920afac0d0c2af3b5f4737e5d9f404 100644 (file)
@@ -291,21 +291,32 @@ LY_DEFINE (ly_parser_output_name, "ly:parser-output-name",
 
 LY_DEFINE (ly_parser_error, "ly:parser-error",
            2, 1, 0, (SCM parser, SCM msg, SCM input),
-           "Display an error message and make the parser fail.")
+           "Display an error message and make the parser fail."
+           "  When @var{parser} is @code{##f}, raise a suitable other error.")
 {
-  LY_ASSERT_SMOB (Lily_parser, parser, 1);
+  if (scm_is_true (parser))
+    LY_ASSERT_SMOB (Lily_parser, parser, 1);
   Lily_parser *p = unsmob<Lily_parser> (parser);
 
   LY_ASSERT_TYPE (scm_is_string, msg, 2);
   string s = ly_scm2string (msg);
 
   Input *i = unsmob<Input> (input);
-  if (i)
-    p->parser_error (*i, s);
+  if (p)
+    {
+      if (i)
+        p->parser_error (*i, s);
+      else
+        p->parser_error (s);
+    }
   else
-    p->parser_error (s);
-
-  return parser;
+    {
+      if (i)
+        i->non_fatal_error (s);
+      else
+        scm_misc_error ("ly:parser-error", "~A", scm_list_1 (msg));
+    }
+  return SCM_UNSPECIFIED;
 }
 
 LY_DEFINE (ly_parser_clear_error, "ly:parser-clear-error",
index 2d2a178857ba97ccb414deef68b23fbb0c8227fd..e2412367b81f642629dd4ca5a4a2f3b854d01a4b 100644 (file)
@@ -89,10 +89,11 @@ expression."
   (define (pitch= pitch1 pitch2)
     (and (= (ly:pitch-notename pitch1) (ly:pitch-notename pitch2))
          (= (ly:pitch-alteration pitch1) (ly:pitch-alteration pitch2))))
-  (let ((result (rassoc ly-pitch (ly:parser-lookup parser 'pitchnames) pitch=)))
-    (if result
-        (car result)
-        #f)))
+  (let* ((pitches (if parser (ly:parser-lookup parser 'pitchnames)
+                      (assoc-get (string->symbol default-language)
+                                 language-pitch-names '())))
+         (result (rassoc ly-pitch pitches pitch=)))
+    (and result (car result))))
 
 (define-public (octave->lily-string pitch)
   (let ((octave (ly:pitch-octave pitch)))