\version "0.1.1";
+breve = \duration { -1 0 }
+longa = \duration { -2 0 }
+
\include "dynamic.ly"
\include "dutch.ly"
+
+
\include "script.ly"
\include "paper16.ly"
-%{MudelaHeader
+\header{
- filename: toccata-fuga-E.ly
- title: toccata and fuga in E-major
- opus: BWV 566
- toccata: 3 bar excerpt
- 2nd fuga: transposed subject --- 4 bar excerpt
+filename toccata-fuga-E.ly
+title toccata and fuga in E-major
+opus BWV 566
+ toccata 3 bar excerpt
+ 2nd fuga transposed subject --- 4 bar excerpt
- composers: Johann Sebastian Bach (1685-1750)
- entered-by: JCN
- copyright: public domain
+composers Johann Sebastian Bach (1685-1750)
+enteredby JCN
+copyright public domain
+}
+
+%{
Tested Features:
purpose of this file is testing:
* real-life collisions
* multi-voice input --- splitting?
* organ staff...
-
-EndMudelaHeader
%}
#include <stdio.h>
+#include <ctype.h>
#include "string.hh"
#include "string-convert.hh"
#include "parseconstruct.hh"
#include "main.hh"
#include "identifier.hh"
+void strip_trailing_white(String&);
+void strip_leading_white(String&);
+
#define start_quote() \
yy_push_state(quote);\
%option warn
%x incl
+%x header
%x lyrics
%x notes
%x quote
REAL ({INT}\.{N}*)|(-?\.{N}+)
KEYWORD \\{WORD}
WHITE [ \n\t\f]
+HORIZONTALWHITE [ \t]
BLACK [^ \n\t\f]
RESTNAME [rs]
NOTECOMMAND \\{A}+
%[^{\n].* {
}
{WHITE}+ {
-
+
}
}
"%"+"}" {
yy_pop_state();
}
+ <<EOF>> {
+ LexerError("EOF found inside a comment");
+ if (! close_input())
+ yyterminate(); // can't move this, since it actually rets a YY_NULL
+ }
}
-<longcomment><<EOF>> {
- LexerError("EOF found inside a comment");
- if (! close_input()) {
- yyterminate(); // can't move this, since it actually rets a YY_NULL
+<header>{
+ [\{\}] {
+ return YYText()[0];
+ }
+ ^{WORD} {
+ String s=YYText();
+ yylval.string = new String(s);
+ return FIELDNAME;
+ }
+ {HORIZONTALWHITE}+{BLACK}.*\n {
+ String s=YYText();
+ strip_leading_white(s);
+ strip_trailing_white(s);
+ yylval.string = new String(s);
+ return RECORDLINE;
+ }
+ {WHITE}* {
+ }
+
+ . {
+ return YYText()[0];
}
}
+
+
<notes,INITIAL,lyrics>\\include {
yy_push_state(incl);
}
{
return YY_START == lyrics;
}
+
+void
+My_lily_lexer::push_header_state()
+{
+ yy_push_state(header);
+}
+
+void strip_trailing_white(String&s)
+{
+ int i=0;
+ for (; i < s.length_i(); i++)
+ if (!isspace(s[i]))
+ break;
+
+ s = s.nomid_str(0, i);
+}
+void strip_leading_white(String&s)
+{
+ int i=s.length_i();
+ while (i--)
+ if (!isspace(s[i]))
+ break;
+
+ s = s.left_str(i+1);
+
+}
#include "parseconstruct.hh"
static Keyword_ent the_key_tab[]={
- {"accepts", ACCEPTS},
- {"alias", ALIAS},
- {"bar", BAR},
- {"cadenza", CADENZA},
- {"clear", CLEAR},
- {"clef", CLEF},
- {"cm", CM_T},
- {"consists", CONSISTS},
- {"contains", CONTAINS},
- {"duration", DURATIONCOMMAND},
- {"absdynamic", ABSDYNAMIC},
- {"group", GROUP},
- {"hshift", HSHIFT},
- {"id", ID},
- {"in", IN_T},
- {"requesttranslator", REQUESTTRANSLATOR},
- {"lyric", LYRIC},
- {"key", KEY},
- {"melodic" , MELODIC},
- {"melodic_request", MELODIC_REQUEST},
- {"meter", METER},
- {"midi", MIDI},
- {"mm", MM_T},
- {"multi", MULTI},
- {"notenames", NOTENAMES},
- {"octave", OCTAVECOMMAND},
- {"output", OUTPUT},
- {"partial", PARTIAL},
- {"paper", PAPER},
- {"plet", PLET},
- {"pt", PT_T},
- {"score", SCORE},
- {"script", SCRIPT},
- {"skip", SKIP},
- {"staff", STAFF},
- {"stem", STEM},
- {"table", TABLE},
- {"spandynamic", SPANDYNAMIC},
- {"symboltables", SYMBOLTABLES},
- {"tempo", TEMPO},
- {"texid", TEXID},
- {"textstyle", TEXTSTYLE},
- {"transpose", TRANSPOSE},
- {"version", VERSION},
- {"grouping", GROUPING},
- {0,0}
+ {"accepts", ACCEPTS},
+ {"alias", ALIAS},
+ {"bar", BAR},
+ {"cadenza", CADENZA},
+ {"clear", CLEAR},
+ {"clef", CLEF},
+ {"cm", CM_T},
+ {"consists", CONSISTS},
+ {"contains", CONTAINS},
+ {"duration", DURATION},
+ {"absdynamic", ABSDYNAMIC},
+ {"group", GROUP},
+ {"hshift", HSHIFT},
+ {"id", ID},
+ {"in", IN_T},
+ {"requesttranslator", REQUESTTRANSLATOR},
+ {"lyric", LYRIC},
+ {"key", KEY},
+ {"melodic" , MELODIC},
+ {"melodic_request", MELODIC_REQUEST},
+ {"meter", METER},
+ {"midi", MIDI},
+ {"mm", MM_T},
+ {"multi", MULTI},
+ {"header", HEADER},
+ {"notenames", NOTENAMES},
+ {"octave", OCTAVE},
+ {"output", OUTPUT},
+ {"partial", PARTIAL},
+ {"paper", PAPER},
+ {"plet", PLET},
+ {"pt", PT_T},
+ {"score", SCORE},
+ {"script", SCRIPT},
+ {"skip", SKIP},
+ {"staff", STAFF},
+ {"stem", STEM},
+ {"table", TABLE},
+ {"spandynamic", SPANDYNAMIC},
+ {"symboltables", SYMBOLTABLES},
+ {"tempo", TEMPO},
+ {"texid", TEXID},
+ {"textstyle", TEXTSTYLE},
+ {"transpose", TRANSPOSE},
+ {"version", VERSION},
+ {"grouping", GROUPING},
+ {0,0}
};
My_lily_lexer::My_lily_lexer()
{
- keytable_p_ = new Keyword_table (the_key_tab);
- identifier_assoc_p_ = new Assoc<String, Identifier*>;
- errorlevel_i_ = 0;
- post_quotes_b_ = false;
- note_tab_p_ = new Notename_table;
+ keytable_p_ = new Keyword_table (the_key_tab);
+ identifier_assoc_p_ = new Assoc<String, Identifier*>;
+ errorlevel_i_ = 0;
+ post_quotes_b_ = false;
+ note_tab_p_ = new Notename_table;
}
int
My_lily_lexer::lookup_keyword (String s)
{
- return keytable_p_->lookup (s);
+ return keytable_p_->lookup (s);
}
Identifier*
My_lily_lexer::lookup_identifier (String s)
{
- if (!identifier_assoc_p_->elt_b (s))
+ if (!identifier_assoc_p_->elt_b (s))
return 0;
-
- return (*identifier_assoc_p_)[s];
+
+ return (*identifier_assoc_p_)[s];
}
void
My_lily_lexer::set_identifier (String name_str, Identifier*i)
{
- Identifier *old = lookup_identifier (name_str);
- if (old) {
+ Identifier *old = lookup_identifier (name_str);
+ if (old)
+ {
old->warning( "redeclaration of \\" + name_str);
delete old;
}
- (*identifier_assoc_p_)[name_str] = i;
+ (*identifier_assoc_p_)[name_str] = i;
}
My_lily_lexer::~My_lily_lexer()
{
- delete keytable_p_;
+ delete keytable_p_;
- for (Assoc_iter<String,Identifier*>
- ai (*identifier_assoc_p_); ai.ok(); ai++) {
+ for (Assoc_iter<String,Identifier*>
+ ai (*identifier_assoc_p_); ai.ok(); ai++)
+ {
DOUT << "deleting: " << ai.key()<<'\n';
delete ai.val();
}
- delete note_tab_p_;
- delete identifier_assoc_p_;
+ delete note_tab_p_;
+ delete identifier_assoc_p_;
}
void
My_lily_lexer::print_declarations (bool init_b)const
{
- for (Assoc_iter<String,Identifier*> ai (*identifier_assoc_p_); ai.ok();
- ai++) {
- if (ai.val()->init_b_ == init_b) {
+ for (Assoc_iter<String,Identifier*> ai (*identifier_assoc_p_); ai.ok();
+ ai++)
+ {
+ if (ai.val()->init_b_ == init_b)
+ {
DOUT << ai.key() << '=';
ai.val()->print ();
- }
+ }
}
}
void
My_lily_lexer::LexerError (char const *s)
{
- if (include_stack_.empty()) {
+ if (include_stack_.empty())
+ {
*mlog << "error at EOF" << s << '\n';
- } else {
+ }
+ else
+ {
errorlevel_i_ |= 1;
Input spot (source_file_l(),here_ch_C());
Melodic_req*
My_lily_lexer::lookup_melodic_req_l (String s)
{
- return note_tab_p_->get_l (s);
+ return note_tab_p_->get_l (s);
}
void
My_lily_lexer::add_notename (String s, Melodic_req *p)
{
- note_tab_p_->add (s,p);
+ note_tab_p_->add (s,p);
}
void
My_lily_lexer::clear_notenames()
{
- delete note_tab_p_;
- note_tab_p_ = new Notename_table;
+ delete note_tab_p_;
+ note_tab_p_ = new Notename_table;
}
%{ // -*-Fundamental-*-
/*
- parser.y -- lily parser
+ parser.y -- YACC parser for mudela
source file of the GNU LilyPond music typesetter
#include "input-translator.hh"
#include "score.hh"
#include "music-list.hh"
+#include "header.hh"
+#include "duration-convert.hh"
#ifndef NDEBUG
#define YYDEBUG 1
Music *music;
Music_list *musiclist;
Score *score;
+ Header *header;
Interval *interval;
Lookup*lookup;
Melodic_req * melreq;
%token CONSISTS
%token ACCEPTS
%token CM_T
-%token DURATIONCOMMAND
+%token DURATION
%token ABSDYNAMIC
%token END
%token GROUPING
%token GROUP
%token REQUESTTRANSLATOR
%token HSHIFT
+%token HEADER
%token IN_T
%token ID
%token LYRIC
%token MM_T
%token MULTI
%token NOTENAMES
-%token OCTAVECOMMAND
+%token OCTAVE
%token OUTPUT
%token PAPER
%token PARTIAL
%type <i> dots
%token <i> INT
%token <melreq> NOTENAME_ID
+%token <id> DURATION_IDENTIFIER
%token <id> IDENTIFIER
%token <id> MELODIC_REQUEST_IDENTIFIER
%token <id> MUSIC_IDENTIFIER
%token <id> REQUEST_IDENTIFIER
%token <real> REAL
%token <string> DURATION RESTNAME
-%token <string> STRING
+%token <string> STRING
+%token <string> FIELDNAME RECORDLINE
%token <i> POST_QUOTES
%token <i> PRE_QUOTES
+%type <header> mudela_header mudela_header_body
%type <box> box
%type <c> open_request_parens close_request_parens
%type <c> open_plet_parens close_plet_parens
%type <i> int
%type <i> script_dir
%type <id> identifier_init
-%type <duration> explicit_duration notemode_duration entered_notemode_duration
+%type <duration> explicit_steno_duration notemode_duration
+%type <duration> entered_notemode_duration explicit_duration
%type <interval> dinterval
%type <intvec> intastint_list
%type <lookup> symtables symtables_body
%type <paper> paper_block paper_body
%type <real> dim real
%type <real> unit
-%type <request> post_request pre_request command_req verbose_command_req abbrev_command_req
+%type <request> post_request pre_request command_req verbose_command_req
+%type <request> abbrev_command_req
%type <request> script_req dynamic_req
%type <score> score_block score_body
%type <script> script_definition script_body mudela_script gen_script_def
%type <symtable> symtable symtable_body
%type <itrans> input_translator_spec input_translator_spec_body
%type <tempo> tempo_request
+%type <string> header_record
%left PRIORITY
%%
mudela: /* empty */
+ | mudela mudela_header {
+ }
| mudela score_block {
add_score($2);
}
delete $2;
}
;
+
+mudela_header_body:
+ {
+ $$ = new Header;
+ }
+ | mudela_header_body FIELDNAME header_record {
+ (*$$)[*$2] = *$3;
+ delete $2;
+ delete $3;
+ }
+ ;
+
+mudela_header:
+ HEADER {
+ THIS->lexer_p_->push_header_state();
+ }
+
+ '{' mudela_header_body '}' {
+ $$ = $4;
+ THIS->lexer_p_->pop_state();
+ }
+ ;
+
+
+header_record:
+ {
+ $$ = new String;
+ }
+ | header_record RECORDLINE {
+ *$$ += *$2;
+ delete $2;
+ }
+ ;
+
/*
DECLARATIONS
*/
| input_translator_spec {
$$ = new Input_translator_id ( $1, INPUT_TRANS_IDENTIFIER);
}
+ | explicit_duration {
+ $$ = new Duration_id( $1, DURATION_IDENTIFIER);
+ }
;
SCORE
*/
score_block:
- SCORE { THIS->remember_spot(); }
+ SCORE { THIS->remember_spot();
+ THIS->error_level_i_ =0;
+ }
/*cont*/ '{' score_body '}' {
$$ = $4;
$$->set_spot(THIS->pop_spot());
| SCORE_IDENTIFIER {
$$ = $1->score();
}
+ | score_body mudela_header {
+ $$->header_p_ = $2;
+ }
| score_body Music {
$$->music_p_ = $2;
}
}
;
+explicit_duration:
+ DURATION '{' int int '}' {
+ $$ = new Duration;
+ $$-> durlog_i_ = $3;
+ $$-> dots_i_ = $4;
+ }
+ ;
+
dynamic_req:
ABSDYNAMIC '{' int '}' {
Absolute_dynamic_req *ad_p = new Absolute_dynamic_req;
PLET INT '/' INT {
THIS->default_duration_.set_plet($2,$4);
}
- | DURATIONCOMMAND STRING {
+ | DURATION STRING {
THIS->set_duration_mode(*$2);
delete $2;
}
- | DURATIONCOMMAND entered_notemode_duration {
+ | DURATION entered_notemode_duration {
THIS->set_default_duration($2);
delete $2;
}
- | OCTAVECOMMAND {
+ | OCTAVE {
/*
This is weird, but default_octave_i_
is used in steno_note_req too
{
$$ = new Moment(0,1);
}
- | duration_length explicit_duration {
+ | duration_length explicit_steno_duration {
*$$ += $2->length();
}
;
$$ = new Duration(THIS->default_duration_);
$$->dots_i_ = $1;
}
- | explicit_duration {
+ | explicit_steno_duration {
THIS->set_last_duration($1);
$$ = $1;
}
}
;
-explicit_duration:
+explicit_steno_duration:
int {
$$ = new Duration;
if ( !Duration::duration_type_b($1) )
THIS->parser_error("Not a duration");
else {
- $$->type_i_ = $1;
+ $$->durlog_i_ = Duration_convert::i2_type($1);
}
}
- | explicit_duration '.' {
+ | DURATION_IDENTIFIER {
+ $$ = $1->duration();
+ }
+ | explicit_steno_duration '.' {
$$->dots_i_ ++;
}
- | explicit_duration '*' int {
+ | explicit_steno_duration '*' int {
$$->plet_.iso_i_ *= $3;
}
- | explicit_duration '/' int {
+ | explicit_steno_duration '/' int {
$$->plet_.type_i_ *= $3;
}
;