]> git.donarmstrong.com Git - lilypond.git/commitdiff
release: 0.0.17 release/0.0.17
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 17 Dec 1996 10:39:41 +0000 (11:39 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 17 Dec 1996 10:39:41 +0000 (11:39 +0100)
64 files changed:
.dstreamrc
Documentation/inputformat
Makefile
NEWS [new file with mode: 0644]
README
Sources.make
Variables.make
flower/Sources.make
flower/Variables.make
flower/compare.hh
flower/fproto.hh
flower/interval.cc
flower/interval.hh
flower/rational.hh [new file with mode: 0644]
flower/real.hh
flower/scalar.cc
flower/scalar.hh
flower/string.cc
flower/string.hh
hdr/debug.hh
hdr/identparent.hh
hdr/inputcommand.hh
hdr/inputcommands.hh
hdr/inputmusic.hh
hdr/inputstaff.hh
hdr/keyword.hh
hdr/lexer.hh
hdr/lookup.hh
hdr/misc.hh
hdr/proto.hh
kortjakje.ly
maartje.ly
make_patch
pavane.ly
src/beam.cc
src/command.cc
src/debug.cc
src/identifier.cc
src/inputcommand.cc
src/inputcommands.cc
src/inputcursor.cc [deleted file]
src/inputmusic.cc
src/inputstaff.cc
src/key.cc
src/keyitem.cc
src/lexer.l
src/lexerinit.cc [new file with mode: 0644]
src/lookup.cc
src/main.cc
src/misc.cc
src/mylexer.cc [new file with mode: 0644]
src/note.cc
src/notename.cc
src/paper.cc
src/parser.y
src/qlpsolve.cc
src/request.cc
src/score.cc
src/scores.cc
src/table.cc
src/template2.cc
src/template3.cc
src/version.cc
symbol.ini

index 2a2dc4300226782763fd63ca1af55977ebb5bd7b..b14fb6c79ae1a11dff02a3ba04c0d2be16a85562 100644 (file)
@@ -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
index e6c0de2261bbd3fe9b9310cd3245cb0fac6b6282..d82c02b2e525831f3cb519f871e22b753be4a5db 100644 (file)
@@ -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
index 4b7e107435d77cd124fc481abc732c2a95048584..ac9d7254ea4bb40b24ffb2d66ece0134e034005a 100644 (file)
--- 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 (file)
index 0000000..455012a
--- /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 310ebb1cb174a3ae4bac8dfb20230bcd23af8c1d..b849b7f2ee00b88f98c29c455095213aed612cc0 100644 (file)
--- 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
index 25bd89dfb16a6a760e09d0d7a0917f55b7a5d604..4545a011b2d723bd0f6a935af0e5b6b1b18ed29d 100644 (file)
@@ -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
 
index 35959bd20c2b270b744e51165065f10d5f947660..f386e5546d9df322edf24e0c7aab435f3f4115f8 100644 (file)
@@ -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
index c7efa127f99c416557580a90612034eaa6eec719..84e27c4681c83fa789e62032a33da76482763737 100644 (file)
@@ -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
 
index ca0275af87b09721188d4d3a2ed80720d5b07f5e..9d58ba9063122b08594da3d29f654556e210c24f 100644 (file)
@@ -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)
index 40bc9d29511e9b9e934ef7a985ee044988798c30..f0e886e539a6a8692f197f3a941f04afd492884e 100644 (file)
@@ -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 ; */
      /**
index 8e30550696fdca77273abc4b1b4a3b24e6afa82d..4452176d19a9032c98462e614d2c0785f310e4a4 100644 (file)
@@ -17,10 +17,13 @@ template<class T> struct Cursor;
 template<class T> struct PCursor;
 template<class T> struct Link;
 template<class T> struct Handle ;
+template<class T>struct Interval_t ;
+#include "real.hh"
 
+typedef Interval_t<Real> Interval;
 
 struct Choleski_decomposition ;
-struct Interval ;
+
 struct long_option_init ;
 struct Getopt_long ;
 struct Matrix ;
index f176c7486fe5738ab5150ac46f22cdfab5b1ae4c..46b4fc7e1603f2bb7346f5af0d6ec3e857eb5404 100644 (file)
@@ -4,80 +4,90 @@
 #include "string.hh"
 
 
-const Real INFTY = HUGE;
 
-void
-Interval::set_empty() {
-    min = INFTY;
-    max = -INFTY;
-}
+template<class T>
+int
+Interval__compare(const Interval_t<T>&a,Interval_t<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.min<min)
-       min = h.min;
-    if (h.max>max)
-       max = h.max;
+    assert(false);             // not comparable
+
+    return 0;
 }
 
+const Real INFTY = HUGE;
+
+template<class T>
 void
-Interval::intersect(Interval h)
-{
-    min = MAX(h.min, min);
-    max = MIN(h.max, max);
+Interval_t<T>::set_empty() {
+    left = INFTY;
+    right = -INFTY;
 }
 
-Interval
-intersection(Interval a, Interval const&b)
-{
-    a.intersect(b);
-    return a;
-    
+template<class T>
+T
+Interval_t<T>::length() const {
+    assert(right >= left);
+    return right-left;
 }
 
-int
-Interval::compare(const Interval&a,Interval const&b)
+template<class T>
+void
+Interval_t<T>::unite(Interval_t<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.left<left)
+       left = h.left;
+    if (h.right>right)
+       right = h.right;
+}
 
-    assert(false);             // not comparable
+/**
+  smallest Interval which includes *this and #h#
+ */
 
