]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.4
authorfred <fred>
Tue, 22 Oct 1996 20:43:52 +0000 (20:43 +0000)
committerfred <fred>
Tue, 22 Oct 1996 20:43:52 +0000 (20:43 +0000)
Makefile
parser.y
rhythmstaf.cc
stcol.cc [new file with mode: 0644]
stcol.hh [new file with mode: 0644]

index 38b71b9bbbf2869630b1c69b975b8819b65f86b7..2f5b450761166df3b803966a344e52a1397a63f6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 MAJVER=0
 MINVER=0
-PATCHLEVEL=3
+PATCHLEVEL=4
 
 # 
 #
@@ -19,17 +19,19 @@ VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
 PACKAGENAME=lilypond
 DNAME=$(PACKAGENAME)-$(VERSION)
 othersrc=lexer.l parser.y
-SCRIPTS=make_version make_patch
+SCRIPTS=make_version make_patch genheader
 IFILES=dimen.tex symbol.ini suzan.ly maartje.ly  lilyponddefs.tex test.tex .dstreamrc
-OFILES=Makefile Sources.make depend 
-DFILES=$(hdr) $(mycc) $(othersrc) $(OFILES) $(IFILES) $(SCRIPTS) COPYING
+OFILES=Makefile Sources.make 
+DOC=COPYING README TODO
+DFILES=$(hdr) $(mycc) $(othersrc) $(OFILES) $(IFILES) $(SCRIPTS) $(DOC)
 
 #compiling
 LOADLIBES=-L$(FLOWERDIR) -lflower
 FLOWERDIR=../flower
-#DEFINES=-DNDEBUG
-CXXFLAGS=$(DEFINES) -I$(FLOWERDIR) -pipe -Wall -g
-
+#DEFINES=-DNDEBUG -DNPRINT -O2
+CXXFLAGS=$(DEFINES) -I$(FLOWERDIR) -pipe -Wall -W  -pedantic -g
+FLEX=flex
+BISON=bison
 exe=$(PACKAGENAME)
 
 ##################################################################
@@ -62,7 +64,7 @@ depend: Sources.make  .GENERATE
 include depend
 
 parser.cc: parser.y
-       bison -d $<
+       $(BISON) -d $<
        mv parser.tab.h parser.hh
        mv parser.tab.c parser.cc
 
@@ -74,7 +76,7 @@ version.hh: Makefile make_version
        make_version $(MAJVER) $(MINVER) $(PATCHLEVEL)  > $@
 
 lexer.cc: lexer.l
-       flex -+ -t $< > $@
+       $(FLEX) -+ -t $< > $@
 
 DDIR=$(DNAME)
 dist:
index cb0853b3409b32d0a06b7c20751f902afa0c9383..d60face970f2830abbe8980091da4c7dadc7593a 100644 (file)
--- a/parser.y
+++ b/parser.y
@@ -2,20 +2,23 @@
 #include <iostream.h>
 
 #include "lexer.hh"
+#include "paper.hh"
 #include "staff.hh"
 #include "score.hh"
 #include "main.hh"
 #include "keyword.hh"
 #include "debug.hh"
 #include "parseconstruct.hh"
-#define YYDEBUG 1
+#include "dimen.hh"
 
+#ifndef NDEBUG
+#define YYDEBUG 1
+#endif
 
 %}
 
 
