lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parser: more specific error messages; issue 3300 (issue 8506043)


From: k-ohara5a5a
Subject: Re: parser: more specific error messages; issue 3300 (issue 8506043)
Date: Mon, 08 Apr 2013 17:58:43 +0000

Reviewers: dak,

Message:
On 2013/04/08 16:05:20, dak wrote:

Here is the problem I have with this change: for
\new Lyrics { hello, Dolly }
the error message will become quite less helpful.

Yep.  Version 2.16 printed the same "unexpected STRING".

I see no safe short-term way to give the parser a clue that \new Lyrics
probably wanted \lyricmode (given that users are allowed to change
contexts).  The best I can think of is
   "unexpected string (without \\lyricmode)"

Apropos: do you have an example of where your refactoring leads to
a better error behavior (independent from the error message text
itself)?

No. Finding the errors earlier simply allows shorter accurate messages.
(remember the struggle to find a non-confusing message for issue 3049)

Description:
parser: more specific error messages; issue 3300

Please review this at https://codereview.appspot.com/8506043/

Affected files:
  M lily/parser.yy


Index: lily/parser.yy
diff --git a/lily/parser.yy b/lily/parser.yy
index cda631865443a1fe04b820d56b223f4658604094..6b5e8cdd2bce0b9bb86078e1c56c5b9249ce782c 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -2320,7 +2320,8 @@ scalar:
        | SCM_IDENTIFIER
        | bare_number
        | FRACTION
-       | lyric_element
+       | STRING
+       | full_markup
        ;

 scalar_closed:
@@ -2328,7 +2329,8 @@ scalar_closed:
        | SCM_IDENTIFIER
        | bare_number
        | FRACTION
-       | lyric_element
+       | STRING
+       | full_markup
        ;


@@ -3100,9 +3102,13 @@ simple_chord_elements:

 lyric_element:
        full_markup {
+               if (!parser->lexer_->is_lyric_state ())
+                       parser->parser_error (@1, _ ("unexpected markup"));
                $$ = $1;
        }
        | STRING {
+               if (!parser->lexer_->is_lyric_state ())
+ parser->parser_error (@1, _ ("unexpected string, or unrecognized note-name"));
                $$ = $1;
        }
        | LYRIC_ELEMENT
@@ -3110,8 +3116,6 @@ lyric_element:

 lyric_element_music:
        lyric_element optional_notemode_duration post_events {
-               if (!parser->lexer_->is_lyric_state ())
-                       parser->parser_error (@1, _ ("have to be in Lyric mode for 
lyrics"));
                $$ = MAKE_SYNTAX ("lyric-event", @$, $1, $2);
                if (scm_is_pair ($3))
                        unsmob_music ($$)->set_property





reply via email to

[Prev in Thread] Current Thread [Next in Thread]