lilypond-1.3.145
[lilypond.git] / lily / my-lily-parser.cc
blobf6553c9cb5eac5b73a8e4575c0f6483bff5245cc
1 /*
2 my-lily-parser.cc -- implement My_lily_parser
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
8 */
10 #include "my-lily-parser.hh"
11 #include "my-lily-lexer.hh"
12 #include "debug.hh"
13 #include "main.hh"
14 #include "parser.hh"
15 #include "file-results.hh"
16 #include "scope.hh"
18 My_lily_parser::My_lily_parser (Sources * source_l)
20 source_l_ = source_l;
21 lexer_p_ = 0;
22 default_duration_ = Duration (2,0);
23 error_level_i_ = 0;
26 default_header_p_ =0;
29 My_lily_parser::~My_lily_parser ()
31 delete lexer_p_;
32 delete default_header_p_;
35 void
36 My_lily_parser::set_version_check (bool)
40 void
41 My_lily_parser::parse_file (String init, String s)
43 lexer_p_ = new My_lily_lexer;
45 lexer_p_->main_input_str_ = s;
47 progress_indication (_ ("Parsing..."));
49 set_yydebug (0);
50 lexer_p_->new_input (init, source_l_);
51 do_yyparse ();
53 progress_indication ("\n");
55 if (!define_spot_array_.empty ())
57 define_spot_array_.top ().warning (_ ("Braces don't match"));
58 error_level_i_ = 1;
61 inclusion_global_array = lexer_p_->filename_str_arr_;
63 error_level_i_ = error_level_i_ | lexer_p_->errorlevel_i_; // ugh naming.
66 void
67 My_lily_parser::remember_spot ()
69 define_spot_array_.push (here_input ());
72 char const *
73 My_lily_parser::here_ch_C () const
75 return lexer_p_->here_ch_C ();
78 void
79 My_lily_parser::parser_error (String s)
81 here_input ().error (s);
82 error_level_i_ = 1;
83 exit_status_global = 1;
86 void
87 My_lily_parser::set_last_duration (Duration const *d)
89 default_duration_ = *d;
93 Input
94 My_lily_parser::pop_spot ()
96 return define_spot_array_.pop ();
99 Input
100 My_lily_parser::here_input () const
102 return lexer_p_->here_input ();
105 // move me?
106 #include "paper-def.hh"
107 #include "translator-def.hh"
109 My_lily_parser * current_parser;
111 MAKE_SCHEME_CALLBACK (My_lily_parser,paper_description, 0);
114 My_lily_parser::paper_description ()
116 My_lily_parser * me = current_parser;
118 Music_output_def *id = unsmob_music_output_def (me->lexer_p_->lookup_identifier ("$defaultpaper"));
119 Paper_def *p = dynamic_cast<Paper_def*> (id->clone ());
121 SCM al = p->translator_p_dict_p_->to_alist ();
122 SCM l = SCM_EOL;
123 for (SCM s = al ; gh_pair_p (s); s = gh_cdr (s))
125 Translator_def * td = unsmob_translator_def (gh_cdar (s));
126 l = gh_cons (gh_cons (gh_caar (s), td->to_alist ()), l);
128 return l;