]> git.donarmstrong.com Git - lilypond.git/blob - lily/my-lily-parser.cc
release: 1.3.83
[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_.durlog_i_ = 2;
23   error_level_i_ = 0;
24
25   fatal_error_i_ = 0;
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       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   if (fatal_error_i_)
81     exit (fatal_error_i_);
82   error_level_i_ = 1;
83   exit_status_i_ = 1;
84 }
85
86 void
87 My_lily_parser::set_last_duration (Duration const *d)
88 {
89   default_duration_ = *d;
90 }
91
92
93 Input
94 My_lily_parser::pop_spot()
95 {
96   return define_spot_array_.pop();
97 }
98
99 Input
100 My_lily_parser::here_input() const
101 {
102   return  lexer_p_->here_input ();
103 }
104
105
106