-    return 0;
+template<class T>
+void
+Interval_t<T>::intersect(Interval_t<T> h)
+{
+#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
+    left = h.left >? left;
+    right = h.right <?right;
+#else
+    left = max(h.left, left);
+    right = min(h.right, right);
+#endif
 }
 
-Interval
-intersect(Interval x, Interval const &y)
+template<class T>
+Interval_t<T>
+intersect(Interval_t<T> x, Interval_t<T> const &y)
 {
     x.intersect(y);
     return x;
 }
-    
+
+template<class T>
 String
-Interval::str() const
+Interval_t<T>::str() const
 {
     if (empty())
        return "[empty]";
     String s("[");
  
-    return s + min + "," + max +"]";
+    return s + left + "," + right +"]";
 }
+
+template<class T>
 bool
-Interval::elt_q(Real r)
+Interval_t<T>::elt_q(T r)
 {
-    return r >= min && r <= max;
+    return r >= left && r <= right;
 }
index 5331c1d12534f78da11277ba627743905f366f20..4184451701e72aa11ccf8a6ea015d7b64317ae76 100644 (file)
 #include "real.hh"
 
 
-/// a Real interval
-struct Interval {
-    Real min, max;
+/// a T interval
+template<class T>
+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<T> h);
     /**
       PRE
       *this and h are comparable
       */