-%union {
-     int i;    
+%union {    
     Real real;
     Command *command;
     Identifier *id;    
     Voice_element *el; 
     Staff *staff;    
     String *string;
-    Score *score;    
+    Score *score;
+    const char *consstr;
+    Paperdef *paper;
+    int i;
 }
 
 %token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME OUTPUT
+%token CM IN PT MM PAPER WIDTH METER
 
-
+%type <consstr> unit
 %token <id> IDENTIFIER
 %token <string> PITCH DURATION RESTNAME
 %token <real> REAL
 %token <string> STRING
 
+%type <paper> paper_block paper_body
+%type <real> dim
 %type <voice> voice_block voice_body voice_elts voice_elts_dollar
 %type <el> voice_elt
 %type <command> score_command
 %type <score> score_block score_body
 %type <staff> staff_block  rhythmstaff_block rhythmstaff_body
+%type <i> int
+
 
 %%
 
@@ -56,11 +67,35 @@ score_block: SCORE '{' score_body '}'       { $$ = $3; }
 score_body:            { $$ = new Score; } 
        | score_body staff_block        { $$->add($2); }
        | score_body score_command      { $$->add($2); }
-       | score_body OUTPUT STRING      { $$->outfile = *$3;
+       | score_body paper_block        { delete $$->paper;
+               $$->paper = $2;
+       }
+       ;
+
+paper_block:
+       PAPER '{' paper_body '}'        { $$ = $3; }
+       ;
+
+paper_body:
+       /* empty */                     { $$ = new Paperdef; }
+       | paper_body WIDTH dim          { $$->width = $3;}
+       | paper_body OUTPUT STRING      { $$->outfile = *$3;
                delete $3;
        }
        ;
 
+dim:
+       REAL unit       { $$ = convert_dimen($1,$2); }
+       ;
+
+
+unit:  CM              { $$ = "cm"; }
+       |IN             { $$ = "in"; }
+       |MM             { $$ = "mm"; }
+       |PT             { $$ = "pt"; }
+       ;
+       
+
 staff_block:
        rhythmstaff_block
        ;
@@ -110,6 +145,18 @@ score_command:
        BAR REAL                        {
                $$ = get_bar_command($2);
        }
+       | METER REAL int int            {
+               $$ = get_meter_command($2, $3, $4);
+       }
+       ;
+
+int:
+       REAL                    {
+               $$ = int($1);
+               if (ABS($1-Real(int($$))) > 1e-8)
+                       yyerror("expecting integer number");
+               
+       }
        ;
 
 %%
@@ -118,7 +165,9 @@ void
 parse_file(String s)
 {
    *mlog << "Parsing ... ";
+#ifdef YYDEBUG
    yydebug = !monitor.silence("Parser");
+#endif
    new_input(s);
    yyparse();
 }
index a7fade6fc5f487378434f554eab1f7c59798f18c..d2a85d62cee60f9ceb7d0fe5b0b0554ddd129dfc 100644 (file)
@@ -7,8 +7,8 @@
 #include "command.hh"
 #include "molecule.hh"
 #include "rhythmstaf.hh"
-#include "symbol.hh"
+#include "lookupsyms.hh"
+#include "sccol.hh" 
 
 Rhythmic_column::Rhythmic_column(Score_column*s, Rhythmic_staff *rs)
     : Staff_column(s)
@@ -69,21 +69,16 @@ Rhythmic_column::process_requests()
     for (int i = 0 ; i < v_elts.sz(); i ++)
        for (PCursor<Request *> rqc(v_elts[i]->reqs); rqc.ok(); rqc++) {
            Request *rq= rqc;
-           switch(rq->tag){
-           case Request::NOTE:
-           case Request::REST:
+           if (rq->rhythmic()){
                if (the_note){
                    WARN << "too many notes.\n";
                    return;
                }
                the_note = rq;
-               break;
-               
-           default:
-               return;
            }
+           break;
+               
        }
-    
 }
 
 
@@ -91,14 +86,30 @@ void
 Rhythmic_column::typeset_command(Command *com, int breakst)
 {
     Item *i = new Item;
-    const Symbol*s=0;
+    Symbol s;
 
     if (com -> args[0] ==  "BAR" ) {
-       s = Symbol::find_bar(com->args[1]);     
+       s = Lookup::bar(com->args[1]);  
+    } else if (com->args[0] == "METER") {
+       Parametric_symbol *p = Lookup::meter("general");
+       svec<String> arg( com->args);
+       arg.del(0);
+       s = p->eval(arg);
     } else
        assert(false);
-    
-    i->output=new Molecule(Atom(s));
+
+    Molecule * m =new Molecule(Atom(s));
+    {
+       Interval wid;
+       svec<Item*> sv(staff_->pscore_->
+                      select_items(staff_->theline, score_column->pcol));
+       for (int j=0; j<sv.sz(); j++) {
+           wid.unite(sv[j]->output->extent().x);
+       }
+       if (!wid.empty())
+           m->translate(Offset(wid.max,0));
+    }
+    i->output=m;
     staff_->pscore_->typeset_item(i, score_column->pcol,
                                  staff_->theline,breakst);
 }
@@ -107,22 +118,25 @@ void
 Rhythmic_column::typeset_req(Request *rq)
 {
     Item *i = new Item;
-    const Symbol*s=0;
-
-    switch(rq->tag){
-    case Request::NOTE:
-       s = Symbol::find_ball(rq->note()->balltype);
-       break;
-    case Request::REST:
-       s = Symbol::find_rest(rq->rest()->balltype);
-       break;
-    default:
-       assert(false);
-       break;
-    }  
-    i->output = new Molecule(Atom(s));
-
-    staff_->pscore_->typeset_item(i, score_column->pcol, staff_->theline,0 );  
+    Symbol s;
+    int dots=0;
+
+    if (rq->note())
+       s = Lookup::ball(rq->note()->balltype);
+    if (rq->rhythmic())
+       dots=rq->rhythmic()->dots;
+    if (rq->rest())
+       s = Lookup::rest(rq->rest()->balltype);
+
+    Molecule *m = new Molecule(Atom(s));
+    if (dots) {
+       Symbol d = Lookup::dots(dots);
+       Molecule dm;
+       dm.add(Atom(d));
+       m->add_right(dm);
+    }
+    i->output=m;
+    staff_->pscore_->typeset_item(i, score_column->pcol, staff_->theline,0 );
 }
 
 void
diff --git a/stcol.cc b/stcol.cc
new file mode 100644 (file)
index 0000000..e9a80c8
--- /dev/null
+++ b/stcol.cc
@@ -0,0 +1,30 @@
+#include "stcol.hh"
+#include "sccol.hh"
+#include "voice.hh"
+
+bool
+Staff_column::mus() const
+{
+    return score_column->musical;
+}
+
+Mtime
+Staff_column::when() const
+{
+    return score_column->when;
+}
+
+void
+Staff_column::add(Voice_element*ve)
+{
+    Mtime d= ve->duration;
+    if (d){
+       score_column->durations.add(d);
+    }
+       
+    v_elts.add(ve);
+}
+
+Staff_column::Staff_column(Score_column*s) {
+    score_column = s;
+}
diff --git a/stcol.hh b/stcol.hh
new file mode 100644 (file)
index 0000000..2b23934
--- /dev/null
+++ b/stcol.hh
@@ -0,0 +1,33 @@
+/*
+  stcol.hh -- part of LilyPond
+
+  (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef STCOL_HH
+#define STCOL_HH
+#include "proto.hh"
+#include "vray.hh"
+
+struct Staff_column {
+    Score_column *score_column;
+
+    /// fields to collect data vertically.
+    svec<Voice_element *> v_elts;
+    svec<Command *> s_commands;
+    
+    Staff_column(Score_column*s); 
+    bool mus() const ;
+    Real when() const;
+    void add(Voice_element*ve);
+    /****************************************************************
+      VIRTUAL
+    ****************************************************************/
+    virtual void process_requests()=0;
+    virtual void process_commands()=0;
+    virtual ~Staff_column() { }
+};
+
+
+#endif // STCOL_HH
+