From 4c874ac08382675045e768f5304e12703677d7d6 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:43:19 +0000 Subject: [PATCH] lilypond-0.0.63 --- lib/includable-lexer.cc | 11 ++++++++--- lib/include/includable-lexer.hh | 7 +++++-- lily/my-lily-parser.cc | 9 ++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/includable-lexer.cc b/lib/includable-lexer.cc index 2f8d33f461..61f1c1b613 100644 --- a/lib/includable-lexer.cc +++ b/lib/includable-lexer.cc @@ -21,9 +21,11 @@ Includable_lexer::new_input(String s, Sources * global_sources) { Source_file * sl = global_sources->get_file_l(s); if (!sl) { - LexerError("can't find file"); + LexerError("Can't find file `" + s+ "'"); return; - } + } else + + char_count_stack_.push(0); if (yy_current_buffer) state_stack_.push(yy_current_buffer); @@ -79,5 +81,8 @@ Includable_lexer::add_lexed_char(int count) Source_file* Includable_lexer::source_file_l()const { - return include_stack_.top(); + if (include_stack_.empty()) + return 0; + else + return include_stack_.top(); } diff --git a/lib/include/includable-lexer.hh b/lib/include/includable-lexer.hh index a5416ef45a..a84f736c48 100644 --- a/lib/include/includable-lexer.hh +++ b/lib/include/includable-lexer.hh @@ -1,5 +1,5 @@ /* - includable-lexer.hh -- declare + includable-lexer.hh -- declare Includable_lexer source file of the LilyPond music typesetter @@ -9,8 +9,10 @@ #ifndef INCLUDABLE_LEXER_HH #define INCLUDABLE_LEXER_HH -#include "string.hh" + #include + +#include "string.hh" #include "varray.hh" #include "fproto.hh" #include "proto.hh" @@ -28,6 +30,7 @@ protected: Array include_stack_; Array char_count_stack_; public: + Source_file* source_file_l()const; void new_input(String s,Sources*); Includable_lexer(); diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index 5d46c7d5b3..5389803e63 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -36,6 +36,7 @@ My_lily_parser::set_debug() lexer_p_->set_debug( !monitor->silence(s+"Lexer") && check_debug); #endif } + void My_lily_parser::print_declarations() { @@ -60,11 +61,17 @@ My_lily_parser::do_init_file() void My_lily_parser::parse_file(String init, String s) { - *mlog << "Parsing ... "; lexer_p_ = new My_lily_lexer; init_str_ = init; + + + *mlog << "Parsing ... "; lexer_p_->new_input(s, source_l_); + if (!lexer_p_->source_file_l()) { + warning("Can not find toplevel file. Ignoring " + s); + return; + } do_yyparse(); print_declarations(); -- 2.39.5