--- /dev/null
+\version "2.13.29"
+
+\header {
+ texidoc = "@code{ly:parser-include-string} should include the current
+string like a file @code{\include}."
+}
+
+#(ly:parser-include-string parser "\\relative c' { a4 b c d }")
yy_switch_to_buffer (yy_create_buffer (file->get_istream (), YY_BUF_SIZE));
}
+void
+Includable_lexer::add_string_include (string data)
+{
+ pending_string_includes_.push_back (data);
+}
+
/** pop the inputstack. conceptually this is a destructor, but it
does not destruct the Source_file that Includable_lexer::new_input
creates. */
bool close_input ();
vector<Source_file*> include_stack_;
vector<int> char_count_stack_;
+ vector<string> pending_string_includes_;
public:
virtual void new_input (string s, Sources *);
void new_input (string name, string data, Sources *);
+ void add_string_include (string data);
char const *here_str0 () const;
};
void clear ();
void do_init_file ();
void do_yyparse ();
+ void include_string (string ly_code);
void parse_file (string init, string name, string out_name);
void parse_string (string ly_code);
void parser_error (string);
#include "interval.hh"
#include "lily-guile.hh"
#include "lily-lexer.hh"
+#include "lily-parser.hh"
#include "lilypond-version.hh"
#include "main.hh"
#include "music.hh"
yylval.scm = unpack_identifier(sval);
return identifier_type (yylval.scm);
}
+
+ for (size_t i = 0; i < pending_string_includes_.size (); i++)
+ new_input ("<included string>", pending_string_includes_[i],
+ parser_->sources_);
+ pending_string_includes_.clear ();
yylval.scm = sval;
return SCM_TOKEN;
return SCM_UNSPECIFIED;
}
+LY_DEFINE (ly_parser_include_string, "ly:parser-include-string",
+ 2, 0, 0, (SCM parser_smob, SCM ly_code),
+ "Include the string @var{ly-code} into the input stream"
+ " for @var{parser-smob}.")
+{
+ LY_ASSERT_SMOB (Lily_parser, parser_smob, 1);
+ Lily_parser *parser = unsmob_lily_parser (parser_smob);
+ LY_ASSERT_TYPE (scm_is_string, ly_code, 2);
+
+ parser->include_string (ly_scm2string (ly_code));
+
+ return SCM_UNSPECIFIED;
+}
+
LY_DEFINE (ly_parser_set_note_names, "ly:parser-set-note-names",
2, 0, 0, (SCM parser, SCM names),
"Replace current note names in @var{parser}."
error_level_ = error_level_ | lexer_->error_level_;
}
+void
+Lily_parser::include_string (string ly_code)
+{
+ lexer_->add_string_include (ly_code);
+}
+
void
Lily_parser::clear ()
{