MAJVER=0
MINVER=0
-PATCHLEVEL=3
+PATCHLEVEL=4
#
#
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)
##################################################################
include depend
parser.cc: parser.y
- bison -d $<
+ $(BISON) -d $<
mv parser.tab.h parser.hh
mv parser.tab.c parser.cc
make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $@
lexer.cc: lexer.l
- flex -+ -t $< > $@
+ $(FLEX) -+ -t $< > $@
DDIR=$(DNAME)
dist:
#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
+
%%
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
;
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");
+
+ }
;
%%
parse_file(String s)
{
*mlog << "Parsing ... ";
+#ifdef YYDEBUG
yydebug = !monitor.silence("Parser");
+#endif
new_input(s);
yyparse();
}
#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)
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;
+
}
-
}
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);
}
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
--- /dev/null
+#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;
+}
--- /dev/null
+/*
+ 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
+