2 my-lily-parser.cc -- implement My_lily_parser
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "my-lily-parser.hh"
11 #include "my-lily-lexer.hh"
14 #include "music-list.hh"
15 #include "musical-request.hh"
16 #include "command-request.hh"
17 #include "lily-guile.hh"
20 #include "file-results.hh"
21 #include "midi-def.hh"
22 #include "paper-def.hh"
23 #include "identifier.hh"
26 My_lily_parser::My_lily_parser (Sources
* source_l
)
31 abbrev_beam_type_i_
= 0;
32 default_duration_
.durlog_i_
= 2;
39 My_lily_parser::~My_lily_parser()
42 delete default_header_p_
;
46 My_lily_parser::set_version_check (bool ig
)
48 ignore_version_b_
= ig
;
52 My_lily_parser::parse_file (String init
, String s
)
54 lexer_p_
= new My_lily_lexer
;
56 lexer_p_
->main_input_str_
= s
;
58 progress_indication (_("Parsing..."));
60 init_parse_b_
= false;
61 set_yydebug (flower_dstream
&&!flower_dstream
->silent_b ("Parser"));
62 lexer_p_
->new_input (init
, source_l_
);
65 if (!define_spot_array_
.empty())
67 warning (_ ("Braces don't match"));
71 inclusion_global_array
= lexer_p_
->filename_str_arr_
;
73 error_level_i_
= error_level_i_
| lexer_p_
->errorlevel_i_
; // ugh naming.
77 My_lily_parser::remember_spot()
79 define_spot_array_
.push (here_input());
83 My_lily_parser::here_ch_C() const
85 return lexer_p_
->here_ch_C();
89 My_lily_parser::parser_error (String s
)
91 here_input().error (s
);
93 exit (fatal_error_i_
);
99 My_lily_parser::set_last_duration (Duration
const *d
)
101 default_duration_
= *d
;
105 My_lily_parser::set_abbrev_beam (int type_i
)
107 abbrev_beam_type_i_
= type_i
;
115 My_lily_parser::get_chord (Musical_pitch tonic
, Array
<Musical_pitch
>* add_arr_p
, Array
<Musical_pitch
>* sub_arr_p
, Musical_pitch
* inversion_p
, Musical_pitch
* bass_p
, Duration d
)
117 Simultaneous_music
*v
= new Request_chord
;
118 v
->set_spot (here_input ());
121 UARGAUGRAGRUAUGRUINAGRAUGIRNA
125 Chord chord
= to_chord (tonic
, add_arr_p
, sub_arr_p
, inversion_p
, bass_p
);
127 Tonic_req
* t
= new Tonic_req
;
133 && Chord::find_notename_i (&chord
.pitch_arr_
, *inversion_p
) > 0)
135 Inversion_req
* i
= new Inversion_req
;
136 i
->pitch_
= *inversion_p
;
142 Bass_req
* b
= new Bass_req
;
147 Array
<Musical_pitch
> pitch_arr
= chord
.to_pitch_arr ();
148 for (int i
= 0; i
< pitch_arr
.size (); i
++)
150 Musical_pitch p
= pitch_arr
[i
];
151 Note_req
* n
= new Note_req
;
163 My_lily_parser::pop_spot()
165 return define_spot_array_
.pop();
169 My_lily_parser::here_input() const
171 return lexer_p_
->here_input ();
175 My_lily_parser::default_paper_p ()
177 Identifier
*id
= lexer_p_
->lookup_identifier ("$defaultpaper");
178 return id
? id
->access_content_Paper_def (true) : new Paper_def
;
182 My_lily_parser::default_midi_p ()
184 Identifier
*id
= lexer_p_
->lookup_identifier ("$defaultmidi");
185 return id
? id
->access_content_Midi_def (true) : new Midi_def
;