]> git.donarmstrong.com Git - lilypond.git/blob - lily/my-lily-parser.cc
* lily/include/debug.hh: deprecate.
[lilypond.git] / lily / my-lily-parser.cc
1 /*
2   my-lily-parser.cc -- implement My_lily_parser
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7        Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #include "my-lily-parser.hh"
11 #include "my-lily-lexer.hh"
12 #include "warn.hh"
13 #include "main.hh"
14 #include "parser.hh"
15 #include "file-results.hh"
16 #include "scm-hash.hh"
17
18 My_lily_parser::My_lily_parser (Sources * source_l)
19 {
20   source_l_ = source_l;
21   lexer_p_ = 0;
22   default_duration_ = Duration (2,0);
23   error_level_i_ = 0;
24   last_beam_start_ = SCM_EOL;
25
26   default_header_p_ =0;
27 }
28
29 My_lily_parser::~My_lily_parser ()
30 {
31   delete lexer_p_;
32   if (default_header_p_)
33     scm_gc_unprotect_object (default_header_p_->self_scm());
34 }
35
36 void
37 My_lily_parser::set_version_check (bool)
38 {
39 }
40
41 void
42 My_lily_parser::parse_file (String init, String s)
43 {
44   lexer_p_ = new My_lily_lexer;
45
46   lexer_p_->main_input_str_ = s;
47
48   progress_indication (_ ("Parsing..."));
49
50   set_yydebug (0);
51   lexer_p_->new_input (init, source_l_);
52   do_yyparse ();
53
54   progress_indication ("\n");
55   
56   if (!define_spot_array_.empty ())
57     {
58       define_spot_array_.top ().warning (_ ("Braces don't match"));
59       error_level_i_ = 1;
60     }
61
62   inclusion_global_array = lexer_p_->filename_str_arr_;
63
64   error_level_i_ = error_level_i_ | lexer_p_->errorlevel_i_; // ugh naming.
65 }
66
67 void
68 My_lily_parser::push_spot ()
69 {
70   define_spot_array_.push (here_input ());
71 }
72
73 char const *
74 My_lily_parser::here_ch_C () const
75 {
76   return lexer_p_->here_ch_C ();
77 }
78
79 void
80 My_lily_parser::parser_error (String s)
81 {
82   here_input ().error (s);
83   error_level_i_ = 1;
84   exit_status_global = 1;
85 }
86
87
88
89 Input
90 My_lily_parser::pop_spot ()
91 {
92   return define_spot_array_.pop ();
93 }
94
95 Input
96 My_lily_parser::here_input () const
97 {
98   return  lexer_p_->here_input ();
99 }
100
101 // move me?
102 #include "paper-def.hh"
103 #include "translator-def.hh"
104
105 My_lily_parser * current_parser;
106
107 MAKE_SCHEME_CALLBACK (My_lily_parser,paper_description, 0);
108
109 SCM
110 My_lily_parser::paper_description ()
111 {
112   My_lily_parser * me = current_parser;
113
114   Music_output_def *id = unsmob_music_output_def (me->lexer_p_->lookup_identifier ("$defaultpaper"));
115   Paper_def *p = dynamic_cast<Paper_def*> (id->clone ());
116
117   SCM al = p->translator_tab_->to_alist ();
118   SCM l = SCM_EOL;
119   for (SCM s = al ; gh_pair_p (s); s = ly_cdr (s))
120     {
121       Translator_def * td = unsmob_translator_def (ly_cdar (s));
122       l = gh_cons (gh_cons (ly_caar (s), td->to_alist ()),  l);
123     }
124   return l;  
125 }
126   
127