From: fred Date: Tue, 22 Oct 1996 20:43:52 +0000 (+0000) Subject: lilypond-0.0.4 X-Git-Tag: release/1.5.59~7039 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b920d325da38fea5c8645b3ad8cdc8839d12e948;p=lilypond.git lilypond-0.0.4 --- diff --git a/Makefile b/Makefile index 38b71b9bbb..2f5b450761 100644 --- 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: diff --git a/parser.y b/parser.y index cb0853b340..d60face970 100644 --- a/parser.y +++ b/parser.y @@ -2,20 +2,23 @@ #include #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; @@ -24,22 +27,30 @@ 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 unit %token IDENTIFIER %token PITCH DURATION RESTNAME %token REAL %token STRING +%type paper_block paper_body +%type dim %type voice_block voice_body voice_elts voice_elts_dollar %type voice_elt %type score_command %type score_block score_body %type staff_block rhythmstaff_block rhythmstaff_body +%type 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(); } diff --git a/rhythmstaf.cc b/rhythmstaf.cc index a7fade6fc5..d2a85d62ce 100644 --- a/rhythmstaf.cc +++ b/rhythmstaf.cc @@ -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 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 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 sv(staff_->pscore_-> + select_items(staff_->theline, score_column->pcol)); + for (int j=0; joutput->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 index 0000000000..e9a80c8e36 --- /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 index 0000000000..2b23934c53 --- /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 v_elts; + svec 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 +