-    void intersect(Interval h);
+    void intersect(Interval_t<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<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<class T>
+int Interval__compare(const Interval_t<T>&,Interval_t<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<T>&, Interval__compare, template<class T>);
 
 
+template<class T>
+inline Interval_t<T>
+intersection(Interval_t<T> a, Interval_t<T> const&b)
+{
+    a.intersect(b);
+    return a;
+    
+}
+
+
+template<class T>
 inline
-Interval operator +(double a,Interval i )
+Interval_t<T> operator +(T a,Interval_t<T> i )
 {
     i += a;
     return i;
 }
 
+template<class T>
 inline
-Interval operator +(Interval i,double a ){
+Interval_t<T> operator +(Interval_t<T> i,T a ){
     return a+i;
 }
 
+typedef Interval_t<Real> Interval;
+
+
+#define Interval__instantiate(T) template struct Interval_t<T>;\
+  template  int Interval__compare(const Interval_t<T>&,Interval_t<T> const&)
+
+
 #endif // INTERVAL_HH
 
 
diff --git a/flower/rational.hh b/flower/rational.hh
new file mode 100644 (file)
index 0000000..30fa2cb
--- /dev/null
@@ -0,0 +1 @@
+#include <Rational.h>
index 68e90f9b71b2b6fad9a5c2907674ebf0b74346e9..16f52b509269e7dc084c7b53889d6ba5a5990400 100644 (file)
@@ -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 <builtin.h>
+#include <minmax.h>
+#include <std/cmath.h>
+
+typedef double Real;
+
 inline Real
 distance(Real x,Real y)
 {
-    return ABS(x-y);
+    return abs(x-y);
 }
 #endif
index b53693928fc613d6326ce202e4ee2b7e20a6a336..f981bc101f83a5b5f01f4fbc3cb44eb8fea52dfc 100644 (file)
@@ -1,6 +1,25 @@
 #include <stdio.h>
 #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
 {
index 5d02d6936c9319d8324092f4c726a8a67940d0f8..67ae85beda708216c08118fc572012ffd68d66d6 100644 (file)
@@ -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();
index 9c6792c0217cb86d523e4aa68ba82f077ec63b3b..0804c5bbdc7d30e6ed50235fea460ac46548772a 100644 (file)
@@ -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);
 }
 
 
index 8008f06394f9bb567932a1a205bac356a233d526..7ed274979d8df163dba37c1c9931bcb228ca381d 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <string.h>
 #include <iostream.h>
-
+#include <Rational.h>
 
 #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)
index e86fe2247d352800823bd9ecc5a2b034727c86dd..1d1ae745c31f6344335e4459e73d392124bcacf2 100644 (file)
@@ -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
index 2e65537fc077915b564fd53477909feca410d29a..addfd26e0befe479548e569e0e24263715992296 100644 (file)
@@ -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; }
index 0f32a34d488028585e82d483b1ab26ff368f9205..47882a23748b2b9cf626b0b490511c4e737c508a 100644 (file)
@@ -11,8 +11,6 @@
 #include "vray.hh"
 
 struct Input_command {
-    Real when;
-    
     /// analogous to argv[]
     svec<Scalar> 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<int>);
-
-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
 
