lilypond-devel
[Top][All Lists]
Advanced

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

Re: Issue 2728: count pairs of brackets (issue 6450114)


From: dak
Subject: Re: Issue 2728: count pairs of brackets (issue 6450114)
Date: Sun, 12 Aug 2012 14:50:21 +0000

Reviewers: Graham Percival,

Message:
On 2012/08/12 14:32:01, Graham Percival wrote:
LGTM, and wow it's amazing that such an improvement in usability can
come from
so few lines of code!

It is probably even more amazing for how long people put up with the old
behavior.

Description:
Issue 2728: count pairs of brackets

What this actually does is parse the main input (starting from
init.ly) in a cloned parser.

This delivers useful error messages in case that the main input is
incomplete.

It currently is based off the code for

Issue 2729: When cloning a lexer/parser, don't copy the scopes.

Please review this at http://codereview.appspot.com/6450114/

Affected files:
  M lily/lexer.ll
  M lily/lily-parser.cc
  M lily/parser.yy


Index: lily/lexer.ll
diff --git a/lily/lexer.ll b/lily/lexer.ll
index 57b9a599678027aa95bde7c06854beeeb65893f8..9fb4cb6d558429e8d76811d6cb2922ab1da9f6d0 100644
--- a/lily/lexer.ll
+++ b/lily/lexer.ll
@@ -694,7 +694,7 @@ BOM_UTF8    \357\273\277
                   reflect after.
                */
                is_main_input_ = include_stack_.size () > 2;
-               if (!close_input ())
+               if (!close_input () || !is_main_input_)
                /* Returns YY_NULL */
                        yyterminate ();
        }
Index: lily/lily-parser.cc
diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc
index cec4893d8db0b9cab96c0404e34cecf088bf28c7..35d7e922e183435473ed37168491176ca0b5776b 100644
--- a/lily/lily-parser.cc
+++ b/lily/lily-parser.cc
@@ -121,7 +121,9 @@ Lily_parser::parse_file (string init, string name, string out_name)
      OUT_FILE (unless IN_FILE redefines output file name).  */

   SCM mod = lexer_->set_current_scope ();
-  do_yyparse ();
+  do {
+    do_yyparse ();
+  } while (!lexer_->is_clean ());

   /*
     Don't mix cyclic pointers with weak tables.
Index: lily/parser.yy
diff --git a/lily/parser.yy b/lily/parser.yy
index fc9aea63be73c95966a31ebe207b12228fdff2bf..35252bcb6e84f9fba33a6e6f2dbe43ef265286a0 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -240,6 +240,7 @@ void set_music_properties (Music *p, SCM a);
 */

 /* Keyword tokens with plain escaped name.  */
+%token END_OF_FILE 0 "end of input"
 %token ACCEPTS "\\accepts"
 %token ADDLYRICS "\\addlyrics"
 %token ALIAS "\\alias"





reply via email to

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