--- /dev/null
+//
+// midi-event.hh -- declare midi_event
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#ifndef MIDI_EVENT_HH
+#define MIDI_EVENT_HH
+
+/// (midi_event)
+class Midi_event {
+public:
+ Midi_event();
+ ~Midi_event();
+
+private:
+};
+
+#endif // MIDI_EVENT_HH
+
--- /dev/null
+//
+// midi-main.hh -- global (sic) m2m stuff
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#include "string.hh"
+extern Source* source_l_g;
+void message( String message_str, char const* context_ch_c_l );
+void warning( String message_str, char const* context_ch_c_l );
+void error( String message_str, char const* context_ch_c_l );
--- /dev/null
+//
+// midi-score.hh -- declare midi_score
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#ifndef MIDI_SCORE_HH
+#define MIDI_SCORE_HH
+
+/// (midi_score)
+class Midi_score {
+public:
+ Midi_score( int format_i, int tracks_i, int tempo_i );
+ ~Midi_score();
+
+ void add_track( Midi_track* midi_track_p );
+
+private:
+ int format_i_;
+ int tracks_i_;
+ int tempo_i_;
+};
+
+#endif // MIDI_SCORE_HH
+
--- /dev/null
+//
+// midi-track.hh -- declare midi_track
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#ifndef MIDI_TRACK_HH
+#define MIDI_TRACK_HH
+
+/// (midi_track)
+class Midi_track {
+public:
+ Midi_track();
+ ~Midi_track();
+
+ void add_event( Midi_event* midi_event_p );
+
+private:
+};
+
+#endif // MIDI_TRACK_HH
+
--- /dev/null
+//
+// my-midi-lexer.hh -- declare My_midi_lexer
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#ifndef MY_MIDI_LEXER_HH
+#define MY_MIDI_LEXER_HH
+
+#include <FlexLexer.h>
+#include "proto.hh"
+// #include "fproto.hh"
+#include "varray.hh"
+#include "string.hh"
+
+int yylex();
+void yyerror(const char *s);
+// bool busy_parsing();
+// void kill_lexer();
+// void set_lexer();
+
+/// (midi_lexer)
+class My_midi_lexer : yyFlexLexer {
+public:
+ My_midi_lexer( String filename_str );
+ ~My_midi_lexer();
+
+ int close_i();
+ void error( char const* sz_l );
+ char const* here_ch_c_l();
+ static int varint2int_i( String str );
+ int yylex();
+
+private:
+ Input_file* input_file_p_;
+
+public: // ugh
+ int errorlevel_i_;
+};
+
+extern My_midi_lexer* midi_lexer_l_g;
+
+#endif // MY_MIDI_LEXER_HH
+
--- /dev/null
+//
+// my-midi-parser.hh -- declare My_midi_parser
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#ifndef MY_MIDI_PARSER_HH
+#define MY_MIDI_PARSER_HH
+
+#include "proto.hh"
+#include "varray.hh"
+#include "string.hh"
+// #include "plist.hh"
+
+int yyparse();
+
+/// (midi_parser)
+class My_midi_parser {
+public:
+ My_midi_parser( String filename_str );
+ ~My_midi_parser();
+ void add_score( Midi_score* midi_score_p );
+ void error( char const* sz_l );
+ int parse();
+
+private:
+ Array<Midi_score*> midi_score_p_array_;
+ char const* defined_ch_c_l_;
+ int fatal_error_i_;
+ My_midi_lexer* midi_lexer_p_;
+};
+
+extern My_midi_parser* midi_parser_l_g;
+
+#endif // MY_MIDI_PARSER_HH
+
--- /dev/null
+//
+// midi-event.cc -- implement Midi_event
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#include "proto.hh"
+#include "midi-event.hh"
+
+Midi_event::Midi_event()
+{
+}
+
+Midi_event::~Midi_event()
+{
+}
+
--- /dev/null
+//
+// midi-main.cc -- implement silly main() entry point
+// should have Root class.
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#include <iostream.h>
+#include "proto.hh"
+#include "plist.hh"
+#include "string.hh"
+#include "source.hh"
+#include "sourcefile.hh"
+#include "midi-main.hh"
+#include "midi-event.hh"
+#include "midi-track.hh"
+#include "my-midi-lexer.hh"
+#include "my-midi-parser.hh"
+
+Source source;
+Source* source_l_g = &source;
+
+//ugh
+char const* defined_ch_c_l = 0;
+
+String
+find_file( String str )
+{
+ return str;
+}
+
+// ugh, copied from warn.cc, cannot use
+void
+message( String message_str, char const* context_ch_c_l )
+{
+ String str = "lilypond: ";
+ Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_c_l );
+ if ( sourcefile_l ) {
+ str += sourcefile_l->file_line_no_str(context_ch_c_l) + String(": ");
+ }
+ str += message_str;
+ if ( sourcefile_l ) {
+ str += ":\n";
+ str += sourcefile_l->error_str( context_ch_c_l );
+ }
+// if ( busy_parsing() )
+// cerr << endl;
+ cerr << str << endl;
+}
+
+void
+warning( String message_str, char const* context_ch_c_l )
+{
+ message( "warning: " + message_str, context_ch_c_l );
+}
+
+void
+error( String message_str, char const* context_ch_c_l )
+{
+ message( message_str, context_ch_c_l );
+ // since when exits error again?
+ // i-d say: error: errorlevel |= 1; -> no output upon error
+ // warning: recovery -> output (possibly wrong)
+ if ( midi_lexer_l_g )
+ midi_lexer_l_g->errorlevel_i_ |= 1;
+}
+
+int
+main( int argc_i, char* argv_sz_a[] )
+{
+ if ( !argc_i )
+ return 2;
+ My_midi_parser midi_parser( argv_sz_a[ 1 ] );
+ return midi_parser.parse();
+}
--- /dev/null
+//
+// midi-score.cc -- implement Midi_score
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#include "proto.hh"
+#include "midi-track.hh"
+#include "midi-score.hh"
+
+Midi_score::Midi_score( int format_i, int tracks_i, int tempo_i )
+{
+ format_i_ = format_i;
+ tracks_i_ = tracks_i;
+ tempo_i_ = tempo_i;
+}
+
+Midi_score::~Midi_score()
+{
+}
+
+void
+Midi_score::add_track( Midi_track* midi_track_p )
+{
+}
--- /dev/null
+//
+// midi-template.cc -- implementemplate
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#include "list.tcc"
+#include "cursor.tcc"
+
+L_instantiate(void *);
+
+class istream;
+class ostream;
+#include "proto.hh"
+#include "plist.tcc"
+#include "pcursor.tcc"
+#include "string.hh"
+#include "sourcefile.hh"
+
+IPL_instantiate(Source_file);
--- /dev/null
+//
+// midi-track.cc -- implement Midi_track
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#include "proto.hh"
+#include "midi-event.hh"
+#include "midi-track.hh"
+
+Midi_track::Midi_track()
+{
+}
+
+Midi_track::~Midi_track()
+{
+}
+
+void
+Midi_track::add_event( Midi_event* midi_event_p )
+{
+}
--- /dev/null
+//
+// my-midi-lexer.cc -- implement My_midi_lexer
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#include "debug.hh"
+#include "inputfile.hh"
+#include "sourcefile.hh"
+#include "my-midi-lexer.hh"
+
+int
+yylex()
+{
+ return midi_lexer_l_g->yylex();
+}
+
+My_midi_lexer* midi_lexer_l_g;
+
+My_midi_lexer::My_midi_lexer( String filename_str )
+{
+ input_file_p_ = new Input_file( filename_str );
+ switch_streams( input_file_p_->is );
+ midi_lexer_l_g = this;
+ errorlevel_i_ = 0;
+}
+
+My_midi_lexer::~My_midi_lexer()
+{
+ delete input_file_p_;
+ midi_lexer_l_g = 0;
+}
+
+void
+My_midi_lexer::error( char const* sz_l )
+{
+ if ( !input_file_p_ ) {
+// *mlog << "error at EOF" << sz_l << '\n';
+ cerr << "error at EOF" << sz_l << '\n';
+ } else {
+ char const* ch_c_l = here_ch_c_l();
+ if ( ch_c_l ) {
+ ch_c_l--;
+ while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
+ ch_c_l--;
+ ch_c_l++;
+ }
+ errorlevel_i_ |= 1;
+// ::error( sz_l, ch_c_l );
+ ::error( sz_l, ch_c_l );
+ }
+}
+
+char const*
+My_midi_lexer::here_ch_c_l()
+{
+ return input_file_p_->sourcefile_l_->ch_c_l() + yyin->tellg();
+}
+
+#if 0 // ?? huh
+int
+My_midi_lexer::yylex()
+{
+ return 0;
+}
+#endif
+
+int
+My_midi_lexer::varint2int_i( String str )
+{
+ return 0;
+}
+
+int
+My_midi_lexer::close_i()
+{
+ return 0;
+}
+
--- /dev/null
+//
+// my-midi-parser.cc -- implement My_midi_parser
+//
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+#include "my-midi-lexer.hh"
+#include "my-midi-parser.hh"
+
+void
+yyerror(char const* sz_l )
+{
+ midi_parser_l_g->error( sz_l );
+}
+
+
+My_midi_parser* midi_parser_l_g;
+
+My_midi_parser::My_midi_parser( String filename_str )
+{
+ midi_lexer_p_ = new My_midi_lexer( filename_str );
+ midi_parser_l_g = this;
+ defined_ch_c_l_ = 0;
+ fatal_error_i_ = 0;
+}
+
+My_midi_parser::~My_midi_parser()
+{
+ delete midi_lexer_p_;
+ midi_parser_l_g = 0;
+}
+
+void
+My_midi_parser::error( char const* sz_l )
+{
+ midi_lexer_l_g->error( sz_l );
+
+ if ( fatal_error_i_ )
+ exit( fatal_error_i_ );
+}
+
+int
+My_midi_parser::parse()
+{
+ return ::yyparse();
+}
+
+void
+My_midi_parser::add_score( Midi_score* midi_score_p )
+{
+ midi_score_p_array_.push( midi_score_p );
+}
+