2 my-lily-parser.cc -- implement My_lily_parser
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "my-lily-parser.hh"
10 #include "my-lily-lexer.hh"
13 #include "music-list.hh"
14 #include "musical-request.hh"
15 #include "command-request.hh"
19 My_lily_parser::clear_notenames()
21 lexer_p_->clear_notenames();
24 My_lily_parser::set_version_check(bool ig)
26 ignore_version_b_ = ig;
29 My_lily_parser::set_debug()
35 set_yydebug( !monitor->silence(s+"Parser") && check_debug);
36 lexer_p_->set_debug( !monitor->silence(s+"Lexer") && check_debug);
41 My_lily_parser::print_declarations()
48 if (!monitor->silence(s+"Declarations") && check_debug) {
49 lexer_p_->print_declarations(init_parse_b_);
55 My_lily_parser::parse_file(String init, String s)
57 lexer_p_ = new My_lily_lexer;
60 *mlog << "Parsing ... ";
63 lexer_p_->new_input( init, source_l_);
67 init_parse_b_ = false;
68 lexer_p_->new_input( s , source_l_);
73 if(!define_spot_array_.empty())
74 warning("Braces don't match.");
77 My_lily_parser::~My_lily_parser()
83 My_lily_parser::remember_spot()
85 define_spot_array_.push(here_input());
89 My_lily_parser::here_ch_C()const
91 return lexer_p_->here_ch_C();
95 My_lily_parser::parser_error(String s)
97 here_input().error(s);
99 exit( fatal_error_i_ );
104 My_lily_parser::set_duration_mode(String s)
107 last_duration_mode_b_ = (s== "LAST");
111 My_lily_parser::set_default_duration(Duration const *d)
113 last_duration_mode_b_ = false;
114 default_duration_ = *d;
119 My_lily_parser::set_last_duration(Duration const *d)
121 if (last_duration_mode_b_)
122 default_duration_ = *d;
127 My_lily_parser::get_word_element(Text_def* tdef_p, Duration * duration_p)
129 Chord* velt_p = new Request_chord;
131 Lyric_req* lreq_p = new Lyric_req(tdef_p);
133 lreq_p->duration_ = *duration_p;
134 lreq_p->set_spot( here_input());
143 My_lily_parser::get_rest_element(String s, Duration * duration_p )
145 Chord* velt_p = new Request_chord;
146 velt_p->set_spot( here_input());
148 if (s=="s") { /* Space */
149 Skip_req * skip_p = new Skip_req;
150 skip_p->duration_ = *duration_p;
152 skip_p->set_spot( here_input());
156 Rest_req * rest_req_p = new Rest_req;
157 rest_req_p->duration_ = *duration_p;
158 rest_req_p->set_spot( here_input());
160 velt_p->add(rest_req_p);
162 Stem_req * stem_p = new Stem_req;
163 stem_p->duration_ = *duration_p;
164 stem_p->set_spot ( here_input ());
172 My_lily_parser::get_note_element(Note_req *rq, Duration * duration_p )
174 Chord*v = new Request_chord;
175 v->set_spot( here_input());
179 if (duration_p->type_i_ >= 2) {
180 Stem_req * stem_req_p = new Stem_req();
181 stem_req_p->duration_ = *duration_p;
183 stem_req_p->set_spot( here_input());
187 rq->set_duration(*duration_p);
188 rq->set_spot( here_input());
194 My_lily_parser::get_parens_request(char c)
205 Beam_req*b = new Beam_req;
206 int p_i=plet_.type_i_ ; // ugh . Should junk?
216 req_p = new Span_dynamic_req;
221 req_p = new Slur_req;
233 req_p->span()->spantype = Span_req::START;
238 req_p->span()->spantype = Span_req::STOP;
245 if (req_p->musical()->span_dynamic()) {
246 Span_dynamic_req* s_l= (req_p->musical()->span_dynamic()) ;
247 s_l->dynamic_dir_i_ = (c == '<') ? 1:-1;
250 req_p->set_spot( here_input());
254 My_lily_parser::My_lily_parser(Sources * source_l)
257 source_l_ = source_l;
259 default_duration_.type_i_ = 4;
260 default_octave_i_ = 0;
261 textstyle_str_="roman"; // in lexer?
263 last_duration_mode_b_ = true;
268 My_lily_parser::add_requests(Chord*v)
270 for (int i = 0; i < pre_reqs.size(); i++) {
274 for (int i = 0; i <post_reqs.size(); i++) {
275 v->add(post_reqs[i]);
281 My_lily_parser::pop_spot()
283 return define_spot_array_.pop();
287 My_lily_parser::here_input()const
289 Source_file * f_l= lexer_p_->source_file_l();
290 return Input(f_l, here_ch_C());
294 My_lily_parser::add_notename(String s, Melodic_req * m_p)
296 lexer_p_->add_notename(s, m_p);