lilypond-0.1.10
[lilypond.git] / mi2mu / include / midi-parser.hh
blob3c1b491f65bdaf5c2309530544578672c171a782
1 /*
2 midi-parser.hh -- declare Midi_parser
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
7 */
10 #ifndef MIDI_PARSER_HH
11 #define MIDI_PARSER_HH
13 // must, gcc 2.7.2{,.1} hits ico on midi-track-parser.cc:134 (@Midi_note)
14 #define INLINES
16 #ifdef INLINES
18 #define next_byte() (inline_next_byte (__FUNCTION__))
19 #define peek_byte() (inline_peek_byte (__FUNCTION__))
20 #define forward_byte_L(n) (inline_forward_byte_L (__FUNCTION__, n))
22 #else
24 #define next_byte()\
25 ((info_l_->byte_L_ < info_l_->end_byte_L_ ?\
26 *info_l_->byte_L_++\
27 : (Byte const)exit (__FUNCTION__": unexpected EOF")));
29 #define peek_byte()\
30 ((info_l_->byte_L_ < info_l_->end_byte_L_ ?\
31 *info_l_->byte_L_\
32 : (Byte const)exit (__FUNCTION__": unexpected EOF")));
34 #define forward_byte_L(n) (inline_forward_byte_L (__FUNCTION__, n))
36 #endif
38 #include "proto.hh"
39 #include "moment.hh"
40 #include "mi2mu-proto.hh"
42 struct Midi_parser_info
44 Midi_parser_info();
45 int division_1_i_;
46 int format_i_;
47 int tracks_i_;
48 int errorlevel_i_;
49 Byte const* byte_L_;
50 Byte const* end_byte_L_;
51 Source_file* source_l_;
52 Mudela_score* score_l_;
53 Moment bar_mom_;
56 #include "string.hh"
58 class Midi_parser
60 public:
61 Midi_parser ();
63 Midi_parser_info* info_l_;
65 protected:
66 // Byte const* inline_forward_byte_L (int n)
67 Byte const* inline_forward_byte_L (char const* fun, int n)
69 if (info_l_->byte_L_ + n < info_l_->end_byte_L_ )
71 Byte const* p = info_l_->byte_L_;
72 info_l_->byte_L_ += n;
73 return p;
75 // exit (__FUNCTION__": unexpected EOF");
76 exit (String (fun) + ": unexpected EOF");
77 return 0;
80 #ifdef INLINES
81 // Byte inline_next_byte ()
82 Byte inline_next_byte (char const* fun)
84 if (info_l_->byte_L_ < info_l_->end_byte_L_)
85 return *info_l_->byte_L_++;
86 // exit (__FUNCTION__": unexpected EOF");
87 exit (String (fun) + ": unexpected EOF");
88 return 0;
91 // Byte inline_peek_byte ()
92 Byte inline_peek_byte (char const* fun)
94 if (info_l_->byte_L_ < info_l_->end_byte_L_)
95 return *info_l_->byte_L_;
96 // exit (__FUNCTION__": unexpected EOF");
97 exit (String (fun) + ": unexpected EOF");
98 return 0;
100 #endif
102 int get_i (int);
103 String get_str (int);
104 unsigned get_u (int);
105 int get_var_i ();
106 int exit (String);
107 void error (String);
108 String message (String);
109 void warning (String);
112 #endif // MIDI_PARSER_HH