index 083c830aa9d0899f39bb89e3e446ae2dde523810..c5b594359bae015a45fe7c1026940e7050077f41 100644 (file)
@@ -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<Input_command*> {
+    Real when;
 
-struct Input_cursor : public PCursor<Input_command*>
-{
     /// 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<Input_command*>);
-    /// 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<Commands_at*>
+{
+    /****************/
+    Input_cursor(PCursor<Commands_at*>);
+    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<Input_command*> {
+struct Input_commands : public IPointerList<Commands_at*> {    
     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);
index 57ddf79443f0960b6ac8f3e0418c46bf19480c50..d3286135f8c2774073edbe86e70afdce0d21e14f 100644 (file)
@@ -9,11 +9,10 @@
 
 #include "plist.hh"
 #include "proto.hh"
+#include "voice.hh"
 
 struct Voice_list : public PointerList<Voice*> {
     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<Vertical_music>
-  
-  */
-
-///
-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<Horizontal_music>
- */
-
-/// 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<Input_music*> 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<Vertical_music*> 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<Horizontal_music*> 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<Input_music*> 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
index abfcc52f61bb9087fe2ce6c2b732806056fcc010..e2caea7dc2b0e5ec56e6a82bbb4a87662f66e713 100644 (file)
 struct Input_staff {
     String type;
     IPointerList<Input_command*> commands_;
-    IPointerList<Horizontal_music*> music_;
+    IPointerList<Input_music*> music_;
 
     /****************/
 
-    void add(Horizontal_music*m);
+    void add(Input_music*m);
     Input_staff(Input_staff&);
     Input_staff(String);
     void add(svec<Input_command*> &s);
index df4547ad7698dd82ae3b8a9ec4a66a1dc3f7a0fe..b081df3a6294e759c5f29d7764dd1a98499800fa 100644 (file)
@@ -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
+
index 7284dd40eb2f54487383ad7fbb1a6bc83e8fe490..239b7bbe0b979c36bfdb036efaaa99b86ea0298e 100644 (file)
@@ -1,17 +1,50 @@
 #ifndef LEXER_HH
 #define LEXER_HH
-
+#include <FlexLexer.h>
 #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<Input_file*> include_stack;
+    Assoc<String, Identifier*> *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
index 7e59dac0fa1fa7ee9fa07c7bb6aedce22e22da24..ecb55bd03c126bb30cfbdb2a7404faf38001c0f9 100644 (file)
@@ -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);
index 763ebbc250a9a7ce5c2f30851c807f0cdb8041d6..376f048c0ecb2b83260f9e0eda0994a2b6a8f139 100644 (file)
@@ -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)
index ebc4fd1398741010b8e65072ae0186a2d929714e..09465e3e85adb5fd4439b5ede0c95194e0a2bc86 100644 (file)
@@ -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
index 392bd19678b4ccda068ef463735f372b2498804b..f5e6d081397af8ff4e5edcd2b437fb41c6a19970 100644 (file)
@@ -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
        }
 }
 
index 912f9e97eed459d17332c2ae79593ad7c9f13dec..a0cffa1190b6e13fc5bd0c8885a2cf070be949ee 100644 (file)
@@ -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
index 8747fe6b840faf8cb47b84a2be7c4d099155c127..8f8a688cd785d61dc3c726ee2c62f69e0b18004f 100755 (executable)
@@ -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
index 5c1703cfc9955e6ae2233cfcc9e81f73de421405..fd66d490cd5e869175406f0e0424248f93c8c5a6 100644 (file)
--- 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
index c897ebfc6650eb35cc56a591c368f5a50d508772..3d43b4ed1dc6a1d42c09e9907d6174263914ee86 100644 (file)
@@ -22,6 +22,7 @@ struct Stem_info {
     Stem_info(){}
     Stem_info(const Stem*);
 };
+
 Stem_info::Stem_info(const Stem*s)
 {
     x = s->hpos();
index 19b7aac6d74e616b6a7bd6dd728edb258ab2d41e..94d3bb94d2d59c42e3ff196a3dac9a19aa834875 100644 (file)
@@ -15,8 +15,6 @@ Command::Command()
     priority=0;
 }
 
-
-
 Command::Command(Real w)
 {
     code = NOP;
index 7620027c91f6f89febbc4ee41bcef3581fd43395..eaed33f080c0836973ce7e8fdd435aa3df3b82d1 100644 (file)
@@ -1,5 +1,6 @@
 #include <fstream.h>
 #include <std/new.h>
+#include <stdlib.h>
 #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
index 5b552898a96a09ce0b60d04bedd8e384aed499ad..6241768694e77943c9e36d5c3eb630cd27037677 100644 (file)
@@ -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());
 }
index 938fc3e01a04cf1edad1a49969c5090ca0a1f0f3..1c48eea52a9c1b02b73e610918785de2f864e97f 100644 (file)
@@ -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<args.sz(); i++)
index 457fb9a57d116e9fb3b78a585e9e69276204c7a1..c7f7aaff5632c5c1e58e880c1a165ba0fd9d8685 100644 (file)
 #include "getcommand.hh"
 #include "command.hh"
 
