From c3e3f53e4380b024aecd64eeb985973fcb19bde4 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Fri, 10 Aug 2012 12:20:36 +0200 Subject: [PATCH] Issue 2728: count pairs of brackets What this actually does is exit the parser after the main file, then continue parsing the rest of the init file in a separate call of the parser. This delivers useful error messages in case that the main input is incomplete. --- lily/lexer.ll | 2 +- lily/lily-parser.cc | 4 +++- lily/parser.yy | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lily/lexer.ll b/lily/lexer.ll index 57b9a59967..9fb4cb6d55 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 (); } diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index c21180c31b..833fe6e158 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -120,7 +120,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. diff --git a/lily/parser.yy b/lily/parser.yy index fc9aea63be..35252bcb6e 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" -- 2.39.5