2004-08-01 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/include/my-lily-parser.hh: rename My_lily -> Lily
+
+ * make/mutopia-targets.make (local-WWW): don't make ps.gz
+ examples. They take huge amounts of space.
+
+ * Documentation/user/GNUmakefile: fix symlinks.
+
* input/test/lyrics-skip-notes.ly: remove
* input/test/stem-cross-staff.ly (noFlag): fold into manual
perl -i~ -pe 's!../lilypond-internals!lilypond-internals/!g' $(outdir)/lilypond.html
rm -f $(outdir)/lilypond/*.png $(outdir)/lilypond/*.ly
# symbolic links to save space
- -ln -sf $(outdir)/*.png $(outdir)/*.ly $(outdir)/lilypond/
+ (cd $(outdir)/lilypond/ ; ln -sf ../*.png ../*.ly . )
$(outdir)/lilypond-internals/lilypond-internals.html: $(outdir)/lilypond-internals.texi
mkdir -p $(dir $@)
break
list_item(f, 'See a picture of page %d' % pageno, 'png')
list_item(base + '.pdf', 'Print', 'PDF')
- list_item(base + '.ps.gz', 'Print', 'gzipped PostScript')
list_item(base + '.midi', 'Listen', 'MIDI')
list.write ("</ul>\n");
class Music_wrapper_iterator;
class Page;
class Pitch;
-class My_lily_lexer;
+class Lily_lexer;
class Note_performer;
class Output_property;
class Paper_book;
/*
- lexer.hh -- declare My_lily_lexer
+ lexer.hh -- declare Lily_lexer
source file of the GNU LilyPond music typesetter
#include "string.hh"
#include "duration.hh"
#include "pitch.hh"
-#include "protected-scm.hh"
+#include "smobs.hh"
bool busy_parsing ();
void kill_lexer ();
/*
TODO: this has a lot of SCM objects. Smobify me.
*/
-class My_lily_lexer : public Includable_lexer
+class Lily_lexer : public Includable_lexer
{
+ DECLARE_SMOBS(Lily_lexer,);
public:
- Protected_scm scopes_;
- Protected_scm encoding_;
+ SCM scopes_;
+ SCM encoding_;
private:
int lookup_keyword (String);
Sources *sources_;
/* Scheme hash tables with (oct name acc) values, and symbol keys. */
- Protected_scm chordmodifier_tab_;
- Protected_scm pitchname_tab_stack_;
+ SCM chordmodifier_tab_;
+ SCM pitchname_tab_stack_;
Keyword_table *keytable_;
int error_level_;
Input last_input_;
- My_lily_lexer (Sources*);
- My_lily_lexer (My_lily_lexer const&);
- ~My_lily_lexer ();
+ Lily_lexer (Sources*);
+ Lily_lexer (Lily_lexer const&);
+ ~Lily_lexer ();
int yylex ();
/*
- my-lily-parser.hh -- declare My_lily_parser
+ my-lily-parser.hh -- declare Lily_parser
source file of the GNU LilyPond music typesetter
TODO: interface is too complicated
*/
-class My_lily_parser
+class Lily_parser
{
- DECLARE_SMOBS (My_lily_parser, );
+ DECLARE_SMOBS (Lily_parser, );
friend int yyparse (void*);
Array<Input> define_spots_;
void set_last_pitch (Pitch const *);
public:
- My_lily_lexer *lexer_;
+ Lily_lexer *lexer_;
Sources *sources_;
Duration default_duration_;
String output_basename_;
bool ignore_version_b_;
SCM last_beam_start_;
- My_lily_parser (Sources *sources);
- My_lily_parser (My_lily_parser const&);
+ Lily_parser (Sources *sources);
+ Lily_parser (Lily_parser const&);
DECLARE_SCHEME_CALLBACK (paper_description, ());
void set_yydebug (bool);
};
-DECLARE_UNSMOB (My_lily_parser, my_lily_parser);
+DECLARE_UNSMOB (Lily_parser, my_lily_parser);
SCM ly_parse_file (SCM);
SCM ly_parse_string (SCM);
SCM ly_parser_bookify (SCM, SCM);
SCM ly_parser_scorify (SCM, SCM);
-Output_def *get_paper (My_lily_parser *parser);
-Output_def *get_midi (My_lily_parser *parser);
-Output_def *get_bookpaper (My_lily_parser *parser);
+Output_def *get_paper (Lily_parser *parser);
+Output_def *get_midi (Lily_parser *parser);
+Output_def *get_bookpaper (Lily_parser *parser);
#endif /* MY_LILY_PARSER_HH */
%option noyywrap
%option nodefault
%option debug
-%option yyclass="My_lily_lexer"
+%option yyclass="Lily_lexer"
%option stack
%option never-interactive
%option warn
%%
void
-My_lily_lexer::push_chord_state (SCM tab)
+Lily_lexer::push_chord_state (SCM tab)
{
pitchname_tab_stack_ = scm_cons (tab, pitchname_tab_stack_);
yy_push_state (chords);
}
void
-My_lily_lexer::push_figuredbass_state ()
+Lily_lexer::push_figuredbass_state ()
{
yy_push_state (figures);
}
void
-My_lily_lexer::push_initial_state ()
+Lily_lexer::push_initial_state ()
{
yy_push_state (INITIAL);
}
void
-My_lily_lexer::push_lyric_state ()
+Lily_lexer::push_lyric_state ()
{
yy_push_state (lyrics);
}
void
-My_lily_lexer::push_markup_state ()
+Lily_lexer::push_markup_state ()
{
yy_push_state (markup);
}
void
-My_lily_lexer::push_note_state (SCM tab)
+Lily_lexer::push_note_state (SCM tab)
{
pitchname_tab_stack_ = scm_cons (tab, pitchname_tab_stack_);
yy_push_state (notes);
}
void
-My_lily_lexer::pop_state ()
+Lily_lexer::pop_state ()
{
if (YYSTATE == notes || YYSTATE == chords)
pitchname_tab_stack_ = ly_cdr (pitchname_tab_stack_);
}
int
-My_lily_lexer::identifier_type (SCM sid)
+Lily_lexer::identifier_type (SCM sid)
{
int k = try_special_identifiers (&yylval.scm , sid);
return k >= 0 ? k : SCM_IDENTIFIER;
int
-My_lily_lexer::scan_escaped_word (String str)
+Lily_lexer::scan_escaped_word (String str)
{
// use more SCM for this.
}
int
-My_lily_lexer::scan_bare_word (String str)
+Lily_lexer::scan_bare_word (String str)
{
SCM sym = ly_symbol2scm (str.to_str0 ());
if ((YYSTATE == notes) || (YYSTATE == chords)) {
}
bool
-My_lily_lexer::is_note_state () const
+Lily_lexer::is_note_state () const
{
return YY_START == notes;
}
bool
-My_lily_lexer::is_chord_state () const
+Lily_lexer::is_chord_state () const
{
return YY_START == chords;
}
bool
-My_lily_lexer::is_lyric_state () const
+Lily_lexer::is_lyric_state () const
{
return YY_START == lyrics;
}
bool
-My_lily_lexer::is_figure_state () const
+Lily_lexer::is_figure_state () const
{
return YY_START == figures;
}
/*
- my-lily-lexer.cc -- implement My_lily_lexer
+ my-lily-lexer.cc -- implement Lily_lexer
source file of the GNU LilyPond music typesetter
};
-My_lily_lexer::My_lily_lexer (Sources *sources)
+Lily_lexer::Lily_lexer (Sources *sources)
{
keytable_ = new Keyword_table (the_key_tab);
encoding_ = SCM_EOL;
- chordmodifier_tab_ = scm_make_vector (scm_int2num (1), SCM_EOL);
+ chordmodifier_tab_ = SCM_EOL;
pitchname_tab_stack_ = SCM_EOL;
sources_ = sources;
scopes_ = SCM_EOL;
error_level_ = 0;
main_input_b_ = false;
+
+ smobify_self ();
add_scope (ly_make_anonymous_module (false));
-
push_note_state (scm_c_make_hash_table (0));
-
+ chordmodifier_tab_ = scm_make_vector (scm_int2num (1), SCM_EOL);
}
-My_lily_lexer::My_lily_lexer (My_lily_lexer const &src)
+Lily_lexer::Lily_lexer (Lily_lexer const &src)
: Includable_lexer ()
{
keytable_ = (src.keytable_) ? new Keyword_table (*src.keytable_) : 0;
error_level_ = src.error_level_;
main_input_b_ = src.main_input_b_;
+ scopes_ = SCM_EOL;
+
+ smobify_self ();
+
SCM scopes = SCM_EOL;
SCM* tail = &scopes;
for (SCM s = src.scopes_; ly_c_pair_p (s); s = ly_cdr (s))
push_note_state (scm_c_make_hash_table (0));
}
-My_lily_lexer::~My_lily_lexer ()
+Lily_lexer::~Lily_lexer ()
{
delete keytable_;
}
SCM
-My_lily_lexer::encoding () const
+Lily_lexer::encoding () const
{
return encoding_ ;
}
void
-My_lily_lexer::add_scope (SCM module)
+Lily_lexer::add_scope (SCM module)
{
ly_reexport_module (scm_current_module ());
scm_set_current_module (module);
}
SCM
-My_lily_lexer::remove_scope ()
+Lily_lexer::remove_scope ()
{
SCM sc = ly_car (scopes_);
scopes_ = ly_cdr (scopes_);
int
-My_lily_lexer::lookup_keyword (String s)
+Lily_lexer::lookup_keyword (String s)
{
return keytable_->lookup (s.to_str0 ());
}
SCM
-My_lily_lexer::lookup_identifier_symbol (SCM sym)
+Lily_lexer::lookup_identifier_symbol (SCM sym)
{
for (SCM s = scopes_; ly_c_pair_p (s); s = ly_cdr (s))
{
}
SCM
-My_lily_lexer::lookup_identifier (String name)
+Lily_lexer::lookup_identifier (String name)
{
return lookup_identifier_symbol (ly_symbol2scm (name.to_str0 ()));
}
void
-My_lily_lexer::start_main_input ()
+Lily_lexer::start_main_input ()
{
// yy_flex_debug = 1;
new_input (main_input_name_, sources_);
}
void
-My_lily_lexer::set_identifier (SCM name, SCM s)
+Lily_lexer::set_identifier (SCM name, SCM s)
{
SCM sym = name;
if (ly_c_string_p (name))
}
void
-My_lily_lexer::LexerError (char const *s)
+Lily_lexer::LexerError (char const *s)
{
if (include_stack_.is_empty ())
progress_indication (_f ("error at EOF: %s", s) + String ("\n"));
}
char
-My_lily_lexer::escaped_char (char c) const
+Lily_lexer::escaped_char (char c) const
{
switch (c)
{
}
Input
-My_lily_lexer::here_input () const
+Lily_lexer::here_input () const
{
Source_file * f= get_source_file ();
return Input (f, (char*)here_str0 ());
}
void
-My_lily_lexer::prepare_for_next_token ()
+Lily_lexer::prepare_for_next_token ()
{
last_input_ = here_input ();
}
void
-My_lily_lexer::set_encoding (String s)
+Lily_lexer::set_encoding (String s)
{
if (s.length ())
encoding_ = ly_symbol2scm (s.to_str0 ());
else
encoding_ = SCM_EOL;
}
+
+
+#include "ly-smobs.icc"
+
+IMPLEMENT_SMOBS (Lily_lexer);
+IMPLEMENT_TYPE_P (Lily_lexer, "ly:my-lily-lexer?");
+IMPLEMENT_DEFAULT_EQUAL_P (Lily_lexer);
+
+SCM
+Lily_lexer::mark_smob (SCM s)
+{
+ Lily_lexer *lexer = (Lily_lexer*) ly_cdr (s);
+
+ scm_gc_mark (lexer->chordmodifier_tab_);
+ scm_gc_mark (lexer->pitchname_tab_stack_);
+ scm_gc_mark (lexer->scopes_);
+ return lexer->encoding_;
+}
+
+int
+Lily_lexer::print_smob (SCM, SCM port, scm_print_state*)
+{
+ scm_puts ("#<Lily_lexer ", port);
+ scm_puts (" >", port);
+ return 1;
+}
/*
- my-lily-parser.cc -- implement My_lily_parser
+ my-lily-parser.cc -- implement Lily_parser
source file of the GNU LilyPond music typesetter
#include "warn.hh"
-My_lily_parser::My_lily_parser (Sources *sources)
+Lily_parser::Lily_parser (Sources *sources)
{
book_count_ = 0;
score_count_ = 0;
smobify_self ();
}
-My_lily_parser::My_lily_parser (My_lily_parser const &src)
+Lily_parser::Lily_parser (Lily_parser const &src)
{
book_count_ = src.book_count_;
score_count_ = src.score_count_;
smobify_self ();
if (src.lexer_)
- lexer_ = new My_lily_lexer (*src.lexer_);
+ lexer_ = new Lily_lexer (*src.lexer_);
+
+ scm_gc_unprotect_object (lexer_->self_scm ());
}
-My_lily_parser::~My_lily_parser ()
+Lily_parser::~Lily_parser ()
{
- // FIXME: Memleak: del lexer
}
#include "ly-smobs.icc"
-IMPLEMENT_SMOBS (My_lily_parser);
-IMPLEMENT_TYPE_P (My_lily_parser, "ly:my-lily-parser?");
-IMPLEMENT_DEFAULT_EQUAL_P (My_lily_parser);
+IMPLEMENT_SMOBS (Lily_parser);
+IMPLEMENT_TYPE_P (Lily_parser, "ly:my-lily-parser?");
+IMPLEMENT_DEFAULT_EQUAL_P (Lily_parser);
SCM
-My_lily_parser::mark_smob (SCM s)
+Lily_parser::mark_smob (SCM s)
{
- My_lily_parser *parser = (My_lily_parser*) ly_cdr (s);
- (void) parser;
- return SCM_EOL;
+ Lily_parser *parser = (Lily_parser*) ly_cdr (s);
+ return (parser->lexer_) ? parser->lexer_->self_scm () : SCM_EOL;
}
int
-My_lily_parser::print_smob (SCM s, SCM port, scm_print_state*)
+Lily_parser::print_smob (SCM s, SCM port, scm_print_state*)
{
scm_puts ("#<my_lily_parser ", port);
- My_lily_parser *parser = (My_lily_parser*) ly_cdr (s);
+ Lily_parser *parser = (Lily_parser*) ly_cdr (s);
(void) parser;
scm_puts (" >", port);
return 1;
/* Process one .ly file, or book. */
void
-My_lily_parser::parse_file (String init, String name, String out_name)
+Lily_parser::parse_file (String init, String name, String out_name)
{
- lexer_ = new My_lily_lexer (sources_);
+ lexer_ = new Lily_lexer (sources_);
// TODO: use $parser
lexer_->set_identifier (ly_symbol2scm ("parser"),
self_scm ());
}
error_level_ = error_level_ | lexer_->error_level_;
- delete lexer_;
+
+ scm_gc_unprotect_object (lexer_->self_scm ());
lexer_ = 0;
}
void
-My_lily_parser::parse_string (String ly_code)
+Lily_parser::parse_string (String ly_code)
{
- My_lily_lexer *parent = lexer_;
- lexer_ = (parent == 0 ? new My_lily_lexer (sources_)
- : new My_lily_lexer (*parent));
+ Lily_lexer *parent = lexer_;
+ lexer_ = (parent == 0 ? new Lily_lexer (sources_)
+ : new Lily_lexer (*parent));
SCM oldmod = scm_current_module ();
}
scm_set_current_module (oldmod);
- delete lexer_;
+ scm_gc_unprotect_object (lexer_->self_scm ());
lexer_ = 0;
}
void
-My_lily_parser::push_spot ()
+Lily_parser::push_spot ()
{
define_spots_.push (here_input ());
}
char const *
-My_lily_parser::here_str0 () const
+Lily_parser::here_str0 () const
{
return lexer_->here_str0 ();
}
void
-My_lily_parser::parser_error (String s)
+Lily_parser::parser_error (String s)
{
here_input ().error (s);
error_level_ = 1;
}
Input
-My_lily_parser::pop_spot ()
+Lily_parser::pop_spot ()
{
return define_spots_.pop ();
}
Input
-My_lily_parser::here_input () const
+Lily_parser::here_input () const
{
/*
Parsing looks ahead , so we really want the previous location of the
progress_indication (_f ("Now processing `%s'", file_name.to_str0 ()));
progress_indication ("\n");
- My_lily_parser *parser = new My_lily_parser (&sources);
+ Lily_parser *parser = new Lily_parser (&sources);
parser->parse_file (init, file_name, out_file);
Sources sources;
sources.set_path (&global_path);
- My_lily_parser *parser = new My_lily_parser (&sources);
+ Lily_parser *parser = new Lily_parser (&sources);
scm_module_define (global_lily_module, ly_symbol2scm ("parser"),
parser->self_scm ());
parser->parse_string (ly_scm2string (ly_code));
1, 0, 0, (SCM parser_smob),
"Return a clone of PARSER_SMOB.")
{
- My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
- My_lily_parser *clone = new My_lily_parser (*parser);
+ Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+ Lily_parser *clone = new Lily_parser (*parser);
/* FIXME: should copy scopes too. */
return scm_gc_unprotect_object (clone->self_scm ());
3, 0, 0, (SCM parser_smob, SCM symbol, SCM val),
"Bind SYMBOL to VAL in PARSER_SMOB's module.")
{
- My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+ Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
SCM_ASSERT_TYPE (ly_c_symbol_p (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
"Lookup @var{symbol} in @var{parser_smob}'s module. "
"Undefined is '().")
{
- My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+ Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
SCM_ASSERT_TYPE (ly_c_symbol_p (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
"Parse the string LY_CODE with PARSER_SMOB."
"Upon failure, throw @code{ly-file-failed} key.")
{
- My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+ Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser");
SCM_ASSERT_TYPE (ly_c_string_p (ly_code), ly_code, SCM_ARG2, __FUNCTION__, "string");
}
Output_def*
-get_paper (My_lily_parser *parser)
+get_paper (Lily_parser *parser)
{
SCM id = parser->lexer_->lookup_identifier ("$defaultpaper");
Output_def *paper = unsmob_output_def (id);
Output_def*
-get_midi (My_lily_parser *parser)
+get_midi (Lily_parser *parser)
{
SCM id = parser->lexer_->lookup_identifier ("$defaultmidi");
Output_def *paper = unsmob_output_def (id);
Output_def*
-get_bookpaper (My_lily_parser *parser)
+get_bookpaper (Lily_parser *parser)
{
SCM id = parser->lexer_->lookup_identifier ("$defaultbookpaper");
Output_def *paper = unsmob_output_def (id);
(SCM parser_smob, SCM score_smob),
"Print score, i.e., the classic way.")
{
- My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+ Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
Score *score = unsmob_score (score_smob);
SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser");
"@var{names} is an alist of symbols. "
"This only has effect if the current mode is notes.")
{
- My_lily_parser *p = unsmob_my_lily_parser (parser);
+ Lily_parser *p = unsmob_my_lily_parser (parser);
SCM_ASSERT_TYPE(p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser");
if (p->lexer_->is_note_state ())
2, 0, 0, (SCM parser_smob, SCM book_smob),
"Print book.")
{
- My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+ Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
Book *book = unsmob_book (book_smob);
Output_def *bp = unsmob_output_def (parser->lexer_->lookup_identifier ("$defaultbookpaper"));
#define YYPARSE_PARAM my_lily_parser
#define YYLEX_PARAM my_lily_parser
#define THIS\
- ((My_lily_parser *) my_lily_parser)
+ ((Lily_parser *) my_lily_parser)
#define yyerror THIS->parser_error
int
yylex (YYSTYPE *s, void *v)
{
- My_lily_parser *pars = (My_lily_parser*) v;
- My_lily_lexer *lex = pars->lexer_;
+ Lily_parser *pars = (Lily_parser*) v;
+ Lily_lexer *lex = pars->lexer_;
lex->lexval = (void*) s;
lex->prepare_for_next_token ();
%%
void
-My_lily_parser::set_yydebug (bool )
+Lily_parser::set_yydebug (bool )
{
#if 0
yydebug = 1;
}
void
-My_lily_parser::do_yyparse ()
+Lily_parser::do_yyparse ()
{
yyparse ((void*)this);
}
*/
void
-My_lily_parser::beam_check (SCM dur)
+Lily_parser::beam_check (SCM dur)
{
Duration *d = unsmob_duration (dur);
if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
*/
int
-My_lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
+Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
{
if (ly_c_string_p (sid)) {
*destination = sid;
# we want dvi_examples as well, because they get thrown away otherwise
# incurring another costly lilypond run.
-local-WWW: $(ly_examples) $(pdf_examples) $(ps_examples) $(png_examples)
+local-WWW: $(ly_examples) $(pdf_examples) $(png_examples)
tar:
mkdir -p $(outdir)/$(tarball)