]> git.donarmstrong.com Git - lilypond.git/commitdiff
partial: 0.0.34.jcn
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 24 Feb 1997 09:48:04 +0000 (10:48 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 24 Feb 1997 09:48:04 +0000 (10:48 +0100)
13 files changed:
hdr/midi-event.hh [new file with mode: 0644]
hdr/midi-main.hh [new file with mode: 0644]
hdr/midi-score.hh [new file with mode: 0644]
hdr/midi-track.hh [new file with mode: 0644]
hdr/my-midi-lexer.hh [new file with mode: 0644]
hdr/my-midi-parser.hh [new file with mode: 0644]
src/midi-event.cc [new file with mode: 0644]
src/midi-main.cc [new file with mode: 0644]
src/midi-score.cc [new file with mode: 0644]
src/midi-template.cc [new file with mode: 0644]
src/midi-track.cc [new file with mode: 0644]
src/my-midi-lexer.cc [new file with mode: 0644]
src/my-midi-parser.cc [new file with mode: 0644]

diff --git a/hdr/midi-event.hh b/hdr/midi-event.hh
new file mode 100644 (file)
index 0000000..c9ab033
--- /dev/null
@@ -0,0 +1,19 @@
+//
+// 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
+
diff --git a/hdr/midi-main.hh b/hdr/midi-main.hh
new file mode 100644 (file)
index 0000000..2812bb8
--- /dev/null
@@ -0,0 +1,10 @@
+//
+// 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 );
diff --git a/hdr/midi-score.hh b/hdr/midi-score.hh
new file mode 100644 (file)
index 0000000..2f88168
--- /dev/null
@@ -0,0 +1,24 @@
+//
+// 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
+
diff --git a/hdr/midi-track.hh b/hdr/midi-track.hh
new file mode 100644 (file)
index 0000000..ce258c6
--- /dev/null
@@ -0,0 +1,21 @@
+//
+// 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
+
diff --git a/hdr/my-midi-lexer.hh b/hdr/my-midi-lexer.hh
new file mode 100644 (file)
index 0000000..5245d1b
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// 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
+
diff --git a/hdr/my-midi-parser.hh b/hdr/my-midi-parser.hh
new file mode 100644 (file)
index 0000000..68b238a
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// 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
+
diff --git a/src/midi-event.cc b/src/midi-event.cc
new file mode 100644 (file)
index 0000000..2e295a5
--- /dev/null
@@ -0,0 +1,16 @@
+//
+// 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()
+{
+}
+
diff --git a/src/midi-main.cc b/src/midi-main.cc
new file mode 100644 (file)
index 0000000..3735517
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// 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();
+}
diff --git a/src/midi-score.cc b/src/midi-score.cc
new file mode 100644 (file)
index 0000000..02a79a5
--- /dev/null
@@ -0,0 +1,24 @@
+//
+// 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 )
+{
+}
diff --git a/src/midi-template.cc b/src/midi-template.cc
new file mode 100644 (file)
index 0000000..02315c3
--- /dev/null
@@ -0,0 +1,19 @@
+//
+// 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);
diff --git a/src/midi-track.cc b/src/midi-track.cc
new file mode 100644 (file)
index 0000000..99390c3
--- /dev/null
@@ -0,0 +1,21 @@
+//
+// 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 )
+{
+}
diff --git a/src/my-midi-lexer.cc b/src/my-midi-lexer.cc
new file mode 100644 (file)
index 0000000..70c860b
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// 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;
+}
+
diff --git a/src/my-midi-parser.cc b/src/my-midi-parser.cc
new file mode 100644 (file)
index 0000000..51dda6b
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// 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 );
+}
+