-Input_commands::Input_commands(Input_commands const&src)
-    : ptr(src.ptr)
+void
+Commands_at::print() const
 {
-    IPointerList<Input_command*> &me(*this);
-    const IPointerList<Input_command*> &that(src);
-    
-    PL_copy(me, that);    
+#ifndef NPRINT
+    mtor << "{ at "<<when<<'\n'; 
+    mtor << "meter " << whole_per_measure
+        << " pos "<< bars << ":" << whole_in_measure <<'\n';
+    for (PCursor<Input_command *> 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<Input_command*> i(*this);
+    IPointerList<Input_command*> &me(*this);
+    const IPointerList<Input_command*> &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<Commands_at*>(list().bottom());
+           Real dt = (w - when()) <? ptr()->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<Commands_at*> &me(*this);
+    const IPointerList<Commands_at*> &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<Input_command*> cc(*this); cc.ok(); cc++) {
-       if (cc->args.sz() &&  cc->args[0] !="")
-           nc->process_add(**cc);
-    }
+    for (PCursor<Commands_at*> i(*this); i.ok(); i++)
+       for (PCursor<Input_command *> 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<Command*> cc(*this); cc.ok() ; cc++) {
+    for (PCursor<Commands_at*> cc(*this); cc.ok() ; cc++) {
        cc->print();
     }
-    ptr.print();
 #endif
 }
+/****************/
+
+Real
+Input_cursor::when()const
+{
+    return (*this)->when; 
+}
+Input_cursor::Input_cursor(PCursor<Commands_at *>c)
+    : PCursor<Commands_at*>(c)
+{
+}
diff --git a/src/inputcursor.cc b/src/inputcursor.cc
deleted file mode 100644 (file)
index 4dc5f93..0000000
+++ /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(PCursor<Input_command*>c)
-    :PCursor<Input_command*>(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<Input_command*> *) 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<Input_command*> ::add(c);
-    (*this)++;
-}
-
-void
-Input_cursor::last_command_here()
-{
-    assert(ok());
-    PCursor<Input_command*> 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;  
-}
index 6d3186bf73b4373b0a16a44b6454f0c8c96482f9..db2e3c57d5b0e0bf8e8a5c8db3ca7d8f72b441d6 100644 (file)
 #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<Vertical_music*> i(voice_); i.ok(); i++)
+    for (PCursor<Input_music*> i(elts); i.ok(); i++)
         i->print();
-    mtor << "}\n";
 }
 
 void
-Music_voice::concatenate(Music_voice*h)
+Complex_music::concatenate(Complex_music*h)
 {
-    for (PCursor<Vertical_music*> i(h->voice_); i.ok(); i++)
+    for (PCursor<Input_music*> 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<Vertical_music*> i(s.voice_); i.ok(); i++)
+    for (PCursor<Input_music*> i(s.elts); i.ok(); i++)
        add(i->clone());
 }
 
+/****************************************************************/
+
 void
-Music_voice::add(Voice_element*v)
+Music_voice::print() const
 {
-    PCursor<Vertical_music*> c(voice_.bottom());
+    mtor << "Music_voice {";
+    Complex_music::print();    
+    mtor << "}\n";
+}
+
+void
+Music_voice::add_elt(Voice_element*v)
+{
+    PCursor<Input_music*> 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<Vertical_music*> i(voice_); i.ok(); i++)
+    for (PCursor<Input_music*> 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<Vertical_music*> i(voice_); i.ok(); i++) {
+    for (PCursor<Input_music*> 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<Vertical_music*> 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<Horizontal_music*> 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<Horizontal_music*> 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<Horizontal_music*> i(chord_); i.ok(); i++) 
+    for (PCursor<Input_music*> i(elts); i.ok(); i++) 
        i->translate_time(t);    
 }
 
-    
-       
 Real
 Music_general_chord::length()
 {
     Real l =0.0;
     
-    for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++) 
-       l = MAX(l, i->length());
+    for (PCursor<Input_music*> 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<Horizontal_music*> i(chord_); i.ok(); i++) {
+    for (PCursor<Input_music*> 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<Horizontal_music*> 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<Voice*> i(*this); i.ok(); i++)
-       delete i.ptr();
-}
index 2337f6ae2df9e55b47c7e8d8c379e63b390578ce..4a38d38bc120ab6c9f71a47c3dba4149d51062a4 100644 (file)
@@ -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<Input_command*> score_wide)
     else if (type == "rhythmic")
        p = new Rhythmic_staff;
 
