]> git.donarmstrong.com Git - lilypond.git/blob - lily/my-lily-parser.cc
release: 1.3.107
[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--2000 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 "debug.hh"
13 #include "main.hh"
14 #include "parser.hh"
15 #include "file-results.hh"
16 #include "scope.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
25
26   default_header_p_ =0;
27 }
28
29 My_lily_parser::~My_lily_parser()
30 {
31   delete lexer_p_;
32   delete default_header_p_;
33 }
34
35 void
36 My_lily_parser::set_version_check (bool )
37 {
38 }
39
40 void
41 My_lily_parser::parse_file (String init, String s)
42 {
43   lexer_p_ = new My_lily_lexer;
44
45   lexer_p_->main_input_str_ = s;
46
47   progress_indication (_("Parsing..."));
48
49   set_yydebug (flower_dstream &&!flower_dstream->silent_b ("Parser"));
50   lexer_p_->new_input (init, source_l_);
51   do_yyparse ();
52
53   if (!define_spot_array_.empty())
54     {
55       define_spot_array_.top ().warning (_ ("Braces don't match"));
56       error_level_i_ = 1;
57     }
58
59   inclusion_global_array = lexer_p_->filename_str_arr_;
60
61   error_level_i_ = error_level_i_ | lexer_p_->errorlevel_i_; // ugh naming.
62 }
63
64 void
65 My_lily_parser::remember_spot()
66 {
67   define_spot_array_.push (here_input());
68 }
69
70 char const *
71 My_lily_parser::here_ch_C() const
72 {
73   return lexer_p_->here_ch_C();
74 }
75
76 void
77 My_lily_parser::parser_error (String s)
78 {
79   here_input().error (s);
80   error_level_i_ = 1;
81   exit_status_i_ = 1;
82 }
83
84 void
85 My_lily_parser::set_last_duration (Duration const *d)
86 {
87   default_duration_ = *d;
88 }
89
90
91 Input
92 My_lily_parser::pop_spot()
93 {
94   return define_spot_array_.pop();
95 }
96
97 Input
98 My_lily_parser::here_input() const
99 {
100   return  lexer_p_->here_input ();
101 }
102
103 // move me?
104 #include "paper-def.hh"
105 #include "identifier.hh"
106 #include "translator-def.hh"
107
108 My_lily_parser * current_parser;
109
110 MAKE_SCHEME_CALLBACK(My_lily_parser,paper_description, 0);
111
112 SCM
113 My_lily_parser::paper_description ()
114 {
115   My_lily_parser * me = current_parser;
116
117   Identifier *id = unsmob_identifier (me->lexer_p_->lookup_identifier ("$defaultpaper"));
118   Paper_def *p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (false));
119
120   SCM al = p->translator_p_dict_p_->to_alist ();
121   SCM l = SCM_EOL;
122   for (SCM s = al ; gh_pair_p (s); s = gh_cdr (s))
123     {
124       Translator_def * td = unsmob_translator_def (gh_cdar (s));
125       l = gh_cons (gh_cons (gh_caar (s), td->to_alist ()),  l);
126     }
127   return l;  
128 }
129   
130