From b9de385139e4607b126f150d76db7905c75a6d89 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 17 Dec 1996 11:39:41 +0100 Subject: [PATCH] release: 0.0.17 --- .dstreamrc | 21 ++-- Documentation/inputformat | 7 +- Makefile | 4 +- NEWS | 21 ++++ README | 22 ++-- Sources.make | 3 +- Variables.make | 12 +- flower/Sources.make | 6 +- flower/Variables.make | 30 ++++- flower/compare.hh | 4 +- flower/fproto.hh | 5 +- flower/interval.cc | 106 +++++++++-------- flower/interval.hh | 96 +++++++++------ flower/rational.hh | 1 + flower/real.hh | 27 ++--- flower/scalar.cc | 20 ++++ flower/scalar.hh | 2 + flower/string.cc | 22 +++- flower/string.hh | 32 +++-- hdr/debug.hh | 2 +- hdr/identparent.hh | 3 +- hdr/inputcommand.hh | 9 +- hdr/inputcommands.hh | 50 ++++---- hdr/inputmusic.hh | 121 +++++++++---------- hdr/inputstaff.hh | 4 +- hdr/keyword.hh | 13 +++ hdr/lexer.hh | 49 ++++++-- hdr/lookup.hh | 2 +- hdr/misc.hh | 5 +- hdr/proto.hh | 10 +- kortjakje.ly | 50 ++++++-- maartje.ly | 17 +-- make_patch | 2 +- pavane.ly | 6 +- src/beam.cc | 1 + src/command.cc | 2 - src/debug.cc | 32 +++++ src/identifier.cc | 3 +- src/inputcommand.cc | 12 +- src/inputcommands.cc | 238 +++++++++++++++++++++++--------------- src/inputcursor.cc | 116 ------------------- src/inputmusic.cc | 142 ++++++++++------------- src/inputstaff.cc | 8 +- src/key.cc | 2 +- src/keyitem.cc | 6 +- src/lexer.l | 127 +------------------- src/lexerinit.cc | 61 ++++++++++ src/lookup.cc | 8 +- src/main.cc | 18 ++- src/misc.cc | 14 ++- src/mylexer.cc | 129 +++++++++++++++++++++ src/note.cc | 2 +- src/notename.cc | 35 +++--- src/paper.cc | 2 +- src/parser.y | 87 ++++++++------ src/qlpsolve.cc | 16 ++- src/request.cc | 13 +-- src/score.cc | 2 +- src/scores.cc | 4 +- src/table.cc | 73 ------------ src/template2.cc | 1 + src/template3.cc | 9 +- src/version.cc | 5 +- symbol.ini | 19 +-- 64 files changed, 1074 insertions(+), 897 deletions(-) create mode 100644 NEWS create mode 100644 flower/rational.hh delete mode 100644 src/inputcursor.cc create mode 100644 src/lexerinit.cc create mode 100644 src/mylexer.cc diff --git a/.dstreamrc b/.dstreamrc index 2a2dc43002..b14fb6c79a 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -1,34 +1,37 @@ -#class name silence? +# class name silence? My_flex_lexer 0 yyFlexLexer 0 -PCol 0 +PCol 1 Score_column 1 Ineq_constrained_qp 1 Spacing_problem 1 Colinfo 1 Mixed_qp 1 PScore 1 +Idealspacing 1 # yydebug -Parser 1 +Parser 0 # FlexLexer debug -Lexer 0 +Lexer 1 parse_duration 1 -parse_pitch 1 +parse_pitchmod 1 Col_configuration 1 +Request 1 Note_req 1 Rhythmic_req 1 Rest_req 1 delete_identifiers 1 Command 1 -Staff_commands 0 +Staff_commands 1 Stem 0 Staff 0 Score 0 Voice 0 -Voice_element 0 -Request 0 -Input_cursor 1 \ No newline at end of file +Voice_element 1 +Input_cursor 1 +Commands_at 0 +Input_command 1 \ No newline at end of file diff --git a/Documentation/inputformat b/Documentation/inputformat index e6c0de2261..d82c02b2e5 100644 --- a/Documentation/inputformat +++ b/Documentation/inputformat @@ -20,7 +20,6 @@ In musicmode, eg, ''!c8.-"text"_v - a lot of characters parse differently than in "command" mode, eg, @@ -47,14 +46,14 @@ not really crystallized; you can use '#' or '%' as line comment OTHER A correctly parsed .ly does not guarantuee output. A lot (most) of the -checking is done *after* parsing (some checks are after the break calc!) -I'm sorry. +checking is done *after* parsing (some checks even are done after the +break calc!); I'm sorry. The parser's job is to construct appropriate objects. It will *only* detect parse errors. LilyPond first reads 'symbol.ini', which contains declarations crucial -to proper operation of LilyPond (symbol tables) +to proper operation of LilyPond (symbol tables, note names) This language looks a lot like Rayce's which in turn owes a lot to the POVRay raytracer. Now, I know, musictypesetting and Raytracing do not diff --git a/Makefile b/Makefile index 4b7e107435..ac9d7254ea 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,9 @@ distclean: clean all: kompijl doc # doc++ documentation of classes -doc: +doc: $(progdocs) -mkdir $(DOCDIR) - doc++ -p -I -d $(DOCDIR) $(progdocs) + doc++ -p -I -d $(DOCDIR) $^ depend: Sources.make .GENERATE touch depend diff --git a/NEWS b/NEWS new file mode 100644 index 0000000000..455012a74f --- /dev/null +++ b/NEWS @@ -0,0 +1,21 @@ +pl 17: + - robust Input_commands + - merged Vertical_/Horizontal music + - PARTIALs with duration + - modularized lexer: multiple runs + +pl 16 + - notenames configurable + +pl 15 + - grouping code + - multibeams (simple) + +pl 14 + - symtables from .ly + - Input_command + - Input_{score/staff} + +pl 13 + - Horizontal/Vertical music + - Input_commands diff --git a/README b/README index 310ebb1cb1..b849b7f2ee 100644 --- a/README +++ b/README @@ -17,21 +17,22 @@ PREREQUISITES Compilation: - - Unix (any decent Linux distrib is fine) + - Unix (any decent Linux distribution is fine) - GNU C++ v2.7 or better - GNU make. - - flex + - flex (2.5.1 or better) - bison/yacc - - The "flower" library - - which should be available from the same source you got this from. + - The "flower" library, which should be available from the + same source you got this from. + - perl Operation: - TeX - the MusixTeX fonts -The Makefile uses perl for trivial -operations, and you could tinker with it to use sed or awk. +The Makefile uses perl for trivial operations, and you could tinker +with it to use sed or awk. COMPILING @@ -52,14 +53,15 @@ why G++ >= 2.7? LilyPond & flower lib uses: USING -No, you shouldn't. Really. If you're still not discouraged; this is +At this time, LilyPond is only suited for Quick & Dirty jobs (the +output quality still is too low). If you're not discouraged; this is what I type in my xterm: - lilypond maartje.ly + lilypond someinput.ly tex test xdvi test& -This is what the output looks like over here. +This is what the output looks like over here: hw:~/musix/spacer$ lilypond maartje.ly LilyPond version 0.0.16 compiled on Dec 11 1996 at 13:54:27 @@ -78,6 +80,8 @@ Transcript written on test.log. hw:~/musix/spacer$ xdvi test& [1] 1468 +Check out kortjakje.ly, it has some comments + PROBLEMS If LilyPond bombs out, then please recompile using -g, and send a gdb diff --git a/Sources.make b/Sources.make index 25bd89dfb1..4545a011b2 100644 --- a/Sources.make +++ b/Sources.make @@ -20,7 +20,7 @@ hdr= qlp.hh linespace.hh qlpsolve.hh\ inputcommand.hh grouping.hh mycc= qlp.cc qlpsolve.cc leastsquares.cc\ - inputcommands.cc inputmusic.cc inputcursor.cc\ + inputcommands.cc inputmusic.cc \ inputscore.cc inputstaff.cc\ break.cc linespace.cc molecule.cc staffline.cc\ pscore.cc tex.cc item.cc pcol.cc staff.cc \ @@ -40,6 +40,7 @@ mycc= qlp.cc qlpsolve.cc leastsquares.cc\ simplewalker.cc\ texbeam.cc texslur.cc clef.cc key.cc slur.cc beam.cc\ idealspacing.cc inputcommand.cc grouping.cc identifier.cc\ + lexerinit.cc mylexer.cc\ template1.cc template2.cc template3.cc template4.cc\ version.cc diff --git a/Variables.make b/Variables.make index 35959bd20c..f386e5546d 100644 --- a/Variables.make +++ b/Variables.make @@ -9,6 +9,14 @@ DEBUGFLAG=-g EXTRACXXFLAGS=-pipe -Wall -W -Wmissing-prototypes # -Woverloaded-virtual +# +# -lefence = ElectricFence. +# +# ElectricFence is memory debugger which uses the +# VM hardware to trap malloc/free errors. +# +#EXTRALIB+=-lefence + #### #### END USER CONFIGURABLE part. #### @@ -29,7 +37,7 @@ endif # version info MAJVER=0 MINVER=0 -PATCHLEVEL=16 +PATCHLEVEL=17 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) CXXVER=`$(CXX) --version` @@ -67,7 +75,7 @@ othersrc=lexer.l parser.y SCRIPTS=make_version make_patch genheader IFILES=dimen.tex symbol.ini kortjakje.ly pavane.ly maartje.ly\ lilyponddefs.tex test.tex .dstreamrc -OFILES=Makefile Variables.make Sources.make COPYING README +OFILES=Makefile Variables.make Sources.make COPYING README NEWS DFILES=$(OFILES) $(IFILES) $(SCRIPTS) #compiling diff --git a/flower/Sources.make b/flower/Sources.make index c7efa127f9..84e27c4681 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -1,14 +1,14 @@ cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \ smat.cc matrix.cc choleski.cc vector.cc dstream.cc\ - matdebug.cc interval.cc scalar.cc + matdebug.cc scalar.cc -templatecc=cursor.cc list.cc tsmat.cc plist.cc +templatecc=cursor.cc list.cc tsmat.cc plist.cc interval.cc inl=findcurs.inl link.inl list.inl cursor.inl plist.inl hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.hh \ string.hh stringutil.hh vray.hh textdb.hh textstr.hh assoc.hh\ findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\ smat.hh vsmat.hh vector.hh real.hh choleski.hh\ tsmat.hh tvsmat.hh plist.hh associter.hh fproto.hh\ - interval.hh scalar.hh sstack.hh + interval.hh scalar.hh sstack.hh rational.hh diff --git a/flower/Variables.make b/flower/Variables.make index ca0275af87..9d58ba9063 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,14 +1,32 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=16 - +PATCHLEVEL=17 PACKAGENAME=flower -VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) -DNAME=$(PACKAGENAME)-$(VERSION) -DEFINES=-DNDEBUG -O2 -#DEFINES=-g + +#PROFILEFLAG=-pg +DEBUGFLAG=-g -O2 +OPTIFLAG=-DNDEBUG -DNPRINT -O2 + +######################################### + +ifdef PROFILEFLAG + DEFINES+=$(OPTIFLAG) $(PROFILEFLAG) + EXTRALIB+=-pg +endif + +ifndef DEBUGFLAG + DEFINES+=$(OPTIFLAG) +else + DEFINES+=$(DEBUGFLAG) +endif + + CXXFLAGS+=$(DEFINES) -Wall -W CXXVER=$(CXX) --version + +VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) +DNAME=$(PACKAGENAME)-$(VERSION) + include Sources.make obs=$(cc:.cc=.o) diff --git a/flower/compare.hh b/flower/compare.hh index 40bc9d2951..f0e886e539 100644 --- a/flower/compare.hh +++ b/flower/compare.hh @@ -37,8 +37,8 @@ prefix one_operator(type, function, !=)\ prefix one_operator(type, function, <)\ prefix one_operator(type, function, <=)\ gpp_minmax(type, prefix)\ -prefix inline type MAX(type t1, type t2) { return (t1 > t2 )? t1 : t2; }\ -prefix inline type MIN(type t1, type t2) { return (t1 < t2 )? t1 : t2; }\ +prefix inline type max(type t1, type t2) { return (t1 > t2 )? t1 : t2; }\ +prefix inline type min(type t1, type t2) { return (t1 < t2 )? t1 : t2; }\ \ prefix bool operator<(type t1, type t2) /* stupid fix to allow ; */ /** diff --git a/flower/fproto.hh b/flower/fproto.hh index 8e30550696..4452176d19 100644 --- a/flower/fproto.hh +++ b/flower/fproto.hh @@ -17,10 +17,13 @@ template struct Cursor; template struct PCursor; template struct Link; template struct Handle ; +templatestruct Interval_t ; +#include "real.hh" +typedef Interval_t Interval; struct Choleski_decomposition ; -struct Interval ; + struct long_option_init ; struct Getopt_long ; struct Matrix ; diff --git a/flower/interval.cc b/flower/interval.cc index f176c7486f..46b4fc7e16 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -4,80 +4,90 @@ #include "string.hh" -const Real INFTY = HUGE; -void -Interval::set_empty() { - min = INFTY; - max = -INFTY; -} +template +int +Interval__compare(const Interval_t&a,Interval_t const&b) +{ + if (a.left == b.left && a.right == b.right) + return 0; + + if (a.left <= b.left && a.right >= b.right) + return 1; -Real -Interval::length() const { - assert(max >= min); - return max-min; -} + if (a.left >= b.left && a.right <= b.right) + return -1; -void -Interval::unite(Interval h) -{ - compare(h, *this ); - if (h.minmax) - max = h.max; + assert(false); // not comparable + + return 0; } +const Real INFTY = HUGE; + +template void -Interval::intersect(Interval h) -{ - min = MAX(h.min, min); - max = MIN(h.max, max); +Interval_t::set_empty() { + left = INFTY; + right = -INFTY; } -Interval -intersection(Interval a, Interval const&b) -{ - a.intersect(b); - return a; - +template +T +Interval_t::length() const { + assert(right >= left); + return right-left; } -int -Interval::compare(const Interval&a,Interval const&b) +template +void +Interval_t::unite(Interval_t h) { - if (a.min == b.min && a.max == b.max) - return 0; - - if (a.min <= b.min && a.max >= b.max) - return 1; - - if (a.min >= b.min && a.max <= b.max) - return -1; + if (h.leftright) + right = h.right; +} - assert(false); // not comparable +/** + smallest Interval which includes *this and #h# + */ - return 0; +template +void +Interval_t::intersect(Interval_t h) +{ +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) + left = h.left >? left; + right = h.right +Interval_t +intersect(Interval_t x, Interval_t const &y) { x.intersect(y); return x; } - + +template String -Interval::str() const +Interval_t::str() const { if (empty()) return "[empty]"; String s("["); - return s + min + "," + max +"]"; + return s + left + "," + right +"]"; } + +template bool -Interval::elt_q(Real r) +Interval_t::elt_q(T r) { - return r >= min && r <= max; + return r >= left && r <= right; } diff --git a/flower/interval.hh b/flower/interval.hh index 5331c1d125..4184451701 100644 --- a/flower/interval.hh +++ b/flower/interval.hh @@ -12,82 +12,104 @@ #include "real.hh" -/// a Real interval -struct Interval { - Real min, max; +/// a T interval +template +struct Interval_t { + T left, right; /****************/ - Real center() { return (min + max) /2;} - void translate(Real t) { - min += t; - max += t; + T center() { return (left + right) /2;} + void translate(T t) { + left += t; + right += t; } - Real operator[](int j) { + T operator[](int j) { if (j==-1) - return min; + return left; else if (j==1) - return max; + return right; else assert(false); - return 0.0; - + return 0; } - void unite(Interval h) ; + void unite(Interval_t h); /** PRE *this and h are comparable */ - void intersect(Interval h); + void intersect(Interval_t h); - Real length() const; + T length() const; void set_empty() ; - bool empty() const { return min > max; } - Interval() { + bool empty() const { return left > right; } + Interval_t() { set_empty(); } - Interval(Real m, Real M) { - min =m; - max = M; + Interval_t(T m, T M) { + left =m; + right = M; } - Interval &operator += (Real r) { - min += r; - max +=r; + Interval_t &operator += (T r) { + left += r; + right +=r; return *this; } - bool elt_q(Real r); - String str() const; - - /// partial ordering - static compare(const Interval&,Interval const&); - /** - inclusion ordering. Crash if not comparable. - */ + String str() const; + bool elt_q(T r); }; /** - this represents the closed interval [min,max]. - No invariants + this represents the closed interval [left,right]. + No invariants. T must be a totally ordered ring + */ + +/// partial ordering +template +int Interval__compare(const Interval_t&,Interval_t const&); +/** + inclusion ordering. Crash if not comparable. */ -Interval intersection(Interval, Interval const&); +/**************************************************************** + INLINE + ****************************************************************/ #include "compare.hh" -instantiate_compare(Interval&, Interval::compare); +template_instantiate_compare(Interval_t&, Interval__compare, template); +template +inline Interval_t +intersection(Interval_t a, Interval_t const&b) +{ + a.intersect(b); + return a; + +} + + +template inline -Interval operator +(double a,Interval i ) +Interval_t operator +(T a,Interval_t i ) { i += a; return i; } +template inline -Interval operator +(Interval i,double a ){ +Interval_t operator +(Interval_t i,T a ){ return a+i; } +typedef Interval_t Interval; + + +#define Interval__instantiate(T) template struct Interval_t;\ + template int Interval__compare(const Interval_t&,Interval_t const&) + + #endif // INTERVAL_HH diff --git a/flower/rational.hh b/flower/rational.hh new file mode 100644 index 0000000000..30fa2cb6d6 --- /dev/null +++ b/flower/rational.hh @@ -0,0 +1 @@ +#include diff --git a/flower/real.hh b/flower/real.hh index 68e90f9b71..16f52b5092 100644 --- a/flower/real.hh +++ b/flower/real.hh @@ -1,29 +1,16 @@ #ifndef REAL_HH #define REAL_HH -typedef double Real; -inline Real sqr(Real x){ - return x*x; -} -inline Real MIN(Real x, Real y) { - return (x < y)? x : y; -} -inline Real MAX(Real x, Real y) { - return (x > y) ? x : y; -} -inline Real ABS(Real x) -{ - return (x>0)? x:-x; -} -inline -int sgn(Real x) { - if (!x)return 0; - return (x > 0) ?1: -1; -} +#include +#include +#include + +typedef double Real; + inline Real distance(Real x,Real y) { - return ABS(x-y); + return abs(x-y); } #endif diff --git a/flower/scalar.cc b/flower/scalar.cc index b53693928f..f981bc101f 100644 --- a/flower/scalar.cc +++ b/flower/scalar.cc @@ -1,6 +1,25 @@ #include #include "scalar.hh" +Scalar::Scalar(Rational r) + :String(r) +{ + +} + +Scalar::operator Rational() +{ + int p = pos('/'); + if (!p) + return int(*this); + + String s2 = right(len()-p); + p--; + String s1 = left(p); + + return Rational(s1.value(), s2.value()); +} + bool Scalar::isnum() { @@ -23,6 +42,7 @@ Scalar::operator int() assert (isnum()); return value(); } + bool Scalar::to_bool() const { diff --git a/flower/scalar.hh b/flower/scalar.hh index 5d02d6936c..67ae85beda 100644 --- a/flower/scalar.hh +++ b/flower/scalar.hh @@ -17,6 +17,8 @@ struct Scalar : public String { Scalar(char c) : String(c) {} Scalar(const char *c) : String(c) {} Scalar(String s ):String(s) {} + Scalar(Rational ); + operator Rational(); Scalar() {} bool isnum(); operator Real(); diff --git a/flower/string.cc b/flower/string.cc index 9c6792c021..0804c5bbdc 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -40,6 +40,20 @@ static char* strupr( char* s ) return s; } +String::String(Rational r) +{ + char * n = Itoa(r.numerator()); // LEAK???? + + *this = n; + if (r.denominator() != 1) { + char * d = Itoa(r.denominator()); + *this += '/' + String(d); + //delete d; + } +/* delete n; + */ +} + // return array, alloced with new. char * String::copy_array() const @@ -119,12 +133,14 @@ String::cptr() const // signed comparison, analogous to strcmp; int -String::compare( const char* test ) const +String::compare(const String& s1,const String &s2 ) { - if (test == (const char *) data) + const char * p1=s1.cptr(); + const char * p2 = s2.cptr(); + if (p1 == p2) return 0; - return strcmp(data, test); + return strcmp(p1,p2); } diff --git a/flower/string.hh b/flower/string.hh index 8008f06394..7ed274979d 100644 --- a/flower/string.hh +++ b/flower/string.hh @@ -15,7 +15,7 @@ #include #include - +#include #include "stringutil.hh" @@ -29,7 +29,7 @@ public: /// init to "" String() { } /** needed because other constructors are provided.*/ - + String(Rational); /// String s = "abc"; String( const char* source ); @@ -86,10 +86,11 @@ public: String nomid(int pos, int n ) const; /// signed comparison, analogous to strcmp; - int compare( const char* s ) const; - + static int compare(const String& s1,const String& s2); + /// index of rightmost c int lastPos( char c) const; + /// index of rightmost element of string int lastPos( const char* string ) const; @@ -141,14 +142,25 @@ public: convert to const char *. */ +#include "compare.hh" + +instantiate_compare(const String &, String::compare); // because const char* also has an operator ==, this is for safety: -inline bool operator==(String s1, String s2){ return !(s1.compare(s2));} -inline bool operator==(String s1, const char *s2){ return !(s1.compare(s2));} -inline bool operator==(const char *s1, String s2){ return !(s2.compare(s1));} -inline bool operator!=(String s1, const char *s2 ) { return s1.compare(s2);} -inline bool operator!=(const char *s1,String s2) { return s2.compare(s1);} -inline bool operator!=(String s1, String s2 ) { return s1.compare(s2);} +inline bool operator==(String s1, const char *s2){ + return s1 == String(s2); +} +inline bool operator==(const char *s1, String s2) +{ + return String(s1)==s2; +} +inline bool operator!=(String s1, const char *s2 ) { + return s1!=String(s2); +} +inline bool operator!=(const char *s1,String s2) { + return String(s2) !=s1; +} + inline String operator + (String s1, String s2) diff --git a/hdr/debug.hh b/hdr/debug.hh index e86fe2247d..1d1ae745c3 100644 --- a/hdr/debug.hh +++ b/hdr/debug.hh @@ -7,6 +7,7 @@ void error(String s); // errors void error_t(String s, Real when); + // warnings void warning(String s); #define WARN warnout << "warning: "<<__FUNCTION__ << "(): " @@ -26,5 +27,4 @@ extern Dstream monitor; // monitor extern bool check_debug; - #endif diff --git a/hdr/identparent.hh b/hdr/identparent.hh index 2e65537fc0..addfd26e0b 100644 --- a/hdr/identparent.hh +++ b/hdr/identparent.hh @@ -20,8 +20,7 @@ struct Identifier virtual const char*classname() { return "new Identifier"; } void error(); virtual Input_staff * staff(bool = false) { error(); return 0; } - virtual Horizontal_music*hmusic(bool = false) { error(); return 0; } - virtual Vertical_music*vmusic(bool = false) { error(); return 0; } + virtual Input_music *music(bool = false) { error(); return 0; } virtual Music_voice *mvoice(bool = false) { error(); return 0; } virtual Symtables *symtables(bool = false) { error(); return 0; } virtual Music_general_chord *mchord(bool = false) { error(); return 0; } diff --git a/hdr/inputcommand.hh b/hdr/inputcommand.hh index 0f32a34d48..47882a2374 100644 --- a/hdr/inputcommand.hh +++ b/hdr/inputcommand.hh @@ -11,8 +11,6 @@ #include "vray.hh" struct Input_command { - Real when; - /// analogous to argv[] svec args; void print()const; @@ -28,11 +26,6 @@ Input_command *get_reset_command(); Input_command *get_partial_command(Real u); Input_command* get_skip_command( int,Real); Input_command* get_grouping_command( svec); - -void -interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat, - Real& whole_per_measure); - -Input_command *get_bar_command(Real ); +Input_command *get_bar_command( ); #endif // INPUTCOMMAND_HH diff --git a/hdr/inputcommands.hh b/hdr/inputcommands.hh index 083c830aa9..c5b594359b 100644 --- a/hdr/inputcommands.hh +++ b/hdr/inputcommands.hh @@ -6,58 +6,64 @@ #ifndef INPUTCOMMANDS_HH #define INPUTCOMMANDS_HH + #include "pcursor.hh" #include "proto.hh" #include "plist.hh" #include "real.hh" +struct Commands_at : public IPointerList { + Real when; -struct Input_cursor : public PCursor -{ /// current measure info Real whole_per_measure; /// where am i Real whole_in_measure; - - /// Real last when which was read - Real last; - int bars; + /// idem - Input_cursor(PCursor); - /// hmm. not safe. Should rethink cursor. - void operator++(int); - /** warning: no optor -- () defined.. */ - void reset(); - Real when()const; + int bars; + + /****************/ + void print() const; + Real barleft(); void add(Input_command*); void setpartial(Real); - void addbot(Input_command*); - void sync(); - void print()const; - void last_command_here(); + Commands_at(const Commands_at&); + Commands_at(Real, Commands_at*prev); +}; + +struct Input_cursor : public PCursor +{ + /****************/ + Input_cursor(PCursor); + Real when()const; + void find_moment(Real w); + void prev() { operator --(0); } + void next() { operator ++(0); } }; /// the list of commands in Score -struct Input_commands : public IPointerList { +struct Input_commands : public IPointerList { Input_cursor ptr; - + /****************/ void find_moment(Real); - void do_skip(int & bars, Real & wholes); - void truncate(Real); - + void add(Input_command c); + void do_skip(int bars, Real wholes); + Input_commands(); Input_commands(Input_commands const&); - void add(Input_command); + void reset(); void print()const; Staff_commands *parse() const; }; + void interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat, Real& whole_per_measure); diff --git a/hdr/inputmusic.hh b/hdr/inputmusic.hh index 57ddf79443..d3286135f8 100644 --- a/hdr/inputmusic.hh +++ b/hdr/inputmusic.hh @@ -9,11 +9,10 @@ #include "plist.hh" #include "proto.hh" +#include "voice.hh" struct Voice_list : public PointerList { void translate_time(Real dt); - /// delete stuff; not in destructor! - void junk(); }; /// ABC for input structures @@ -21,9 +20,13 @@ struct Input_music { virtual Voice_list convert()=0; virtual Real length()=0; virtual void translate_time(Real dt)=0; - virtual ~Input_music(); + virtual ~Input_music(){} virtual void print() const =0; // virtual void transpose(...) const =0; + + + virtual Input_music *clone() const = 0; + virtual Simple_music *simple() { return 0; } }; /** @@ -37,96 +40,80 @@ struct Input_music { */ +/// Simple music consists of one voice +struct Simple_music : Input_music { + Voice voice_; -/// -struct Vertical_music : Input_music { - virtual Vertical_music *clone() const = 0; - - /// check if it is a simple voice - virtual Vertical_simple *simple() { return 0;} -}; -/** - chord like : - - - different music forms which start at the same time ( stacked "vertically" ) - - This class really doesn't do very much, but it enables you to say - - a Music_voice is a List - - */ - -/// -struct Horizontal_music : Input_music { - virtual Voice_list convert()=0; - virtual Horizontal_music *clone() const = 0; -}; -/** - voice like. - - different music forms which start after each other ( concatenated, - stacked "horizontally ) - - This class really doesn't do very much, but it enables you to say - - a Chord is a List - - */ - -/// the most basic element of a chord: a simple voice -struct Vertical_simple : Vertical_music { - Voice * voice_; // should be a real member - - /****************/ - Vertical_simple(Vertical_simple const&); - Vertical_simple(); - ~Vertical_simple(); + /****/ + virtual Simple_music*simple() { return this; } void add(Voice_element*); - virtual Vertical_simple*simple() { return this; } virtual Real length(); virtual Voice_list convert(); virtual void translate_time(Real dt); - virtual Vertical_music *clone() const { - return new Vertical_simple(*this); + virtual void print() const; + virtual Input_music *clone() const { + return new Simple_music(*this); } + +}; + +/// Complex_music consists of multiple voices +struct Complex_music : Input_music { + IPointerList elts; + + void add(Input_music*); + Complex_music(); + Complex_music(Complex_music const &); virtual void print() const ; + void concatenate(Complex_music*); + }; -/// the only child of Horizontal_music -struct Music_voice : Horizontal_music { - IPointerList voice_ ; +/// multiple stuff after each other +struct Music_voice : Complex_music { + /****************/ - Music_voice() {} - Music_voice(Music_voice const&); Real length(); - void add(Vertical_music*); - void add(Voice_element*); - virtual Voice_list convert(); virtual void translate_time(Real dt); - virtual Horizontal_music *clone() const { + virtual Voice_list convert(); + void add_elt(Voice_element*); + virtual Input_music *clone() const { return new Music_voice(*this); } - void concatenate(Music_voice*); virtual void print() const ; }; -/// -struct Music_general_chord : Vertical_music { - IPointerList chord_; +/** + voice like. + + different music forms which start after each other ( concatenated, + stacked "horizontally ) + + */ + +/// Multiple musicstuff stacked on top of each other +struct Music_general_chord : Complex_music { + IPointerList chord_; /****************/ - Music_general_chord() {} - Music_general_chord(Music_general_chord const&s); - void add(Horizontal_music*); + virtual Real length(); virtual Voice_list convert(); virtual void translate_time(Real dt); - virtual Vertical_music *clone() const { + void add_elt(Voice_element*); + virtual Input_music *clone() const { return new Music_general_chord(*this); } - void concatenate(Music_general_chord*); + virtual void print() const ; }; +/** + chord like : + + - different music forms which start at the same time ( stacked "vertically" ) + + */ + #endif // INPUTMUSIC_HH diff --git a/hdr/inputstaff.hh b/hdr/inputstaff.hh index abfcc52f61..e2caea7dc2 100644 --- a/hdr/inputstaff.hh +++ b/hdr/inputstaff.hh @@ -15,11 +15,11 @@ struct Input_staff { String type; IPointerList commands_; - IPointerList music_; + IPointerList music_; /****************/ - void add(Horizontal_music*m); + void add(Input_music*m); Input_staff(Input_staff&); Input_staff(String); void add(svec &s); diff --git a/hdr/keyword.hh b/hdr/keyword.hh index df4547ad76..b081df3a62 100644 --- a/hdr/keyword.hh +++ b/hdr/keyword.hh @@ -1,3 +1,12 @@ +/* + keyword.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef KEYWORD_HH +#define KEYWORD_HH + /* for the keyword table */ struct Keyword_ent { @@ -12,3 +21,7 @@ struct Keyword_table Keyword_table(Keyword_ent *); int lookup(const char *s) const; }; + + +#endif // KEYWORD_HH + diff --git a/hdr/lexer.hh b/hdr/lexer.hh index 7284dd40eb..239b7bbe0b 100644 --- a/hdr/lexer.hh +++ b/hdr/lexer.hh @@ -1,17 +1,50 @@ #ifndef LEXER_HH #define LEXER_HH - +#include #include "proto.hh" - -void new_input(String s); +#include "fproto.hh" +#include "sstack.hh" +#include "string.hh" int yylex(); void yyerror(const char *s); bool busy_parsing(); -int lookup_keyword(String s); - -Identifier* lookup_identifier(String s); -void add_identifier(Identifier*i); -void delete_identifiers(); void kill_lexer(); +void set_lexer(); + +struct Input_file { + istream*is; + int line; + String name; + + Input_file(String); + ~Input_file(); +}; + + +/// lexer with provisions for include files. +struct My_flex_lexer : yyFlexLexer { + + sstack include_stack; + Assoc *the_id_tab; + Keyword_table * keytable; + Notename_tab * defaulttab; + + /****************/ + + void set(Notename_tab *n); + int lookup_keyword(String); + void lookup_notename(int &large, int &small, String s); + void LexerError(const char *); + Identifier*lookup_identifier(String s); + My_flex_lexer(); + void add_identifier(Identifier*i); + ~My_flex_lexer(); + void new_input(String s); + bool close_input(); + int yylex(); +}; + +extern My_flex_lexer *lexer; + #endif diff --git a/hdr/lookup.hh b/hdr/lookup.hh index 7e59dac0fa..ecb55bd03c 100644 --- a/hdr/lookup.hh +++ b/hdr/lookup.hh @@ -17,7 +17,7 @@ struct Lookup { Real internote(); Symbol linestaff(int n, Real w); - + Symbol fill(Box b); Symbol beam_element(int,int,Real=0); /// round slope to closest TeXslope Symbol beam(Real&,Real); diff --git a/hdr/misc.hh b/hdr/misc.hh index 763ebbc250..376f048c0e 100644 --- a/hdr/misc.hh +++ b/hdr/misc.hh @@ -1,8 +1,11 @@ #ifndef MISC_HH #define MISC_HH +#include "real.hh" -double log2(double x) ; +Real wholes(int dur, int dots); + +double log_2(double x) ; int intlog2(int d); inline int ABS(int i) diff --git a/hdr/proto.hh b/hdr/proto.hh index ebc4fd1398..09465e3e85 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -80,14 +80,16 @@ struct Voice_element; struct Voicegroup; struct Voice_list; -struct Vertical_music; -struct Horizontal_music; -struct Horizontal_simple; -struct Vertical_simple ; +struct Input_music; +struct Simple_music; +struct Complex_music; struct Music_voice; struct Music_general_chord; + struct Input_score; struct Input_staff; struct Input_command; struct Notename_tab; +struct Input_file; +struct Keyword_table; #endif // PROTO_HH diff --git a/kortjakje.ly b/kortjakje.ly index 392bd19678..f5e6d08139 100644 --- a/kortjakje.ly +++ b/kortjakje.ly @@ -2,19 +2,39 @@ % % bare bones version. (written down from memory :-) -melodie = music {$\octave {} +% the % is a comment. + +% declare music (which will be in *one* staff ) for the lead voice + +melodie = music { + $ % switch Lilypond in note-mode + \octave {} % set the default octave + % the default note duratino is 4 %%% theme - c c g g a a g2 f f e e d d c2 + c c g g a a + g2 % g2 means a "g-1" pitched half-note + f f e e d d c2 g g f f e e d d g g f f e e d d %%% var 1 - c r8 c8 ( ) g r8 g8 ( ) a r8 a8 ( ) g r4 + c r8 c8 % r8 means an 8th rest. + ( % start a slur + % NOTE: the slurstart should be directly after the note + ) % end a slur. + g r8 g8 ( ) a r8 a8 ( ) g r4 f r8 f8 ( ) e4 r8 e8 ( ) d4 r8 d8 ( ) c4 r4 $} -begeleiding = $\music { - \octave { ` } + % more of this. +begeleiding = +$ + \music { % as you can see, the $ sign obliges + % you to precede keyword by a backslash: \ + \octave { ` } % default octave: 1 below the first octave. + %%% theme - `c c e c f c e c d `b c `a `f `g `c2 + `c % ` means one octave lower. + % Similarly: ' means one higher. + c e c f c e c d `b c `a `f `g `c2 \octave { ` } e `g d `g c `g `b `g e `g d `g c `g `b `g %%%% var 1 @@ -23,16 +43,21 @@ begeleiding = $\music { }$ +% create a staff named bstaf bstaf = staff { melodic - music { begeleiding } - commands { - clef bass + music { begeleiding } % use the declared music + commands { % commands with Staff-wide impact. + clef bass % bass-clef + } } + +% another one vstaf = staff { melodic music { melodie } + % default clef is violin clef } @@ -40,11 +65,12 @@ score { staff { vstaf } staff { bstaf } paper { - unitspace 2.5cm + unitspace 2.5cm % a whole note takes 2.5 cm ideally. } commands { - meter 2 4 - skip 32:0 + meter 2 4 % a 2/4 meter. + skip 32:0 % skip 32 measures, and generate the bars + meter 6 8 % another meter } } diff --git a/maartje.ly b/maartje.ly index 912f9e97ee..a0cffa1190 100644 --- a/maartje.ly +++ b/maartje.ly @@ -1,6 +1,7 @@ ritme = staff {rhythmic music {$ - c8 c2 c2 + c8 + c2 c2 %[c8( )'a8 c8 c8] c2 c2 @@ -20,19 +21,20 @@ ritme = staff {rhythmic melody= staff { melodic music{$ - c8 +c8 r1 'cis2.. r8 r4 r8 r16 r32 r32 - \duration {4} \chord { + \duration {4} + { \music { c () `bes c} \music { 'fis ()'gisis fis } \music { d () d dis } \music { a () bes eis } \music { fis () g gis } } - c4 + { c4 'c4 } [d8 e8 'f8 g8] d8 e8 f8 g8 ''fis2 @@ -44,8 +46,8 @@ staff { melodic $} commands { - skip 0:0.125 - skip 1:0 % BUG!! +% skip 0:0.125 + skip 3:0 % BUG!! key $ fis cis gis $ skip 2:0 key $ $ @@ -65,7 +67,8 @@ score { % staff { melody } commands { meter 4 4 - partial 0.125 skip 0:0.125 + partial 8 + skip 1:0 skip 2:0 meter 2 4 skip 19:0 diff --git a/make_patch b/make_patch index 8747fe6b84..8f8a688cd7 100755 --- a/make_patch +++ b/make_patch @@ -31,5 +31,5 @@ fi #(cd $nm$old; touch depend; make clean) #(cd $nm$new; touch depend; make clean) -(cd $nm$new; diff -P -c ../$nm$old . > ../patch-$new) +(cd $nm$new; diff -rP -c ../$nm$old . > ../patch-$new) rm -rf $nm$old $nm$new diff --git a/pavane.ly b/pavane.ly index 5c1703cfc9..fd66d490cd 100644 --- a/pavane.ly +++ b/pavane.ly @@ -20,7 +20,7 @@ staff {melodic % 11 )`b [`fis `a `b] cis4 `b4 `fis2 r2 cis4 d4()[d cis d e] - \octave { '` } + \octave { } a4 gis2. a4 b4()[b a b 'cis] fis4 e4 cis2 e4 fis4 () [fis e fis gis] cis4 `b4()`b8 r8 r4 @@ -43,7 +43,6 @@ staff {melodic key $fis cis $ } } - score { staff { horn @@ -53,7 +52,8 @@ score { unitspace 1.5 cm geometric 1.4 } - commands { meter 4 4 + commands {meter 4 4 + skip 18:0 meter 2 4 skip 1:0 diff --git a/src/beam.cc b/src/beam.cc index c897ebfc66..3d43b4ed1d 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -22,6 +22,7 @@ struct Stem_info { Stem_info(){} Stem_info(const Stem*); }; + Stem_info::Stem_info(const Stem*s) { x = s->hpos(); diff --git a/src/command.cc b/src/command.cc index 19b7aac6d7..94d3bb94d2 100644 --- a/src/command.cc +++ b/src/command.cc @@ -15,8 +15,6 @@ Command::Command() priority=0; } - - Command::Command(Real w) { code = NOP; diff --git a/src/debug.cc b/src/debug.cc index 7620027c91..eaed33f080 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1,5 +1,6 @@ #include #include +#include #include "debug.hh" #include "dstream.hh" #include "vector.hh" @@ -33,3 +34,34 @@ set_debug(bool b) { check_debug =b; } + + +#if 0 // want to debug mem functions + + +/// +static +void foobulize(void *p , size_t s) +{ +// assert(s < 2000000); + memset(p, 0xf0, s); +} +/** + trash a portion of memory. Make sure access to deleted stuff is bogus. + */ +void * +operator new (size_t s) +{ + void *p = malloc(s); + assert(p); +// foobulize(p,s); + return p; +} + +void +operator delete(void *p, size_t s) +{ + foobulize(p,s); + free(p); +} +#endif diff --git a/src/identifier.cc b/src/identifier.cc index 5b552898a9..6241768694 100644 --- a/src/identifier.cc +++ b/src/identifier.cc @@ -2,10 +2,11 @@ #include "identparent.hh" #include "lexer.hh" +#include "debug.hh" void Identifier::error() { String e("Wrong identifier type: "); - yyerror(e + classname()); + ::error(e + classname()); } diff --git a/src/inputcommand.cc b/src/inputcommand.cc index 938fc3e01a..1c48eea52a 100644 --- a/src/inputcommand.cc +++ b/src/inputcommand.cc @@ -4,17 +4,15 @@ Input_command::Input_command() { - when = -1; } -Input_command::Input_command(Real w) +Input_command::Input_command(Real ) { - when =w; } Input_command::operator Command() { - Command c(when); + Command c; if (!args.sz()) return c; @@ -92,10 +90,10 @@ get_meterchange_command(int n, int m) } Input_command * -get_bar_command(Real w) +get_bar_command() { Input_command*c = new Input_command; - c->when = w; + c->args.add( "BAR"); c->args.add( "|"); @@ -118,7 +116,7 @@ get_skip_command(int n, Real m) void Input_command::print()const { - mtor << "{ at " << when; + mtor << "{ "; if (args.sz()) { mtor<< " args: "; for (int i = 0; i &me(*this); - const IPointerList &that(src); - - PL_copy(me, that); +#ifndef NPRINT + mtor << "{ at "< cc(*this); cc.ok(); cc++) + cc->print(); + mtor << "}\n"; +#endif } -Input_commands::Input_commands() - : ptr (bottom()) +Commands_at::Commands_at(Real dt, Commands_at* prev) { - Input_command c(0.0); - bottom().add(new Input_command(c)); - ptr = bottom(); + if (prev) { + assert(dt >0); + when = prev->when + dt; + whole_per_measure = prev->whole_per_measure; + whole_in_measure = prev->whole_in_measure + dt; + bars = prev->bars; + + while ( whole_in_measure >= whole_per_measure ) { + whole_in_measure -= whole_per_measure; + bars ++; + } + if (!whole_in_measure) { + bottom().add(get_bar_command()); + } + } else { + whole_per_measure = 1; + whole_in_measure =0; + when = 0.0; + bars = 0; + } } void -Input_commands::truncate(Real last) +Commands_at::add(Input_command *i ) +{ + bottom().add(i); + if (i->args[0] == "METER") { // should check for other meterchanges here. + Real l = i->args[1]; + Real o = i->args[2]; + whole_per_measure = l/o; + } +} + +Commands_at::Commands_at(Commands_at const&src) { - bool reset_ = false; + when = src.when; + whole_in_measure = whole_in_measure; + whole_per_measure = whole_per_measure; + bars = src.bars; - if (ptr.when() >= last) - reset_=true; - PCursor i(*this); + IPointerList &me(*this); + const IPointerList &that(src); - while (i.ok() && i ->when < last) - i++; + PL_copy(me, that); +} - while (i.ok()) - i.del(); +void +Commands_at::setpartial(Real p) +{ + if (when) + error_t ("Partial measure only allowed at beginning.", when); + if (p<0||p > whole_per_measure) + error_t ("Partial measure has incorrect size", when); + whole_in_measure = whole_per_measure - p; +} +Real +Commands_at::barleft() + +{ + return whole_per_measure-whole_in_measure; +} - if (reset_) { - reset(); +/****************/ + +void +Input_cursor::find_moment(Real w) +{ + Real last = when(); + while (1) { + if (! ok() ) { + *this = PCursor(list().bottom()); + Real dt = (w - when()) barleft(); + assert(dt >= 0); + Commands_at * c = new Commands_at(dt, *this); + add(c); + } else if (when() == w ) { + return ; + } else if (when() > w ) + break; + - while(ptr.ok()) - ptr++; + last = when(); + next(); } + + prev(); + Real dt = (w - when()); + Commands_at * c = new Commands_at(dt, *this); + add(c); + next(); } -/* - ugh. This sux. - */ -void -Input_commands::find_moment(Real w) + + +/****************/ +Input_commands::Input_commands(Input_commands const&src) + : ptr(src.ptr) { - assert(w >= ptr.when()); - while (ptr.ok() && ptr.when() < w) { - ptr++; - } + IPointerList &me(*this); + const IPointerList &that(src); - if (!ptr.ok()) { - int bars_left =int(floor( (w - ptr.last + ptr.whole_in_measure) - /ptr.whole_per_measure)); - if (bars_left) { - Real bar_when = ptr.last - ptr.whole_in_measure + ptr.whole_per_measure; - ptr.addbot(get_bar_command(bar_when)); - find_moment(w); // tail-recursion. todo - } else { - ptr.addbot(new Input_command(w)); - } + PL_copy(me, that); +} - } else if (ptr.when() != w) { - ptr.insert(new Input_command(w)); - ptr--; - } +Input_commands::Input_commands() + : ptr (bottom()) +{ + Commands_at * p = new Commands_at(0,0); + bottom().add(p); + ptr = bottom(); } void -Input_commands::do_skip(int & bars, Real & wholes) +Input_commands::do_skip(int bars, Real wholes) { - if (wholes) { - find_moment(ptr.when() +wholes); - wholes = 0.0; + while (bars > 0) { + Real b = ptr->barleft(); + ptr.find_moment(ptr->when + b); + bars --; } - - if (bars) { - ptr.last_command_here(); // find any METER change commands. - if (ptr.whole_in_measure){ - Real barleft = ptr.whole_per_measure - ptr.whole_in_measure; - do_skip(bars, barleft); - }else { - find_moment(ptr.when() + bars*ptr.whole_per_measure); - bars = 0; - } + if (wholes) { + ptr.find_moment(ptr->when + wholes); } } @@ -101,46 +153,30 @@ Input_commands::do_skip(int & bars, Real & wholes) void Input_commands::add(Input_command c) { - if (c.args[0] == "PARTIAL") { - Real p = c.args[1].fvalue(); - ptr.setpartial(p); - + if (c.args[0] == "PARTIAL") { + ptr->setpartial(c.args[1]); } else if (c.args[0] == "METER") { - int beats_per_meas, one_beat; - Real r; - - interpret_meter(&c, beats_per_meas, one_beat, r); + int beats_per_meas = c.args[1]; + int one_beat = c.args[2]; Input_command *ch = get_meterchange_command(beats_per_meas, one_beat); - ch->when = ptr.when(); - ptr.add(ch); - + ptr->add(ch); } else if (c.args[0] == "KEY" || c.args[0] == "CLEF") { Input_command *ic = new Input_command(c); - ic->when = ptr.when(); - ptr.add(ic); + ptr->add(ic); } else if (c.args[0] == "SKIP") { - int bars = c.args[1].value() ; - Real wholes= c.args[2].fvalue(); - while (bars > 0 || wholes > 0.0) { - do_skip(bars, wholes); - } + int bars = c.args[1] ; + Real wholes= c.args[2]; + do_skip(bars, wholes); } else if (c.args[0] == "RESET") { - reset(); + ptr= top(); } } -void -Input_commands::reset() -{ - ptr = top(); - ptr.reset(); -} - - Staff_commands* Input_commands::parse() const { + print(); Staff_commands*nc = new Staff_commands; { /* all pieces should start with a breakable. */ @@ -151,10 +187,14 @@ Input_commands::parse() const nc->process_add(c); } - for (PCursor cc(*this); cc.ok(); cc++) { - if (cc->args.sz() && cc->args[0] !="") - nc->process_add(**cc); - } + for (PCursor i(*this); i.ok(); i++) + for (PCursor cc(**i); cc.ok(); cc++) { + if (cc->args.sz() && cc->args[0] !="") { + Command c = **cc; + c.when = i->when; + nc->process_add(c); + } + } return nc; } @@ -164,9 +204,19 @@ void Input_commands::print() const { #ifndef NPRINT - for (PCursor cc(*this); cc.ok() ; cc++) { + for (PCursor cc(*this); cc.ok() ; cc++) { cc->print(); } - ptr.print(); #endif } +/****************/ + +Real +Input_cursor::when()const +{ + return (*this)->when; +} +Input_cursor::Input_cursor(PCursorc) + : PCursor(c) +{ +} diff --git a/src/inputcursor.cc b/src/inputcursor.cc deleted file mode 100644 index 4dc5f9310f..0000000000 --- a/src/inputcursor.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - it still sucks. - */ - -#include "inputcommands.hh" -#include "inputcommand.hh" -#include "debug.hh" -#include "staffcommands.hh" -#include "getcommand.hh" -#include "command.hh" - -void -interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat, - Real& whole_per_measure) -{ - beats_per_meas = c->args[1].value(); - one_beat = c->args[2].value(); - whole_per_measure = beats_per_meas/Real(one_beat); -} - -Real -Input_cursor::when()const -{ - return (*this)->when; -} - -void -Input_cursor::print() const -{ -#ifndef NPRINT - mtor << "meter " << whole_per_measure - << " pos "<< bars << ":" << whole_in_measure <<'\n'; -#endif -} - -void -Input_cursor::reset() -{ - whole_per_measure = 1.0; // ? - whole_in_measure =0.0; - bars = 0; - last=0; -} - -Input_cursor :: Input_cursor(PCursorc) - :PCursor(c) -{ - reset(); -} - -void -Input_cursor::sync() -{ - assert(ok()); - - whole_in_measure += when() - last; - while (whole_per_measure > 0 && whole_in_measure >= whole_per_measure) { - bars ++; - whole_in_measure -= whole_per_measure; - } - if (whole_in_measure < 1e-5) // ugr - whole_in_measure = 0.0; -} - -void -Input_cursor::operator++(int) -{ - last = when(); - (*(PCursor *) this) ++; - - if (ok()) { - sync(); - if (ptr()->args[0] == "METER") { - int i,j; - interpret_meter(ptr(), i, j, whole_per_measure); - } - } -} - -void -Input_cursor::addbot(Input_command*c) -{ - assert(!ok()); - add(c); -} - - -void -Input_cursor::add(Input_command*c) -{ - PCursor ::add(c); - (*this)++; -} - -void -Input_cursor::last_command_here() -{ - assert(ok()); - PCursor next = (*this)+1; - while (next.ok() && next->when == when()){ - *this = next; - next = *this +1; - - } -} - -void -Input_cursor::setpartial(Real p) -{ - if (when()) - error_t ("Partial measure only allowed at beginning.", when() ); - if (p<0||p > whole_per_measure) - error_t ("Partial measure has incorrect size", when()); - - whole_in_measure = whole_per_measure - p; -} diff --git a/src/inputmusic.cc b/src/inputmusic.cc index 6d3186bf73..db2e3c57d5 100644 --- a/src/inputmusic.cc +++ b/src/inputmusic.cc @@ -1,106 +1,104 @@ #include "debug.hh" #include "inputmusic.hh" #include "voice.hh" -Input_music::~Input_music() -{ -} -Vertical_simple::Vertical_simple() -{ - voice_ = new Voice; -} -Vertical_simple::Vertical_simple(Vertical_simple const&s) -{ - voice_ = new Voice(*s.voice_); -} + void -Vertical_simple::add(Voice_element*v) +Simple_music::add(Voice_element*v) { - voice_->add(v); + voice_.add(v); } Real -Vertical_simple::length() +Simple_music::length() { - return voice_->last(); + return voice_.last(); } void -Vertical_simple::translate_time(Real t) +Simple_music::translate_time(Real t) { - voice_->start += t; + voice_.start += t; } Voice_list -Vertical_simple::convert() +Simple_music::convert() { Voice_list l; - l.bottom().add(new Voice(*voice_)); + l.bottom().add(new Voice(voice_)); return l; } -Vertical_simple::~Vertical_simple() -{ - delete voice_; -} void -Vertical_simple::print() const +Simple_music::print() const { - mtor << "Vertical_simple {"; - voice_->print(); + mtor << "Simple_music {"; + voice_.print(); mtor << "}\n"; } /****************/ + void -Music_voice::print() const +Complex_music::add(Input_music*v) +{ + elts.bottom().add(v); +} + +void +Complex_music::print() const { - mtor << "Music_voice {"; - for (PCursor i(voice_); i.ok(); i++) + for (PCursor i(elts); i.ok(); i++) i->print(); - mtor << "}\n"; } void -Music_voice::concatenate(Music_voice*h) +Complex_music::concatenate(Complex_music*h) { - for (PCursor i(h->voice_); i.ok(); i++) + for (PCursor i(h->elts); i.ok(); i++) add(i->clone()); } +Complex_music::Complex_music() +{ +} -Music_voice::Music_voice(Music_voice const&s) +Complex_music::Complex_music(Complex_music const&s) { - for (PCursor i(s.voice_); i.ok(); i++) + for (PCursor i(s.elts); i.ok(); i++) add(i->clone()); } +/****************************************************************/ + void -Music_voice::add(Voice_element*v) +Music_voice::print() const { - PCursor c(voice_.bottom()); + mtor << "Music_voice {"; + Complex_music::print(); + mtor << "}\n"; +} + +void +Music_voice::add_elt(Voice_element*v) +{ + PCursor c(elts.bottom()); if (!c.ok() || !c->simple()) { - Vertical_simple*vs = new Vertical_simple; + Simple_music*vs = new Simple_music; c.add(vs); } - c = voice_.bottom(); - Vertical_simple *s = c->simple(); + c = elts.bottom(); + Simple_music *s = c->simple(); s->add(v); } -void -Music_voice::add(Vertical_music*v) -{ - voice_.bottom().add(v); -} - Real Music_voice::length() { Real l = 0.0; - for (PCursor i(voice_); i.ok(); i++) + for (PCursor i(elts); i.ok(); i++) l += i->length(); return l; } @@ -112,7 +110,7 @@ Music_voice::convert() Voice_list l; Real here = 0.0; - for (PCursor i(voice_); i.ok(); i++) { + for (PCursor i(elts); i.ok(); i++) { Real len = i->length(); Voice_list k(i->convert()); k.translate_time(here); @@ -126,59 +124,51 @@ Music_voice::convert() void Music_voice::translate_time(Real t) { - for (PCursor i(voice_); i.ok(); i++) - i->translate_time(t); + elts.bottom()->translate_time(t); } /****************/ + void -Music_general_chord::print() const +Music_general_chord::add_elt(Voice_element*v) { - mtor << "Music_general_chord {"; - for (PCursor i(chord_); i.ok(); i++) - i->print(); - mtor << "}\n"; + Simple_music*vs = new Simple_music; + vs->add(v); + elts.bottom().add(vs); } void -Music_general_chord::concatenate(Music_general_chord*v) +Music_general_chord::print() const { - for (PCursor i(v->chord_); i.ok(); i++) - add(i->clone()); + mtor << "Music_general_chord {"; + Complex_music::print(); + mtor << "}\n"; } void Music_general_chord::translate_time(Real t) { - for (PCursor i(chord_); i.ok(); i++) + for (PCursor i(elts); i.ok(); i++) i->translate_time(t); } - - Real Music_general_chord::length() { Real l =0.0; - for (PCursor i(chord_); i.ok(); i++) - l = MAX(l, i->length()); + for (PCursor i(elts); i.ok(); i++) + l = l >? i->length(); return l; } -void -Music_general_chord::add(Horizontal_music*h) -{ - chord_.bottom().add(h); -} - Voice_list Music_general_chord::convert() { Voice_list l; - for (PCursor i(chord_); i.ok(); i++) { + for (PCursor i(elts); i.ok(); i++) { Voice_list k(i->convert()); l.concatenate(k); } @@ -186,14 +176,6 @@ Music_general_chord::convert() } -Music_general_chord::Music_general_chord( - Music_general_chord const & s) -{ - for (PCursor i(s.chord_); i.ok(); i++) { - add(i->clone()); - } -} - /****************/ void @@ -203,9 +185,3 @@ Voice_list::translate_time(Real x) i->start += x; } -void -Voice_list::junk() -{ - for (PCursor i(*this); i.ok(); i++) - delete i.ptr(); -} diff --git a/src/inputstaff.cc b/src/inputstaff.cc index 2337f6ae2d..4a38d38bc1 100644 --- a/src/inputstaff.cc +++ b/src/inputstaff.cc @@ -24,7 +24,7 @@ Input_staff::Input_staff(String s) } void -Input_staff::add(Horizontal_music*m) +Input_staff::add(Input_music*m) { music_.bottom().add(m); } @@ -39,7 +39,7 @@ Input_staff::parse(PointerList score_wide) else if (type == "rhythmic") p = new Rhythmic_staff; - for (PCursor i(music_); i.ok(); i++) { + for (PCursor i(music_); i.ok(); i++) { Voice_list vl = i->convert(); p->add(vl); } @@ -59,7 +59,7 @@ Input_staff::Input_staff(Input_staff&s) { for (PCursor i(s.commands_); i.ok(); i++) commands_.bottom().add(new Input_command(**i)); - for (PCursor i(s.music_); i.ok(); i++) + for (PCursor i(s.music_); i.ok(); i++) add(i); type = s.type; @@ -72,7 +72,7 @@ Input_staff::print() const mtor << "Input_staff {\n"; for (PCursor i(commands_); i.ok(); i++) i->print(); - for (PCursor i(music_); i.ok(); i++) + for (PCursor i(music_); i.ok(); i++) i->print(); mtor << "}\n"; #endif diff --git a/src/key.cc b/src/key.cc index 0a5af6ffd7..dac8c266ec 100644 --- a/src/key.cc +++ b/src/key.cc @@ -63,7 +63,7 @@ Key::oldkey_undo(svecs) for (int i=0; i < newkey.sz(); i++) newkey[i] = 0; - for (int i=0; i < s.sz(); i++) { + for (int i=0; i < s.sz(); ) { int large = s[i++]; int small = s[i++]; newkey[large] = small; diff --git a/src/keyitem.cc b/src/keyitem.cc index 607e144f1a..71f1654f19 100644 --- a/src/keyitem.cc +++ b/src/keyitem.cc @@ -46,5 +46,9 @@ Keyitem::brew_molecole() a.translate(Offset(0,(c_position + pitch[i]) * inter)); Molecule m(a); output->add_right(m); - } + } + Molecule m(paper()->lookup_->fill(Box( + Interval(0, paper()->note_width()), + Interval(0,0)))); + output->add_right(m); } diff --git a/src/lexer.l b/src/lexer.l index c5c51f70b6..0b17abac66 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -1,37 +1,14 @@ %{ // -*-Fundamental-*- -#include #include -#include "glob.hh" + #include "string.hh" #include "notename.hh" #include "lexer.hh" -#include "keyword.hh" #include "vray.hh" #include "parser.hh" #include "debug.hh" -#include "sstack.hh" - -struct Input_file { - istream*is; - int line; - String name; - - Input_file(String); - ~Input_file(); -}; - -/// lexer with provisions for include files. -struct My_flex_lexer : yyFlexLexer { - sstack include_stack; - void new_input(String s); - bool close_input(); -}; -My_flex_lexer *lexer=0; - -static int last_print; -const int DOTPRINT=50; // every 50 lines dots %} %option c++ @@ -39,6 +16,7 @@ const int DOTPRINT=50; // every 50 lines dots %option nodefault %option yylineno %option debug +%option yyclass="My_flex_lexer" %x notes %x incl %x quote @@ -162,7 +140,7 @@ DOTS \.+ <> { mtor << "<>"; - if (! ((My_flex_lexer*) this)->close_input()) + if (! close_input()) yyterminate(); // can't move this, since it actually rets a YY_NULL } @@ -217,102 +195,3 @@ DOTS \.+ %% -int -yylex() { - return lexer->yylex(); -} - -void -yyerror(const char *s) -{ - String e; - if (lexer->include_stack.empty()) { - *mlog << "error at EOF" << s; - }else - *mlog << lexer->include_stack.top()->name << ": " << - lexer->lineno() << ": error:" << s << '\n'; - exit(1); -} - - -bool -busy_parsing() -{ - return lexer; -} - -void -kill_lexer() -{ - delete lexer; - lexer = 0; -} - -void -new_input(String s) -{ - if (!lexer) { - lexer = new My_flex_lexer; - lexer->set_debug( !monitor.silence("Lexer") && check_debug); - } - lexer->new_input(s); -} - -/****************/ - -Input_file::Input_file(String s) -{ - name = s; - line = 1; - if (s=="") - is = &cin; - else - is = new ifstream( s ); // - - if ( ! *is) { - String e("cant open " + s); - if (lexer) - yyerror(e); - else - error(e); - } - cout << "["<line = lineno(); - - Input_file *newin = new Input_file(s); - include_stack.push(newin); - switch_streams(newin->is); - yylineno = 1; -} - -// pop the inputstack. -bool -My_flex_lexer::close_input() -{ - Input_file *old = include_stack.pop(); - bool ok = true; - if (include_stack.empty()) { - ok = false; - } else { - Input_file *i = include_stack.top(); - switch_streams(i->is); - yylineno = i->line; - } - delete old; - return ok; -} diff --git a/src/lexerinit.cc b/src/lexerinit.cc new file mode 100644 index 0000000000..3bc0d31aed --- /dev/null +++ b/src/lexerinit.cc @@ -0,0 +1,61 @@ +#include +#include "lexer.hh" +#include "debug.hh" + +My_flex_lexer *lexer=0; + +int +yylex() { + return lexer->yylex(); +} + +void +yyerror(const char *s) +{ + lexer->LexerError(s); +} + +bool +busy_parsing() +{ + return lexer; +} + +void +kill_lexer() +{ + delete lexer; + lexer = 0; +} + +void +set_lexer() +{ + if (!lexer) { + lexer = new My_flex_lexer; + lexer->set_debug( !monitor.silence("Lexer") && check_debug); + } +} + +Input_file::Input_file(String s) +{ + name = s; + line = 1; + if (s=="") + is = &cin; + else + is = new ifstream( s ); + + if ( ! *is) { + String e("cant open " + s); + error(e); + } + cout << "["<lookup(String(j)); } - +Symbol +Lookup::fill(Box b) +{ + Symbol s( (*symtables_)("param")->lookup("fill")); + s.dim = b; + return s; +} Symbol Lookup::accidental(int j) { diff --git a/src/main.cc b/src/main.cc index 7ff09dfc34..c4b48ff238 100644 --- a/src/main.cc +++ b/src/main.cc @@ -29,6 +29,7 @@ help() void notice() { cout << + "\n" "LilyPond, a music typesetter.\n" "Copyright (C) 1996 by\n" " Han-Wen Nienhuys \n" @@ -77,11 +78,18 @@ main (int argc, char **argv) break; } } - char *arg = oparser.get_next_arg(); - - if (!arg) arg = ""; - parse_file(arg); - do_scores(); + int p=0; + char *arg ; + while ( (arg= oparser.get_next_arg()) ) { + parse_file(arg); + do_scores(); + p++; + } + if (!p) { + parse_file(""); + do_scores(); + } + exit (0); } diff --git a/src/misc.cc b/src/misc.cc index 51baac1211..30116303fc 100644 --- a/src/misc.cc +++ b/src/misc.cc @@ -3,6 +3,18 @@ #include +Real +wholes(int dur, int dots) +{ + Real f = 1.0/Real(dur); + Real delta = f; + + while (dots--) { + delta /= 2.0; + f += delta; + } + return f; +} int intlog2(int d) { int i=0; @@ -15,7 +27,7 @@ intlog2(int d) { } double -log2(double x) { +log_2(double x) { return log(x) /log(2.0); } diff --git a/src/mylexer.cc b/src/mylexer.cc new file mode 100644 index 0000000000..0a912e3389 --- /dev/null +++ b/src/mylexer.cc @@ -0,0 +1,129 @@ +#include "identparent.hh" +#include "associter.hh" +#include "lexer.hh" +#include "parser.hh" +#include "keyword.hh" +#include "assoc.hh" +#include "lexer.hh" +#include "sstack.hh" +#include "debug.hh" +#include "notename.hh" + +static Keyword_ent the_key_tab[]={ + "bar", BAR, + "bass", BASS, + "clef", CLEF, + "cm", CM, + "commands", COMMANDS, + "duration", DURATIONCOMMAND, + "geometric", GEOMETRIC, + "in", IN, + "key", KEY, + "melodic", MELODIC, + "meter", METER, + "mm", MM, + "octave", OCTAVECOMMAND, + "output", OUTPUT, + "partial", PARTIAL, + "paper", PAPER, + "pt", PT, + "rhythmic", RHYTHMIC, + "score", SCORE, + "skip", SKIP, + "staff", STAFF, + "start", START_T, + "table", TABLE, + "symboltables", SYMBOLTABLES, + "notenames", NOTENAMES, + "texid", TEXID, + "chord", CHORD, + "multi", MULTI, + "unitspace", UNITSPACE, + "violin", VIOLIN, + "voice", VOICE, + "voices", VOICES, + "width", WIDTH, + "music", MUSIC, + "grouping", GROUPING, + 0,0 +}; + +My_flex_lexer::My_flex_lexer() +{ + keytable = new Keyword_table(the_key_tab); + the_id_tab = new Assoc; + defaulttab = 0; +} + +int +My_flex_lexer::lookup_keyword(String s) +{ + return keytable->lookup(s); +} + +Identifier* +My_flex_lexer::lookup_identifier(String s) +{ + if (!the_id_tab->elt_query(s)) + return 0; + + return (*the_id_tab)[s]; +} + +void +My_flex_lexer::add_identifier(Identifier*i) +{ + delete lookup_identifier(i->name); + (*the_id_tab)[i->name] = i; +} + +My_flex_lexer::~My_flex_lexer() +{ + delete keytable; + delete defaulttab; + for (Assoc_iter ai(*the_id_tab); ai.ok(); ai++) { + mtor << "deleting: " << ai.key()<<'\n'; + delete ai.val(); + } + delete the_id_tab; +} + +void +My_flex_lexer::LexerError(const char *s) +{ + if (lexer->include_stack.empty()) { + *mlog << "error at EOF" << s; + }else + *mlog << lexer->include_stack.top()->name << ": " << + lexer->lineno() << ": error:" << s << '\n'; + exit(1); +} +// set the new input to s, remember old file. +void +My_flex_lexer::new_input(String s) +{ + if (!include_stack.empty()) + include_stack.top()->line = lineno(); + + Input_file *newin = new Input_file(s); + include_stack.push(newin); + switch_streams(newin->is); + yylineno = 1; +} + +// pop the inputstack. +bool +My_flex_lexer::close_input() +{ + Input_file *old = include_stack.pop(); + bool ok = true; + if (include_stack.empty()) { + ok = false; + } else { + Input_file *i = include_stack.top(); + switch_streams(i->is); + yylineno = i->line; + } + delete old; + return ok; +} diff --git a/src/note.cc b/src/note.cc index fe269792eb..cac44829ad 100644 --- a/src/note.cc +++ b/src/note.cc @@ -42,7 +42,7 @@ parse_pitchmod( const char *a, int &j, int &oct, bool & overide_acc) } mtor << "oct " << oct; - mtor << "override: " << overide_acc; + mtor << "override: " << overide_acc<<'\n'; } diff --git a/src/notename.cc b/src/notename.cc index dec6d47701..f22f44d7b9 100644 --- a/src/notename.cc +++ b/src/notename.cc @@ -4,24 +4,6 @@ #include "lexer.hh" #include "identifier.hh" -static Notename_tab * defaulttab = 0; - -void -set_notename_tab(Notename_tab*n) -{ - delete defaulttab; - defaulttab = n; -} - -void -lookup_notename(int &large, int &small, String s) -{ - if (!defaulttab) - set_notename_tab(lookup_identifier("default_table")-> - notename_tab(true)); - - defaulttab->lookup(large, small, s); -} void @@ -46,3 +28,20 @@ Notename_tab::set(int l, int s, String n) assert(l < 8 && s <= 2 && s >= -2 && l >=0); notetab[l * 5 + s +2] = n; } +/****************/ +void +My_flex_lexer::set(Notename_tab *n) +{ + delete defaulttab; + defaulttab = n; +} + +void +My_flex_lexer::lookup_notename(int &large, int &small, String s) +{ + if (!defaulttab) + set(lookup_identifier("default_table")-> + notename_tab(true)); + + defaulttab->lookup(large, small, s); +} diff --git a/src/paper.cc b/src/paper.cc index fe2a30d136..2879d90c91 100644 --- a/src/paper.cc +++ b/src/paper.cc @@ -14,7 +14,7 @@ const Real PHI = (1+sqrt(5))/2; Real Paperdef::duration_to_dist(Real d) { - return whole_width * pow(geometric_, log2(d)); + return whole_width * pow(geometric_, log_2(d)); } Real diff --git a/src/parser.y b/src/parser.y index 91f6deaca1..a0b9ed9b2f 100644 --- a/src/parser.y +++ b/src/parser.y @@ -2,6 +2,8 @@ #include #include "lookup.hh" + +#include "misc.hh" #include "lexer.hh" #include "paper.hh" #include "inputstaff.hh" @@ -35,8 +37,7 @@ Paperdef*default_paper(); String *string; const char *consstr; Paperdef *paper; - Horizontal_music *horizontal; - Vertical_music *vertical; + Input_music *music; Music_general_chord *chord; Music_voice *mvoice; int i; @@ -71,15 +72,17 @@ Paperdef*default_paper(); %token NOTENAME %token REAL %token STRING -%token OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS +%token OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS %token DOTS INT %type unit %type pitch_list -%type declaration +%type declaration +%type declarable_identifier %type paper_block paper_body %type dim %type duration +%type duration_length %type voice_elt full_element %type score_command staff_command skipcommand %type score_block score_body @@ -90,9 +93,9 @@ Paperdef*default_paper(); %type staff_commands_block staff_commands_body %type post_request pre_request %type clef_id pitchmod -%type vertical_music +%type music %type music_chord music_chord_body -%type horizontal_music + %type music_voice_body music_voice %type dinterval @@ -113,35 +116,40 @@ mudela: /* empty */ ; mudela_command: - notename_tab { set_notename_tab($1); } + notename_tab { lexer->set($1); } ; /* DECLARATIONS */ add_declaration: declaration { - add_identifier($1); + lexer->add_identifier($1); } ; +declarable_identifier: + NEWIDENTIFIER { $$ = $1; } + | IDENTIFIER { $$ = new String($1->name); } + ; + declaration: - NEWIDENTIFIER '=' staff_block { + declarable_identifier '=' staff_block { $$ = new Staff_id(*$1, $3); delete $1; // this sux } - | NEWIDENTIFIER '=' music_voice { + | declarable_identifier '=' music_voice { $$ = new M_voice_id(*$1, $3); delete $1; } - | NEWIDENTIFIER '=' music_chord { + | declarable_identifier '=' music_chord { $$ = new M_chord_id(*$1, $3); delete $1; } - | NEWIDENTIFIER '=' symtables { + | declarable_identifier '=' symtables { $$ = new Lookup_id(*$1, $3); delete $1; } - | NEWIDENTIFIER '=' notename_tab { + | declarable_identifier '=' notename_tab { $$ = new Notetab_id(*$1, $3); delete $1; } @@ -216,8 +224,14 @@ staff_command: } ; +duration_length: + duration { + $$ = wholes($1[0], $1[1]); + } + ; + skipcommand: - SKIP int ':' REAL { + SKIP int ':' duration_length { $$ = get_skip_command($2, $4); } @@ -226,7 +240,7 @@ score_command: | METER int int { $$ = get_meterchange_command($2, $3); } - | PARTIAL REAL { + | PARTIAL duration_length { $$ = get_partial_command($2); } | GROUPING int_list { @@ -278,7 +292,7 @@ staff_init: staff_body: staff_init - | staff_body horizontal_music { + | staff_body music { $$->add($2); } | staff_body staff_commands_block { @@ -290,15 +304,12 @@ staff_body: /* MUSIC */ -horizontal_music: +music: music_voice { $$ = $1; } + | music_chord { $$ = $1; } ; -vertical_music: - music_chord { $$ = $1; } - ; - -music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; } +music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; } ; music_voice_body: { @@ -308,28 +319,31 @@ music_voice_body: { $$->concatenate($2->mvoice()); } | music_voice_body full_element { - $$->add($2); + $$->add_elt($2); } | music_voice_body voice_command { } - | music_voice_body vertical_music { + | music_voice_body music { $$->add($2); } ; -music_chord: CHORD '{' music_chord_body '}' { $$ = $3; } +music_chord: '{' music_chord_body '}' { $$ = $2; } ; music_chord_body: { $$ = new Music_general_chord; } - | music_voice_body IDENTIFIER { + | music_chord_body IDENTIFIER { $$->concatenate($2->mchord()); } - | music_chord_body horizontal_music { + | music_chord_body music { $$ -> add($2); } + | music_chord_body full_element { + $$ ->add_elt($2); + } ; @@ -424,7 +438,7 @@ int: REAL { $$ = int($1); if (ABS($1-Real(int($$))) > 1e-8) - yyerror("expecting integer number"); + error("expecting integer number"); } | INT ; @@ -491,11 +505,16 @@ symtable_body: ; symboldef: - STRING box { + STRING box { $$ = new Symbol(*$1, *$2); delete $1; delete $2; } + | STRING { + Box b; + $$ = new Symbol(*$1, b); + delete $1; + } ; box: @@ -522,18 +541,16 @@ parse_file(String s) yydebug = !monitor.silence("Parser") && check_debug; #endif - new_input("symbol.ini"); + set_lexer(); + lexer->new_input("symbol.ini"); yyparse(); - new_input(s); + lexer->new_input(s); yyparse(); - - delete_identifiers(); kill_lexer(); - *mlog << "\n"; } Paperdef* default_paper() { - return new Paperdef(lookup_identifier("default_table")->lookup(true)); + return new Paperdef(lexer->lookup_identifier("default_table")->lookup(true)); } diff --git a/src/qlpsolve.cc b/src/qlpsolve.cc index 13bd30e89b..21af7cdcb0 100644 --- a/src/qlpsolve.cc +++ b/src/qlpsolve.cc @@ -67,6 +67,7 @@ Active_constraints::add(int k) // update of matrices Vector Ha = H*a; Real aHa = a*Ha; + Vector addrow(Ha.dim()); if (ABS(aHa) > EPS) { /* a != 0, so if Ha = O(EPS), then @@ -74,13 +75,14 @@ Active_constraints::add(int k) if H*a == 0, the constraints are dependent. */ - H -= Matrix(Ha , Ha)/(aHa); + H -= Matrix(Ha/aHa , Ha); /* sorry, don't know how to justify this. .. */ - Vector addrow(Ha/(aHa)); + addrow=Ha; + addrow/= aHa; A -= Matrix(A*a, addrow); A.insert_row(addrow,A.rows()); }else @@ -103,12 +105,16 @@ Active_constraints::drop(int k) /* */ - H += Matrix(a,a)/(a*opt->quad*a); - A -= A*opt->quad*Matrix(a,a)/(a*opt->quad*a); + Real q = a*opt->quad*a; + H += Matrix(a,a/q); + A -= A*opt->quad*Matrix(a,a/q); }else WARN << "degenerate constraints"; + #ifndef NDEBUG Vector rem_row(A.row(q)); - assert(rem_row.norm() < EPS); + assert(rem_row.norm() < EPS); + #endif + A.delete_row(q); } diff --git a/src/request.cc b/src/request.cc index 6f3778a66d..7821ba240c 100644 --- a/src/request.cc +++ b/src/request.cc @@ -1,4 +1,5 @@ #include "request.hh" +#include "misc.hh" #include "debug.hh" #define VIRTUALCONS(T,R) R *T::clone() const { return new T(*this); } struct T @@ -69,18 +70,6 @@ Rest_req::print() const Rhythmic_req::print(); } -Real -wholes(int dur, int dots) -{ - Real f = 1.0/Real(dur); - Real delta = f; - - while (dots--) { - delta /= 2.0; - f += delta; - } - return f; -} Real Rhythmic_req::duration() const { diff --git a/src/score.cc b/src/score.cc index ca468ee6ae..4c584c4ea7 100644 --- a/src/score.cc +++ b/src/score.cc @@ -10,7 +10,7 @@ void Score::process() { - *mlog << "Processing ... "; + *mlog << "\nProcessing ... "; assert (paper_); diff --git a/src/scores.cc b/src/scores.cc index b7b854881b..1d0679c534 100644 --- a/src/scores.cc +++ b/src/scores.cc @@ -14,12 +14,12 @@ do_scores() for (int i=0; i < sv.sz(); i++) { Score * s = sv[i]->parse(); delete sv[i]; - + s->process(); s->output(outfn); delete s; - } + sv.set_size(0); } void diff --git a/src/table.cc b/src/table.cc index 5e199beb9e..119475cc54 100644 --- a/src/table.cc +++ b/src/table.cc @@ -2,80 +2,7 @@ #include "debug.hh" #include "string.hh" #include "inputstaff.hh" -#include "identparent.hh" -#include "keyword.hh" -#include "associter.hh" -#include "parser.hh" -static Keyword_ent the_key_tab[]={ - "bar", BAR, - "bass", BASS, - "clef", CLEF, - "cm", CM, - "commands", COMMANDS, - "duration", DURATIONCOMMAND, - "geometric", GEOMETRIC, - "in", IN, - "key", KEY, - "melodic", MELODIC, - "meter", METER, - "mm", MM, - "octave", OCTAVECOMMAND, - "output", OUTPUT, - "partial", PARTIAL, - "paper", PAPER, - "pt", PT, - "rhythmic", RHYTHMIC, - "score", SCORE, - "skip", SKIP, - "staff", STAFF, - "start", START_T, - "table", TABLE, - "symboltables", SYMBOLTABLES, - "notenames", NOTENAMES, - "texid", TEXID, - "chord", CHORD, - "multi", MULTI, - "unitspace", UNITSPACE, - "violin", VIOLIN, - "voice", VOICE, - "voices", VOICES, - "width", WIDTH, - "music", MUSIC, - "grouping", GROUPING, - 0,0 -}; -int -lookup_keyword(String s) -{ - static Keyword_table table(the_key_tab); - return table.lookup(s); -} -Assoc the_id_tab; - -Identifier* -lookup_identifier(String s) -{ - if (!the_id_tab.elt_query(s)) - return 0; - - return the_id_tab[s]; -} - -void -add_identifier(Identifier*i) -{ - the_id_tab[i->name] = i; -} - -void -delete_identifiers() -{ - for (Assoc_iter ai(the_id_tab); ai.ok(); ai++) { - mtor << "deleting: " << ai.key()<<'\n'; - delete ai.val(); - } -} diff --git a/src/template2.cc b/src/template2.cc index d2d42f954f..40031c4abe 100644 --- a/src/template2.cc +++ b/src/template2.cc @@ -10,6 +10,7 @@ #include "plist.cc" +IPL_instantiate(Request); IPL_instantiate(Score_column); IPL_instantiate(Staff_column); IPL_instantiate(Staff); diff --git a/src/template3.cc b/src/template3.cc index d9c85526d7..be32eeceff 100644 --- a/src/template3.cc +++ b/src/template3.cc @@ -1,13 +1,18 @@ +#include "request.hh" #include "command.hh" #include "inputscore.hh" #include "inputstaff.hh" #include "inputmusic.hh" #include "inputcommand.hh" +#include "inputcommands.hh" #include "molecule.hh" #include "plist.cc" IPL_instantiate(Atom); IPL_instantiate(Command); - - +IPL_instantiate(Atom); +IPL_instantiate(Command); +IPL_instantiate(Input_command); +IPL_instantiate(Commands_at); +IPL_instantiate(Input_staff); diff --git a/src/version.cc b/src/version.cc index 3e81f11500..b2a57def4a 100644 --- a/src/version.cc +++ b/src/version.cc @@ -1,7 +1,8 @@ #include "version.hh" +#include "fversion.hh" -static char *s = "LilyPond version " VERSIONSTR " compiled on " - __DATE__ " at " __TIME__ " with " COMPILER "\n"; +static char *s = "LilyPond " VERSIONSTR "/FlowerLib " FVERSIONSTR +". Compile: " __DATE__ ", " __TIME__ " (" COMPILER ")\n"; const char * get_version() diff --git a/symbol.ini b/symbol.ini index fc53d30f8d..21226c079d 100644 --- a/symbol.ini +++ b/symbol.ini @@ -7,7 +7,6 @@ table_sixteen = symboltables { texid "\musixsixteendefs" - % index TeXstring, xmin xmax ymin ymax @@ -66,8 +65,9 @@ table_sixteen = symboltables { % dims ignored for this table "param" = table { "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt - "linestaf" "\linestafsym{%}{%}" 0pt 0pt 0pt 0pt - "stem" "\stem{%}{%}" 0pt 0pt 0pt 0pt + "linestaf" "\linestafsym{%}{%}" + "stem" "\stem{%}{%}" + "fill" "\hbox{}" } "dots" = table { @@ -86,8 +86,8 @@ table_sixteen = symboltables { } "beamslopes" = table { - "slope" "\beamslope{%}{%}" 0pt 0pt 0pt 0pt - "horizontal" "\rulesym{%}{%}" 0pt 0pt 0pt 0pt + "slope" "\beamslope{%}{%}" + "horizontal" "\rulesym{%}{%}" } } @@ -158,8 +158,9 @@ table_twenty = symboltables { % dims ignored for this table "param" = table { "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt - "linestaf" "\linestafsym{%}{%}" 0pt 0pt 0pt 0pt - "stem" "\stem{%}{%}" 0pt 0pt 0pt 0pt + "linestaf" "\linestafsym{%}{%}" + "stem" "\stem{%}{%}" + "fill" "\hbox{}" } "dots" = table { @@ -178,8 +179,8 @@ table_twenty = symboltables { } "beamslopes" = table { - "slope" "\beamslope{%}{%}" 0pt 0pt 0pt 0pt - "horizontal" "\rulesym{%}{%}" 0pt 0pt 0pt 0pt + "slope" "\beamslope{%}{%}" + "horizontal" "\rulesym{%}{%}" } } -- 2.39.5