+# Generate.make ?
+# -> Rules.make: containing all compile/flex/bison/... rules (jcn)
parsheadorig=$(CCDIR)/parser.tab.h
parsheadnew=$(HEADERDIR)/parser.hh
#
# take some trouble to avoid overwriting the old y.tab.h
+# why? (jcn)
$(CCDIR)/parser.cc: $(CCDIR)/parser.y
$(BISON) -d $<
(if diff $(parsheadorig) $(parsheadnew)>/dev/null; then \
$(HEADERDIR)/version.hh: Variables.make make_version
make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) "$(CXX) $(CXXVER)" > $@
-$(CCDIR)/lexer.cc: $(CCDIR)/lexer.l
- $(FLEX) -t $< > $@
-
-
+$(CCDIR)/%.cc: $(CCDIR)/%.y
+ $(BISON) -d $<
+ mv $(CCDIR)/$(shell basename $@ .cc ).tab.h $(HEADERDIR)/$(shell basename $@ .cc).hh
+ mv $(CCDIR)/$(shell basename $@ .cc ).tab.c $@
+$(CCDIR)/%.cc: $(CCDIR)/%.l
+ $(FLEX) -t $< > $@
+# Makefile
+# top level makefile of LilyPond
+
include Variables.make
.SUFFIXES:
$(STRIPDEBUG) $(STABLEOBS)
$(LINKER) -o $@ $^ $(LOADLIBES)
+$(m2m): $(m2mobs)
+ $(LINKER) -o $@ $^ $(LOADLIBES)
.PHONY: clean docxx
clean:
- rm -f $(exe) $(DOCDIR)/* core $(obs) $(ALLDEPS)
+ rm -f $(allexe) $(DOCDIR)/* core $(allobs) $(ALLDEPS)
for SUBDIR in $(SUBDIRS); \
do \
$(MAKE) SUBDIR=$$SUBDIR -C $$SUBDIR clean;\
distclean: clean
rm -f version.hh $(gencc) .GENERATE *~ $(ALLDEPS)
-all: kompijl doc
+all: $(exe) $(m2m) doc
# value of $(OSTYPE) on windhoos; "make $OSTYPE" if u use bash :-)
win32:
default:
$(MAKE) -C ..
-DISTFILES=Makefile $(hdr)
+DISTFILES=Makefile $(allhdr)
dist:
ln $(DISTFILES) $(DDIR)/$(SUBDIR)
clean:
rm -f parser.hh
+ rm -f midi-parser.hh
--- /dev/null
+/*
+ inputfile.hh -- declare Input_file
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#ifndef INPUT_FILE_HH
+#define INPUT_FILE_HH
+#include <FlexLexer.h>
+#include "proto.hh"
+#include "fproto.hh"
+#include "varray.hh"
+#include "string.hh"
+
+struct Input_file {
+ istream* is;
+ char const* defined_ch_c_l_;
+ Source_file* sourcefile_l_;
+ int line;
+ String name;
+
+ Input_file(String);
+ ~Input_file();
+};
+
+#endif // INPUT_FILE_HH
+/*
+ lexer.hh -- declare My_flex_lexer
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
#ifndef LEXER_HH
#define LEXER_HH
#include <FlexLexer.h>
void kill_lexer();
void set_lexer();
-struct Input_file {
- istream* is;
- char const* defined_ch_c_l_;
- Source_file* sourcefile_l_;
- int line;
- String name;
-
- Input_file(String);
- ~Input_file();
-};
-
-
/// lexer with provisions for include files.
struct My_flex_lexer : yyFlexLexer {
--- /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
+
IPointerList<Source_file*> sourcefile_p_iplist_;
};
+
+// ugh
+extern Source* source_l_g;
+
#endif // SOURCE_HH //
win32:
$(MAKE) -C .. Windows_NT
-DISTFILES=Makefile $(mycc) $(othersrc)
+DISTFILES=Makefile $(allcc) $(othersrc)
dist:
ln $(DISTFILES) $(DDIR)/$(SUBDIR)
-TAGS: $(mycc)
- etags -CT $(mycc)
+TAGS: $(allcc)
+ etags -CT $(allcc)
clean:
rm -f $(gencc)
--- /dev/null
+/*
+ inputfile.cc -- implement Input_file
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl> Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+#include <iostream.h>
+#include <strstream.h>
+#include "proto.hh"
+#include "plist.hh"
+#include "inputfile.hh"
+#include "debug.hh"
+#include "sourcefile.hh"
+#include "source.hh"
+
+Input_file::Input_file(String s)
+{
+ name = s;
+ line = 1;
+ String pf(s);
+ if ( pf == "" ) {
+ is = &cin;
+ defined_ch_c_l_ = 0;
+ sourcefile_l_ = 0;
+ }
+ else {
+ Source_file* sourcefile_p = new Source_file( pf );
+ source_l_g->add( sourcefile_p );
+ sourcefile_l_ = sourcefile_p;
+ is = sourcefile_l_->istream_l();
+ defined_ch_c_l_ = sourcefile_l_->ch_c_l();
+ }
+ cout << "[" << pf << flush;
+}
+
+Input_file::~Input_file()
+{
+ cout << "]" << flush;
+}
+/*
+ lexerinit.cc -- implement some stuff
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
#include <iostream.h>
#include <strstream.h>
#include "proto.hh"
{
return lexer;
}
-
-Input_file::Input_file(String s)
-{
- name = s;
- line = 1;
- String pf(s);
- if (pf=="") {
- is = &cin;
- defined_ch_c_l_ = 0;
- sourcefile_l_ = 0;
- }
- else {
- Source_file* sourcefile_p = new Source_file( pf );
- source_global_l->add( sourcefile_p );
- sourcefile_l_ = sourcefile_p;
- is = sourcefile_l_->istream_l();
- defined_ch_c_l_ = sourcefile_l_->ch_c_l();
- }
- cout << "["<<pf<<flush;
-}
-
-Input_file::~Input_file()
-{
- cout << "]" << flush;
-}
--- /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-lexer.l
+
+#include <stdio.h>
+
+#include "string.hh"
+#include "proto.hh"
+#include "my-midi-lexer.hh"
+#include "midi-parser.hh"
+
+#ifndef MIDI_LEX_DEBUG
+#define puts( x )
+#endif
+
+%}
+
+%option c++
+%option noyywrap
+%option nodefault
+%option yylineno
+%option debug
+%option yyclass="My_midi_lexer"
+%option stack
+
+%x data
+%x event
+%x int8
+%x int16
+%x int32
+%x meta_event
+%x track
+
+INT8 [\x00-\xff]
+INT16 {INT8}{INT8}
+INT32 {INT16}{INT16}
+INT7_8UNSET [\x00-\x7f]
+INT7_8SET [\x80-\xff]
+VARINT {INT7_8SET}{0,3}{INT7_8UNSET}
+
+HEADER MThd
+TRACK MTrk
+
+RUNNING_STATUS [\x30-\x4f]
+NOTE_OFF [\x80-\x8f]
+NOTE_ON [\x90-\x9f]
+PROGRAM_CHANGE [\xc0-\xcf]
+
+SYSEX_EVENT1 [\xf0]
+SYSEX_EVENT2 [\xf7]
+
+META_EVENT [\xff]
+
+SEQUENCE [\x00][\x02]
+TEXT [\x01]
+COPYRIGHT [\x02]
+TRACK_NAME [\x03]
+INSTRUMENT_NAME [\x04]
+LYRIC [\x05]
+MARKER [\x06]
+CUE_POINT [\x07]
+
+END_OF_TRACK [\x2f][\x00]
+TEMPO [\x51][\x03]
+SMPTE_OFFSET [\x54][\x05]
+TIME [\x58][\x04]
+KEY [\x59][\x02]
+SSME [\0x7f][\x03]
+
+%%
+
+{HEADER}/{INT32} { // using /{INT32}; longer match than {INT32}
+ puts( "lex: header" );
+ yy_push_state( int16 );
+ yy_push_state( int16 );
+ yy_push_state( int16 );
+ yy_push_state( int32 );
+ return HEADER;
+}
+
+{TRACK}/{INT32} { // using /{INT32}; longer match than {INT32}
+ puts( "lex: track" );
+ yy_push_state( track );
+ yy_push_state( int32 );
+ return TRACK;
+}
+
+<int32>{INT32} {
+ puts( "lex: int32" );
+ assert( YYLeng() == 4 );
+ String str( (Byte const*)YYText(), YYLeng() );
+ yylval.i = StringConversion::bin2int_i( str );
+ yy_pop_state();
+ return INT32;
+}
+<int16>{INT16} {
+ puts( "lex: int16" );
+ assert( YYLeng() == 2 );
+ String str( (Byte const*)YYText(), YYLeng() );
+ yylval.i = StringConversion::bin2int_i( str );
+ yy_pop_state();
+ return INT16;
+}
+<int8>{INT8} {
+ puts( "lex: int8" );
+ assert( YYLeng() == 1 );
+// yylval.byte = *(Byte*)YYText();
+ yylval.i = *(Byte*)YYText();
+ yy_pop_state();
+ return INT8;
+}
+
+<track>{VARINT} {
+ puts( "lex: track: varint" );
+ String str( (Byte const*)YYText(), YYLeng() );
+ yylval.i = My_midi_lexer::varint2int_i( str );
+ yy_push_state( event );
+ return VARINT;
+}
+
+<event>{RUNNING_STATUS} {
+ yylval.byte = *(Byte*)YYText();
+ yy_pop_state();
+ yy_push_state( int8 );
+ return RUNNING_STATUS;
+}
+<event>{NOTE_OFF} {
+ puts( "lex: note off" );
+ yylval.byte = *(Byte*)YYText();
+ yy_pop_state();
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ return NOTE_OFF;
+}
+<event>{NOTE_ON} {
+ puts( "lex: note on" );
+ yylval.byte = *(Byte*)YYText();
+ yy_pop_state();
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ return NOTE_ON;
+}
+<event>{PROGRAM_CHANGE} {
+ yylval.byte = *(Byte*)YYText();
+ yy_pop_state();
+ yy_push_state( int8 );
+ return PROGRAM_CHANGE;
+}
+<event>{META_EVENT} {
+ yy_push_state( meta_event );
+ return META_EVENT;
+}
+
+<meta_event>{SEQUENCE} { // ssss sequence number
+ yy_push_state( int16 );
+ return SEQUENCE;
+}
+<meta_event>{TEXT} { // len data
+ yy_push_state( data );
+ return TEXT;
+}
+<meta_event>{COPYRIGHT} {
+ yy_push_state( data );
+ return COPYRIGHT;
+}
+<meta_event>{TRACK_NAME} {
+ yy_push_state( data );
+ return TRACK_NAME;
+}
+<meta_event>{INSTRUMENT_NAME} {
+ yy_push_state( data );
+ return INSTRUMENT_NAME;
+}
+<meta_event>{LYRIC} {
+ yy_push_state( data );
+ return LYRIC;
+}
+<meta_event>{MARKER} {
+ yy_push_state( data );
+ return MARKER;
+}
+<meta_event>{CUE_POINT} {
+ yy_push_state( data );
+ return CUE_POINT;
+}
+<meta_event>{TEMPO} { // tttttt usec
+ puts( "lex: tempo" );
+ yy_pop_state();
+ yy_pop_state();
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ return TEMPO;
+}
+<meta_event>{SMPTE_OFFSET} { // hr mn se fr ff
+ yy_pop_state();
+ yy_pop_state();
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ return SMPTE_OFFSET;
+}
+<meta_event>{TIME} { // nn dd cc bb
+ puts( "lex: time" );
+ yy_pop_state();
+ yy_pop_state();
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ return TIME;
+}
+<meta_event>{KEY} { // sf mi
+ puts( "lex: key" );
+ yy_pop_state();
+ yy_pop_state();
+ yy_push_state( int8 );
+ yy_push_state( int8 );
+ return KEY;
+}
+<meta_event>{SSME} { // len data
+ yy_pop_state();
+ yy_pop_state();
+ yy_push_state( data );
+ return SSME;
+}
+<meta_event>{END_OF_TRACK} {
+ puts( "lex: end of track" );
+ yy_pop_state();
+ yy_pop_state();
+ yy_pop_state();
+ return END_OF_TRACK;
+}
+<meta_event>{INT8} {
+ yylval.byte = *(Byte*)YYText();
+ return INT8;
+}
+
+<data>{VARINT} {
+ String str( (Byte const*)YYText(), YYLeng() );
+ int i = My_midi_lexer::varint2int_i( str );
+ String* str_p = new String;
+ while ( i-- )
+ *str_p += (char)yyinput();
+ yylval.str_p = str_p;
+ yy_pop_state();
+ yy_pop_state();
+ return DATA;
+}
+
+
+<<EOF>> {
+// mtor << "<<EOF>>";
+
+ if ( !close_i() )
+ yyterminate(); // can't move this, since it actually rets a YY_NULL
+}
+
+%%
+
--- /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
+%{
+
+#include <iostream.h>
+
+#include "my-midi-lexer.hh"
+#include "my-midi-parser.hh"
+#include "midi-event.hh"
+#include "midi-track.hh"
+#include "midi-score.hh"
+
+#ifndef NDEBUG
+#define YYDEBUG 1
+#endif
+
+%}
+
+%union {
+ Byte byte;
+ char c;
+ int i;
+ String* str_p;
+ Request* request_p;
+ Midi_event* midi_event_p; // Voice_element* ?
+ Midi_score* midi_score_p; // Input_score* ?
+ Midi_track* midi_track_p; // Input_music* ?
+}
+
+%token HEADER TRACK
+%token SYSEX_EVENT1 SYSEX_EVENT2
+%token META_EVENT
+%token SEQUENCE TEXT COPYRIGHT TRACK_NAME INSTRUMENT_NAME LYRIC MARKER CUE_POINT
+%token END_OF_TRACK TEMPO SMPTE_OFFSET TIME KEY SSME
+
+%token<i> INT8 INT16 INT32 INT7_8UNSET INT7_8SET VARINT
+%token<i> RUNNING_STATUS NOTE_OFF NOTE_ON PROGRAM_CHANGE
+%token<str_p> DATA
+
+%type <midi_score_p> header midi_score
+%type <midi_track_p> track
+%type <midi_event_p> event
+%type <midi_event_p> the_event meta_event text_event midi_event sysex_event
+%type <midi_event_p> running_status note_off note_on program_change
+
+%%
+
+midi: /* empty */
+ | midi midi_score {
+ midi_parser_l_g->add_score( $2 );
+ }
+ ;
+
+midi_score:
+ header {
+ }
+ | midi_score track {
+ $$->add_track( $2 );
+ }
+ ;
+
+header:
+ HEADER INT32 INT16 INT16 INT16 {
+ $$ = new Midi_score( $3, $4, $5 );
+ }
+ ;
+
+track:
+ TRACK INT32 {
+ $$ = new Midi_track;
+ }
+ | track event {
+ $$->add_event( $2 );
+ }
+ ;
+
+event:
+ VARINT the_event {
+ }
+ ;
+
+the_event:
+ meta_event {
+ }
+ | midi_event {
+ }
+ | sysex_event {
+ }
+ ;
+
+meta_event:
+ META_EVENT the_meta_event {
+ };
+
+the_meta_event:
+ SEQUENCE INT16 {
+ }
+ | text_event DATA {
+ }
+ | END_OF_TRACK {
+ }
+ | TEMPO INT8 INT8 INT8 {
+ }
+ | SMPTE_OFFSET INT8 INT8 INT8 INT8 INT8 {
+ }
+ | TIME INT8 INT8 INT8 INT8 {
+ }
+ | KEY INT8 INT8 {
+ }
+ | SSME DATA {
+ }
+ ;
+
+text_event:
+ TEXT {
+ }
+ | COPYRIGHT {
+ }
+ | TRACK_NAME {
+ }
+ | INSTRUMENT_NAME {
+ }
+ | LYRIC {
+ }
+ | MARKER {
+ }
+ | CUE_POINT {
+ }
+ ;
+
+midi_event:
+ running_status {
+ }
+ | note_off {
+ }
+ | note_on {
+ }
+ | program_change {
+ }
+ ;
+
+running_status:
+ RUNNING_STATUS {
+ }
+ ;
+
+note_off:
+ NOTE_OFF INT8 INT8 {
+ }
+ ;
+
+note_on:
+ NOTE_ON INT8 INT8 {
+ int pitch_i = $2;
+ // assuming key of C
+ String notename_str = ( pitch_i % 12 )[ "ccddeffggaab" ];
+ static int accidental_i_a[ 12 ] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 };
+ int accidental_i = accidental_i_a[ pitch_i % 12 ];
+ if ( accidental_i == 1 )
+ notename_str += "is";
+ cout << "note(" << pitch_i << "): " << notename_str << endl;
+ }
+ ;
+
+program_change:
+ PROGRAM_CHANGE {
+ }
+ ;
+
+sysex_event:
+ SYSEX_EVENT1 {
+ }
+ | SYSEX_EVENT2 {
+ }
+ ;
--- /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 );
+}
+
#include "identparent.hh"
#include "associter.hh"
#include "lexer.hh"
+#include "inputfile.hh"
#include "parser.hh"
#include "keyword.hh"
#include "assoc.hh"
data_caddr_ = (caddr_t)mmap( (void*)0, size_off_, PROT_READ, MAP_SHARED, fildes_i_, 0 );
if ( (int)data_caddr_ == -1 )
+ // ugh: defined_ch_c_l...
warning( String( "can't map: " ) + name_str_ + String( ": " ) + strerror( errno ), defined_ch_c_l ); //lexer->here_ch_c_l() );
}
message( String message_str, char const* context_ch_c_l )
{
String str = "lilypond: ";
- Source_file* sourcefile_l = source_global_l->sourcefile_l( context_ch_c_l );
+ 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(": ");
}