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",
(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)))