-    for (PCursor<Horizontal_music*> i(music_); i.ok(); i++) {
+    for (PCursor<Input_music*> 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<Input_command*> i(s.commands_); i.ok(); i++)
        commands_.bottom().add(new Input_command(**i));
-    for (PCursor<Horizontal_music*> i(s.music_); i.ok(); i++)
+    for (PCursor<Input_music*> 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<Input_command*> i(commands_); i.ok(); i++)
        i->print();
-    for (PCursor<Horizontal_music*> i(music_); i.ok(); i++)
+    for (PCursor<Input_music*> i(music_); i.ok(); i++)
        i->print();
     mtor << "}\n";
 #endif
index 0a5af6ffd79acc28aad423c94201da84320c820a..dac8c266ec2240c641e325e9b813b07d261c3575 100644 (file)
@@ -63,7 +63,7 @@ Key::oldkey_undo(svec<Scalar>s)
     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;
index 607e144f1af0210b38182d278e18319a8b37c45b..71f1654f19fad49ea16ca5c0c27d76459018db7a 100644 (file)
@@ -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);      
 }
index c5c51f70b69b1e519ade8cc5c0460c99bb7a495d..0b17abac663d3a0bdd3aef64337e24c9b83c0f57 100644 (file)
@@ -1,37 +1,14 @@
 %{ // -*-Fundamental-*-
 
-#include <fstream.h>
 #include <stdio.h>
-#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<Input_file*> 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                \.+
 <<EOF>> {
        mtor << "<<EOF>>";
 
-       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 << "["<<s<<flush;
-}
-
-Input_file::~Input_file()
-{
-  if (is != &cin)
-      delete is;
-  cout << "]" << flush;  
-}
-/****************/
-
-// 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/lexerinit.cc b/src/lexerinit.cc
new file mode 100644 (file)
index 0000000..3bc0d31
--- /dev/null
@@ -0,0 +1,61 @@
+#include <fstream.h>
+#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 << "["<<s<<flush;
+}
+
+Input_file::~Input_file()
+{
+  if (is != &cin)
+      delete is;
+  cout << "]" << flush;  
+}
index 7376f3c1d41265fdc7dba607ac7b3fa0cba9fdcf..baa037b9709a456aebd7733fe1fde78da86cf51b 100644 (file)
@@ -51,7 +51,13 @@ Lookup::rest(int j)
 {
     return (*symtables_)("rests")->lookup(String(j));
 }
-
+Symbol
+Lookup::fill(Box b)
+{
+    Symbol s( (*symtables_)("param")->lookup("fill"));
+    s.dim = b;
+    return s;
+}
 Symbol
 Lookup::accidental(int j)
 {
index 7ff09dfc347d0cd3016806fb923053070de042b2..c4b48ff238ff6bb716beb13926387f1c0dee219a 100644 (file)
@@ -29,6 +29,7 @@ help()
 void notice()
 {
     cout <<
+       "\n"
        "LilyPond, a music typesetter.\n"
        "Copyright (C) 1996 by\n"
        "  Han-Wen Nienhuys <hanwen@stack.nl>\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);
 }
index 51baac1211f392936110b117a75185f037df9f46..30116303fce315c16565d70aa81c5dba0ee4799f 100644 (file)
@@ -3,6 +3,18 @@
 
 #include <math.h>
 
+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 (file)
index 0000000..0a912e3
--- /dev/null
@@ -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<String, Identifier*>;
+    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<String,Identifier*> 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;
+}
index fe269792eb8ca11e2bfd8eec6eda7e1acbff96fb..cac44829adadd117a5e31d2f62588b4e6df6aaf2 100644 (file)
@@ -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';
 }
 
 
