From: fred Date: Wed, 28 Jan 1998 22:11:15 +0000 (+0000) Subject: lilypond-0.1.54 X-Git-Tag: release/1.5.59~6011 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=036f9a611b1a75a00c9d4b0eab263c1aeea7e70e;p=lilypond.git lilypond-0.1.54 --- diff --git a/lily/includable-lexer.cc b/lily/includable-lexer.cc new file mode 100644 index 0000000000..3728476203 --- /dev/null +++ b/lily/includable-lexer.cc @@ -0,0 +1,104 @@ +/* + includable-lexer.cc -- implement Includable_lexer + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "includable-lexer.hh" +#include "source-file.hh" +#include "source.hh" + +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +Includable_lexer::Includable_lexer () +{ + yy_current_buffer = 0; +} + +/** set the new input to s, remember old file. +*/ +void +Includable_lexer::new_input (String s, Sources * global_sources) +{ + Source_file * sl = global_sources->get_file_l (s); + if (!sl) + { + String msg =_ ("Can't find file `") + s+ "'"; + LexerError (msg.ch_C ()); + return; + } + + + char_count_stack_.push (0); + if (yy_current_buffer) + state_stack_.push (yy_current_buffer); + cout << "[" << s<istream_l (), YY_BUF_SIZE)); +} + +/** pop the inputstack. conceptually this is a destructor, but it + does not destruct the Source_file that Includable_lexer::new_input creates. */ +bool +Includable_lexer::close_input () +{ + include_stack_.pop (); + char_count_stack_.pop (); + cout << "]"<ch_C () + char_count_stack_.top (); +} + +Includable_lexer::~Includable_lexer () +{ + while (!include_stack_.empty ()) + { + close_input (); + } +} +/** + Since we don't create the buffer state from the bytes directly, we + don't know about the location of the lexer. Add this as a + YY_USER_ACTION */ +void +Includable_lexer::add_lexed_char (int count) +{ + char_count_stack_.top () += count; +} + +Source_file* +Includable_lexer::source_file_l () const +{ + if (include_stack_.empty ()) + return 0; + else + return include_stack_.top (); +}