LEFT | RIGHT |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 (current_dir.length () ? (current_dir + PATHSEP) : "") + source
s->path_->to_string ().c_str ()); | 74 (current_dir.length () ? (current_dir + PATHSEP) : "") + source
s->path_->to_string ().c_str ()); |
75 LexerError (msg.c_str ()); | 75 LexerError (msg.c_str ()); |
76 return; | 76 return; |
77 } | 77 } |
78 file_name_strings_.push_back (file->name_string ()); | 78 file_name_strings_.push_back (file->name_string ()); |
79 | 79 |
80 char_count_stack_.push_back (0); | 80 char_count_stack_.push_back (0); |
81 if (yy_current_buffer) | 81 if (yy_current_buffer) |
82 state_stack_.push_back (yy_current_buffer); | 82 state_stack_.push_back (yy_current_buffer); |
83 | 83 |
84 if (is_loglevel (LOG_DEBUG)) | 84 debug_output (string (state_stack_.size (), ' ') // indentation! |
85 { | 85 + string ("[") + file->name_string ()); |
86 string spaces = ""; | |
87 for (size_t i = 0; i < state_stack_.size (); i++) | |
88 spaces += " "; | |
89 debug_output (spaces + string ("[") + file->name_string ()); | |
90 } | |
91 | 86 |
92 include_stack_.push_back (file); | 87 include_stack_.push_back (file); |
93 | 88 |
94 /* Ugh. We'd want to create a buffer from the bytes directly. | 89 /* Ugh. We'd want to create a buffer from the bytes directly. |
95 | 90 |
96 Whoops. The size argument to yy_create_buffer is not the | 91 Whoops. The size argument to yy_create_buffer is not the |
97 filelength but a BUFFERSIZE. Maybe this is why reading stdin fucks up. */ | 92 filelength but a BUFFERSIZE. Maybe this is why reading stdin fucks up. */ |
98 yy_switch_to_buffer (yy_create_buffer (file->get_istream (), YY_BUF_SIZE)); | 93 yy_switch_to_buffer (yy_create_buffer (file->get_istream (), YY_BUF_SIZE)); |
99 } | 94 } |
100 | 95 |
101 void | 96 void |
102 Includable_lexer::new_input (string name, string data, Sources *sources) | 97 Includable_lexer::new_input (string name, string data, Sources *sources) |
103 { | 98 { |
104 Source_file *file = new Source_file (name, data); | 99 Source_file *file = new Source_file (name, data); |
105 sources->add (file); | 100 sources->add (file); |
106 file_name_strings_.push_back (name); | 101 file_name_strings_.push_back (name); |
107 | 102 |
108 char_count_stack_.push_back (0); | 103 char_count_stack_.push_back (0); |
109 if (yy_current_buffer) | 104 if (yy_current_buffer) |
110 state_stack_.push_back (yy_current_buffer); | 105 state_stack_.push_back (yy_current_buffer); |
111 | 106 |
112 if (is_loglevel (LOG_DEBUG)) | 107 debug_output (string (state_stack_.size (), ' ') // indentation! |
113 { | 108 + string ("[") + name); |
114 string spaces = ""; | |
115 for (size_t i = 0; i < state_stack_.size (); i++) | |
116 spaces += " "; | |
117 debug_output (spaces + string ("[") + name); | |
118 } | |
119 include_stack_.push_back (file); | 109 include_stack_.push_back (file); |
120 | 110 |
121 yy_switch_to_buffer (yy_create_buffer (file->get_istream (), YY_BUF_SIZE)); | 111 yy_switch_to_buffer (yy_create_buffer (file->get_istream (), YY_BUF_SIZE)); |
122 } | 112 } |
123 | 113 |
124 void | 114 void |
125 Includable_lexer::add_string_include (string data) | 115 Includable_lexer::add_string_include (string data) |
126 { | 116 { |
127 pending_string_includes_.push_back (data); | 117 pending_string_includes_.push_back (data); |
128 } | 118 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 close_input (); | 156 close_input (); |
167 } | 157 } |
168 | 158 |
169 Source_file * | 159 Source_file * |
170 Includable_lexer::get_source_file () const | 160 Includable_lexer::get_source_file () const |
171 { | 161 { |
172 if (include_stack_.empty ()) | 162 if (include_stack_.empty ()) |
173 return 0; | 163 return 0; |
174 return include_stack_.back (); | 164 return include_stack_.back (); |
175 } | 165 } |
LEFT | RIGHT |