index dec6d47701c222d1f5143266674fab14f510b2dd..f22f44d7b9ab957b12f15b7c3b6b481bfd4d070a 100644 (file)
@@ -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);
+}
index fe2a30d136a9d1f875a16a73bb39863ffd60b4ca..2879d90c91fa267a3de568c08404a7af6153f5a5 100644 (file)
@@ -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
index 91f6deaca13cb144edfe2a8284be02916a614ae6..a0b9ed9b2f2440dc803e2858f04670f773d86faa 100644 (file)
@@ -2,6 +2,8 @@
 #include <iostream.h>
 
 #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 <ii> NOTENAME 
 %token <real> REAL
 %token <string> STRING
-%token <i> OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS
+%token <c> OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS
 %token <i> DOTS INT
 %type <consstr> unit
 %type <intvec> pitch_list
 
-%type <id> declaration 
+%type <id> declaration
+%type <string> declarable_identifier
 %type <paper> paper_block paper_body
 %type <real> dim
 %type <ii> duration
+%type <real> duration_length
 %type <el> voice_elt full_element
 %type <command> score_command staff_command skipcommand
 %type <score> score_block score_body
@@ -90,9 +93,9 @@ Paperdef*default_paper();
 %type <commandvec> staff_commands_block staff_commands_body
 %type <request> post_request pre_request
 %type <string> clef_id pitchmod
-%type <vertical> vertical_music  
+%type <music> music 
 %type <chord> music_chord music_chord_body
-%type <horizontal>  horizontal_music
+
 %type <mvoice>  music_voice_body music_voice
 
 %type <interval> 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));
 }
index 13bd30e89b0c7021c0555bde61c7258bbc8d5166..21af7cdcb0b5be79ae0756777fd03f35b41171c0 100644 (file)
@@ -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);
 }
 
index 6f3778a66d5d0af9730f12f1d0880af70d821d2e..7821ba240c19cb02bc9e1b52ad7b94a27dbaa34b 100644 (file)
@@ -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 {    
index ca468ee6ae3c71698dd5a8448801ee08fc090e26..4c584c4ea727b3e6cc2bb4100a94e61737463992 100644 (file)
@@ -10,7 +10,7 @@
 void
 Score::process()
 {
-    *mlog << "Processing ... ";
+    *mlog << "\nProcessing ... ";
     
     assert (paper_);
     
index b7b854881b1484df4c7570be44a2a9148228ec81..1d0679c534268c540518fa7cfb03080da5a7f42f 100644 (file)
@@ -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
index 5e199beb9eee7ca6412b9f735007293c928a7b8b..119475cc54d167cb5b7804ab5b1c2594f5fa1017 100644 (file)
@@ -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<String, Identifier*> 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<String,Identifier*> ai(the_id_tab); ai.ok(); ai++) {
-       mtor << "deleting: " << ai.key()<<'\n';
-       delete ai.val();
-    }
-}
index d2d42f954f258431baef1b0888f9d4eee714484c..40031c4abe51fac081fa95683bcfde338863ad47 100644 (file)
@@ -10,6 +10,7 @@
 #include "plist.cc"
 
 
+IPL_instantiate(Request);
 IPL_instantiate(Score_column);
 IPL_instantiate(Staff_column);
 IPL_instantiate(Staff);
index d9c85526d7786c706506e950206e79aa1bcecffa..be32eeceff2bcba66f393bf9b47efe1304b8956b 100644 (file)
@@ -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);
index 3e81f115004fcdb96b213eed418c61f5ef5cf48f..b2a57def4ae1d04f2ca871ae32d1265eb1a6c060 100644 (file)
@@ -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()
index fc53d30f8d9591902dd9864a282cbdf6c68d551c..21226c079dcdb0d3499d60038bba26d606aa7da0 100644 (file)
@@ -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{%}{%}"        
     }
 
 }