* lily/tempo-performer.cc (Tempo_performer): initialize last_tempo_.
* lily/source-file.cc (Source_file): always 0-terminate character
array, to prevent Flex from barfing.
* lily/global-context.cc (get_output): robustness: don't crash if
no Score context found.
2006-09-01 Han-Wen Nienhuys <hanwen@lilypond.org>
+ * lily/lexer.ll: accept EOF in all states.
+
+ * lily/tempo-performer.cc (Tempo_performer): initialize last_tempo_.
+
+ * lily/source-file.cc (Source_file): always 0-terminate character
+ array, to prevent Flex from barfing.
+
+ * lily/global-context.cc (get_output): robustness: don't crash if
+ no Score context found.
+
* lily/include/book.hh (class Book): idem.
* lily/include/context-def.hh (struct Context_def): idem.
SCM output = g->get_output ();
progress_indication ("\n");
- unsmob_music_output (output)->process ();
+
+ if (Music_output *od = unsmob_music_output (output))
+ od->process ();
+
return output;
}
SCM
Global_context::get_output ()
{
- return get_score_context ()->get_property ("output");
+ Context * c = get_score_context ();
+ if (c)
+ return c->get_property ("output");
+ else
+ return SCM_EOL;
}
void
int i;
sscanf (YYText (), "%d", &i);
+// this->set_debug (1);
yy_pop_state ();
this->here_input ().get_source_file ()->set_line (here_input ().start (), i);
}
}
}
-<<EOF>> {
+<*><<EOF>> {
if (is_main_input_)
{
is_main_input_ = false;
parser->parse_file (init, file_name, out_file);
bool error = parser->error_level_;
+
parser->unprotect ();
- parser = 0;
if (error)
/* TODO: pass renamed input file too. */
scm_throw (ly_symbol2scm ("ly-file-failed"),
lexer_->main_input_name_ = "<string>";
lexer_->is_main_input_ = true;
- set_yydebug (0);
lexer_->new_input (lexer_->main_input_name_, ly_code, sources_);
SCM mod = lexer_->set_current_scope ();
%{
+#define YYDEBUG 1
#define YYERROR_VERBOSE 1
#define YYPARSE_PARAM my_lily_parser
#define YYLEX_PARAM my_lily_parser
%%
void
-Lily_parser::set_yydebug (bool )
+Lily_parser::set_yydebug (bool x)
{
-#if 0
- yydebug = 1;
-#endif
+ yydebug = x;
}
void
int c;
while ((c = fgetc (stdin)) != EOF)
characters_.push_back (c);
-
- characters_.push_back (0);
}
+/*
+ return contents of FILENAME. *Not 0-terminated!*
+ */
vector<char>
gulp_file (string filename, int desired_size)
{
name_ = filename;
characters_.resize (data.length ());
-
copy (data.begin (), data.end (), characters_.begin ());
+ characters_.push_back (0);
+
init_port ();
for (vsize i = 0; i < characters_.size (); i++)
else
{
characters_ = gulp_file (filename_string, -1);
- characters_.push_back (0);
}
+ characters_.push_back (0);
+
init_port ();
for (vsize i = 0; i < characters_.size (); i++)
Source_file::~Source_file ()
{
delete istream_;
- istream_ = 0;
}
Slice
Tempo_performer::Tempo_performer ()
{
+ last_tempo_ = SCM_EOL;
audio_ = 0;
}
(char->integer #\0)))))
(string->list (number->string var-idx)))))))))
-(define-public (ly:parse-string-result str parser)
+(define-public (parse-string-result str parser)
"Parse `str', which is supposed to contain a music expression."
+
(ly:parser-parse-string
parser
(format #f "parseStringResult = \\notemode { ~a }" str))
,@(map (lambda (binding)
`(ly:parser-define! parser-clone ',(car binding) ,(cdr binding)))
(reverse bindings))
- (ly:parse-string-result ,lily-string parser-clone)))))
+ (parse-string-result ,lily-string parser-clone)))))
(read-hash-extend #\{ read-lily-expression)