]> git.donarmstrong.com Git - lilypond.git/blob - lily/my-lily-parser.cc
release: 1.5.23
[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--2001 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 (0);
50   lexer_p_->new_input (init, source_l_);
51   do_yyparse ();
52
53   progress_indication ("\n");
54   
55   if (!define_spot_array_.empty ())
56     {
57       define_spot_array_.top ().warning (_ ("Braces don't match"));
58       error_level_i_ = 1;
59     }
60
61   inclusion_global_array = lexer_p_->filename_str_arr_;
62
63   error_level_i_ = error_level_i_ | lexer_p_->errorlevel_i_; // ugh naming.
64 }
65
66 void
67 My_lily_parser::push_spot ()
68 {
69   define_spot_array_.push (here_input ());
70 }
71
72 char const *
73 My_lily_parser::here_ch_C () const
74 {
75   return lexer_p_->here_ch_C ();
76 }
77
78 void
79 My_lily_parser::parser_error (String s)
80 {
81   here_input ().error (s);
82   error_level_i_ = 1;
83   exit_status_global = 1;
84 }
85
86
87
88 Input
89 My_lily_parser::pop_spot ()
90 {
91   return define_spot_array_.pop ();
92 }
93
94 Input
95 My_lily_parser::here_input () const
96 {
97   return  lexer_p_->here_input ();
98 }
99
100 // move me?
101 #include "paper-def.hh"
102 #include "translator-def.hh"
103
104 My_lily_parser * current_parser;
105
106 MAKE_SCHEME_CALLBACK (My_lily_parser,paper_description, 0);
107
108 SCM
109 My_lily_parser::paper_description ()
110 {
111   My_lily_parser * me = current_parser;
112
113   Music_output_def *id = unsmob_music_output_def (me->lexer_p_->lookup_identifier ("$defaultpaper"));
114   Paper_def *p = dynamic_cast<Paper_def*> (id->clone ());
115
116   SCM al = p->translator_p_dict_p_->to_alist ();
117   SCM l = SCM_EOL;
118   for (SCM s = al ; gh_pair_p (s); s = ly_cdr (s))
119     {
120       Translator_def * td = unsmob_translator_def (ly_cdar (s));
121       l = gh_cons (gh_cons (ly_caar (s), td->to_alist ()),  l);
122     }
123   return l;  
124 }
125   
126