From: fred Date: Sun, 24 Mar 2002 19:35:52 +0000 (+0000) Subject: lilypond-0.0.43 X-Git-Tag: release/1.5.59~5156 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d05e2a7456f3c135daaeca433976e76c0d070ea3;p=lilypond.git lilypond-0.0.43 --- diff --git a/.dstreamrc b/.dstreamrc index c7b8c24c77..dd50d37872 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -1,8 +1,7 @@ # class name silence? Dstream 1 -My_flex_lexer 1 -yyFlexLexer 1 +My_lily_lexer 0 PCol 1 Score_column 1 Ineq_constrained_qp 1 @@ -14,9 +13,9 @@ Idealspacing 1 # yydebug InitParser 1 -Parser 1 +Parser 0 InitDeclarations 1 - +Declarations 0 # FlexLexer debug InitLexer 1 Lexer 1 @@ -47,9 +46,9 @@ Group_change_req 1 Script_req 1 Colinfo 1 Word_wrap 1 -Text_req 1 +Text_req 0 Script_def 1 -Text_def 1 +Text_def 0 Paperdef 1 Symtable 1 Symtables 1 diff --git a/init/table_sixteen.ini b/init/table_sixteen.ini index 240eae0b8b..5d9e6842ad 100644 --- a/init/table_sixteen.ini +++ b/init/table_sixteen.ini @@ -3,36 +3,36 @@ % It has a lot of hard-wired stringconstants % -table_sixteen= -symboltables { +table_sixteen= +\symboltables { - texid "\musixsixteendefs" + \texid "\musixsixteendefs" % index TeXstring, xmin xmax ymin ymax - "scripts" = table { - "fermata" "\fermata" 0pt 0pt 0pt 6pt - "-fermata" "\ifermata" 0pt 0pt -6pt 0pt + "scripts" = \table { + "fermata" "\fermata" 0\pt 0\pt 0\pt 6\pt + "-fermata" "\ifermata" 0\pt 0\pt -6\pt 0\pt "portato" "\portato" "-portato" "\iportato" "tenuto" "\tenuto" "-tenuto" "\itenuto" - "sforzato" "\sforzato" -0.8pt 4.8pt -1.92pt 1.92pt - "marcato" "\marcato" 0pt 4.8pt 0pt 4pt - "-marcato" "\imarcato" 0pt 4.8pt -4pt 0pt - "staccato" "\staccato" 0pt 0pt 0pt 5pt - "staccatissimo" "\staccatissimo" 0pt 0pt 0pt 7.5pt - "-staccatissimo" "\istaccatissimo" 0pt 0pt -7.5pt 0pt - "upbow" "\upbow" -1pt 6pt 0pt 5pt - "downbow" "\downbow" 0pt 5pt 0pt 7.5pt + "sforzato" "\sforzato" -0.8\pt 4.8\pt -1.92\pt 1.92\pt + "marcato" "\marcato" 0\pt 4.8\pt 0\pt 4\pt + "-marcato" "\imarcato" 0\pt 4.8\pt -4\pt 0\pt + "staccato" "\staccato" 0\pt 0\pt 0\pt 5\pt + "staccatissimo" "\staccatissimo" 0\pt 0\pt 0\pt 7.5\pt + "-staccatissimo" "\istaccatissimo" 0\pt 0\pt -7.5\pt 0\pt + "upbow" "\upbow" -1\pt 6\pt 0\pt 5\pt + "downbow" "\downbow" 0\pt 5\pt 0\pt 7.5\pt } - "style" = table { - "roman" "\settext{%}" 0pt 0pt 0pt 8pt - "italic" "\setitalic{%}" 0pt 0pt 0pt 8pt - "dynamic" "\setdynamic{%}" 0pt 0pt 0pt 8pt + "style" = \table { + "roman" "\settext{%}" 0\pt 0\pt 0\pt 8\pt + "italic" "\setitalic{%}" 0\pt 0\pt 0\pt 8\pt + "dynamic" "\setdynamic{%}" 0\pt 0\pt 0\pt 8\pt } - "dynamics" = table { + "dynamics" = \table { "mf" "\dynmf" "fff" "\dynfff" @@ -44,99 +44,99 @@ symboltables { "ppp" "\dynppp" } - "align" = table { + "align" = \table { "-1" "\leftalign{%}" "0" "\centeralign{%}" "1" "\rightalign{%}" } - "clefs" = table { - "violin" "\violinclef" 0pt 12.8pt -10pt 18pt - "bass" "\bassclef" 0pt 12.8pt 0pt 16pt - "alto" "\altoclef" 0pt 12.8pt 0pt 16pt - "tenor" "\altoclef" 0pt 12.8pt 0pt 16pt - "violin_change" "\cviolinclef" 0pt 11.2pt -12pt 12pt - "bass_change" "\cbassclef" 0pt 11.2pt 0pt 16pt - "alto_change" "\caltoclef" 0pt 11.2pt 0pt 16pt - "tenor_change" "\caltoclef" 0pt 11.2pt 0pt 16pt + "clefs" = \table { + "violin" "\violinclef" 0\pt 12.8\pt -10\pt 18\pt + "bass" "\bassclef" 0\pt 12.8\pt 0\pt 16\pt + "alto" "\altoclef" 0\pt 12.8\pt 0\pt 16\pt + "tenor" "\altoclef" 0\pt 12.8\pt 0\pt 16\pt + "violin_change" "\cviolinclef" 0\pt 11.2\pt -12\pt 12\pt + "bass_change" "\cbassclef" 0\pt 11.2\pt 0\pt 16\pt + "alto_change" "\caltoclef" 0\pt 11.2\pt 0\pt 16\pt + "tenor_change" "\caltoclef" 0\pt 11.2\pt 0\pt 16\pt } - "balls" = table { - "1" "\wholeball" 0pt 6pt -2 pt 2pt - "2" "\halfball" 0pt 5pt -2 pt 2pt - "4" "\quartball" 0pt 5pt -2 pt 2pt + "balls" = \table { + "1" "\wholeball" 0\pt 6\pt -2 \pt 2\pt + "2" "\halfball" 0\pt 5\pt -2 \pt 2\pt + "4" "\quartball" 0\pt 5\pt -2 \pt 2\pt } - "slur" = table { + "slur" = \table { "whole" "\slurchar%{%}" "half" "\hslurchar%{%}" } - "accidentals" = table { - "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt - "-1" "\flat" 0pt 6pt -2.5pt 7.5pt - "0" "\natural" 0pt 6pt -7.5pt 7.5pt - "1" "\sharp" 0pt 6pt -7.5pt 7.5pt - "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt + "accidentals" = \table { + "-2" "\flatflat" 0\pt 10.2\pt -2.5\pt 7.5\pt + "-1" "\flat" 0\pt 6\pt -2.5\pt 7.5\pt + "0" "\natural" 0\pt 6\pt -7.5\pt 7.5\pt + "1" "\sharp" 0\pt 6\pt -7.5\pt 7.5\pt + "2" "\sharpsharp" 0\pt 6\pt -2.5\pt 7.5\pt } - "streepjes" = table { - "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt - "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt + "streepjes" = \table { + "toplines" "\toplines{%}" -3\pt 9\pt 0\pt 0\pt + "botlines" "\botlines{%}" -3\pt 9\pt 0\pt 0\pt } - "bars" = table { + "bars" = \table { "empty" "\emptybar" - "|" "\maatstreep" 0pt 0.4pt -8pt 8pt - "||" "\finishbar" 0pt 2pt -8pt 8pt - ":|" "\repeatbar" -4pt 0pt -8pt 8pt - "|:" "\startrepeat" 0pt 4pt -8pt 8pt - ":|:" "\repeatbarstartrepeat" 0pt 16pt -8pt 8pt + "|" "\maatstreep" 0\pt 0.4\pt -8\pt 8\pt + "||" "\finishbar" 0\pt 2\pt -8\pt 8\pt + ":|" "\repeatbar" -4\pt 0\pt -8\pt 8\pt + "|:" "\startrepeat" 0\pt 4\pt -8\pt 8\pt + ":|:" "\repeatbarstartrepeat" 0\pt 16\pt -8\pt 8\pt } - "rests" = table { - "1" "\wholerest" -5pt 1pt -1pt 1pt - "2" "\halfrest" -5pt 1pt -1pt 1pt - "4" "\quartrest" -5pt 2pt -5pt 5pt - "8" "\eighthrest" 0pt 5pt 0pt 8pt - "16" "\sixteenthrest" 0pt 6pt 0pt 12pt - "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt + "rests" = \table { + "1" "\wholerest" -5\pt 1\pt -1\pt 1\pt + "2" "\halfrest" -5\pt 1\pt -1\pt 1\pt + "4" "\quartrest" -5\pt 2\pt -5\pt 5\pt + "8" "\eighthrest" 0\pt 5\pt 0\pt 8\pt + "16" "\sixteenthrest" 0\pt 6\pt 0\pt 12\pt + "32" "\thirtysecondrest" 0\pt 6\pt 0\pt 16\pt } - "meters" = table { - "C" "\fourfourmeter" 0pt 10pt -5pt 5pt - "C2" "\allabreve" 0pt 10pt -5pt 5pt + "meters" = \table { + "C" "\fourfourmeter" 0\pt 10\pt -5\pt 5\pt + "C2" "\allabreve" 0\pt 10\pt -5\pt 5\pt } % dims ignored for this table - "param" = table { - "meter" "\generalmeter{%}{%}" 0pt 10pt -5pt 5pt + "param" = \table { + "meter" "\generalmeter{%}{%}" 0\pt 10\pt -5\pt 5\pt "linestaf" "\linestafsym{%}{%}" "stem" "\stem{%}{%}" "fill" "\hbox{}" - "crescendo" "\crescendosym{%}" 0pt 0pt -3pt 3pt - "decrescendo" "\decrescendosym{%}" 0pt 0pt -3pt 3pt + "crescendo" "\crescendosym{%}" 0\pt 0\pt -3\pt 3\pt + "decrescendo" "\decrescendosym{%}" 0\pt 0\pt -3\pt 3\pt } - "dots" = table { - "1" "\lsingledot" 0pt 2pt -1pt 1pt - "2" "\ldoubledot" 0pt 5pt -1pt 1pt - "3" "\ltripledot" 0pt 8pt -1pt 1pt + "dots" = \table { + "1" "\lsingledot" 0\pt 2\pt -1\pt 1\pt + "2" "\ldoubledot" 0\pt 5\pt -1\pt 1\pt + "3" "\ltripledot" 0\pt 8\pt -1\pt 1\pt } - "flags" = table { - "8" "\eigthflag" 0pt 4pt 0pt 0pt - "16" "\sixteenthflag" 0pt 4pt 0pt 0pt - "32" "\thirtysecondflag" 0pt 4pt 0pt 0pt - "-8" "\deigthflag" 0pt 4pt 0pt 0pt - "-16" "\dsixteenthflag" 0pt 4pt 0pt 0pt - "-32" "\dthirtysecondflag" 0pt 4pt 0pt 0pt + "flags" = \table { + "8" "\eigthflag" 0\pt 4\pt 0\pt 0\pt + "16" "\sixteenthflag" 0\pt 4\pt 0\pt 0\pt + "32" "\thirtysecondflag" 0\pt 4\pt 0\pt 0\pt + "-8" "\deigthflag" 0\pt 4\pt 0\pt 0\pt + "-16" "\dsixteenthflag" 0\pt 4\pt 0\pt 0\pt + "-32" "\dthirtysecondflag" 0\pt 4\pt 0\pt 0\pt } - "beamslopes" = table { + "beamslopes" = \table { "slope" "\beamslope{%}{%}" "horizontal" "\rulesym{%}{%}" } } -default_table = symboltables { table_sixteen } +default_table = \symboltables { table_sixteen } diff --git a/lily/lexer.l b/lily/lexer.l index 29738a70aa..549a957efd 100644 --- a/lily/lexer.l +++ b/lily/lexer.l @@ -4,14 +4,14 @@ #include "string.hh" #include "string-convert.hh" -#include "lexer.hh" +#include "my-lily-lexer.hh" #include "varray.hh" #include "parser.hh" #include "debug.hh" #include "input-score.hh" #include "parseconstruct.hh" #include "main.hh" -#include "identparent.hh" +#include "identifier.hh" #define start_quote() \ yy_push_state(quote);\ @@ -25,13 +25,13 @@ %option nodefault %option yylineno %option debug -%option yyclass="My_flex_lexer" +%option yyclass="My_lily_lexer" %option stack -%x notes %x incl -%x quote %x lyrics +%x notes +%x quote @@ -48,23 +48,32 @@ WORD {A}{AN}* ALPHAWORD {A}+ INT -?{N}+ REAL {INT}?(\.{N}*)? - -OPTSIGN !? -PITCHMOD ['`]*{OPTSIGN} -RESTNAME r|s|p +KEYWORD \\{WORD} +WHITE [ \n\t\f] +BLACK [^ \n\t\f] +RESTNAME r NOTECOMMAND \\{WORD} DOTS \.+ -LYRICS {TEX}+ -COMMENT [%#].*\n +LYRICS {AA}[^0-9 \t\n\f]* +COMMENT %.*\n %% -\$ { - yy_push_state(notes); +{COMMENT} { } -\@ { - yy_push_state(lyrics); + + +^include { + yy_push_state(incl); +} +{WHITE}* { /* eat the whitespace */ } +\"[^"]*\" { /* got the include file name */ + String s (YYText()+1); + s = s.left_str(s.length_i()-1); + defined_ch_c_l = here_ch_c_l() - String( YYText() ).length_i() - 1; + new_input(s); + yy_pop_state(); } {RESTNAME} { @@ -73,32 +82,23 @@ COMMENT [%#].*\n mtor << "rest:"<< yylval.string; return RESTNAME; } +\$\\{BLACK}*{WHITE} { + String s=YYText() + 2; + s=s.left_str(s.length_i() - 1); + return scan_escaped_word(s); +} +\${BLACK}*{WHITE} { + String s=YYText() + 1; + s=s.left_str(s.length_i() - 1); + return scan_bare_word(s); +} {ALPHAWORD} { - String str = YYText(); - mtor << "word: " << str<< eol; - Identifier * id = lookup_identifier(str); - if (id) { - yylval.id = id; - return id->token_code_i_; - } + return scan_bare_word(YYText()); - yylval.string=new String( str ); - return STRING; } + {NOTECOMMAND} { - String c = YYText() +1; - mtor << "\\word: " << YYText()+1<token_code_i_; - } - String *sp = new String( c); - yylval.string=sp; - return STRING; + return scan_escaped_word(YYText()+1); } {DOTS} { @@ -109,13 +109,11 @@ COMMENT [%#].*\n yylval.i = String_convert::dec2_i( String( YYText() ) ); return INT; } -{COMMENT} { -} [ \t\n]+ { } -\$ { - yy_pop_state(); +\+\+ { + return CONCAT; } \" { start_quote(); @@ -128,6 +126,9 @@ COMMENT [%#].*\n \" { start_quote(); } +\\\" { + *yylval.string +='\"'; +} [^"]+ { *yylval.string += YYText(); } @@ -149,30 +150,7 @@ COMMENT [%#].*\n return INT; } {NOTECOMMAND} { - String c = YYText() +1; - mtor << "\\word: " << YYText()+1<{LYRICS} { /* ugr. This sux. */ @@ -191,9 +169,6 @@ COMMENT [%#].*\n } \| { return YYText()[0]; -} -{COMMENT} { - } [{}] { return YYText()[0]; @@ -203,9 +178,6 @@ COMMENT [%#].*\n } [ \t\n]+ { } -@ { - yy_pop_state(); -} <> { mtor << "<>"; @@ -213,38 +185,12 @@ COMMENT [%#].*\n if (! close_input()) yyterminate(); // can't move this, since it actually rets a YY_NULL } - - -include { - yy_push_state(incl); +{WORD} { + return scan_bare_word(YYText()); } -[ \t]* { /* eat the whitespace */ } -\"[^"]*\"+ { /* got the include file name */ - String s (YYText()+1); - s = s.left_str(s.length_i()-1); - defined_ch_c_l = here_ch_c_l() - String( YYText() ).length_i() - 1; - new_input(s); - yy_pop_state(); +{KEYWORD} { + return scan_escaped_word(YYText()+1); } - - -{WORD} { - mtor << "word: " << YYText()<token_code_i_; + } + + yylval.string=new String( str ); + return STRING; +} + +bool +My_lily_lexer::note_state_b() const +{ + return YY_START == notes; +} + +bool +My_lily_lexer::lyric_state_b() const +{ + return YY_START == lyrics; +} diff --git a/lily/parser.y b/lily/parser.y index e30f2da400..d5d53de1d1 100644 --- a/lily/parser.y +++ b/lily/parser.y @@ -1,13 +1,16 @@ %{ // -*-Fundamental-*- #include - +#include "script-def.hh" +#include "symtable.hh" #include "lookup.hh" #include "misc.hh" -#include "lexer.hh" +#include "my-lily-lexer.hh" #include "paper-def.hh" #include "midi-def.hh" -#include "input-score.hh" #include "main.hh" +#include "input-score.hh" +#include "input-staff.hh" +#include "input-music.hh" #include "keyword.hh" #include "debug.hh" #include "parseconstruct.hh" @@ -27,7 +30,7 @@ Paper_def*default_paper(); char const* defined_ch_c_l; char const* req_defined_ch_c_l; int fatal_error_i = 0; - +bool init_parse_b; %} @@ -69,15 +72,14 @@ int fatal_error_i = 0; %token CADENZA %token CLEF %token CM_T -%token COMMAND -%token COMMANDS +%token CONCAT %token DURATIONCOMMAND %token DYNAMIC %token END %token GEOMETRIC -%token GOTO %token GROUPING %token IN_T +%token LYRICS %token KEY %token MELODIC %token METER @@ -99,22 +101,25 @@ int fatal_error_i = 0; %token STEM %token SYMBOLTABLES %token TABLE -%token TABLE +%token TRANSPOSE %token TEMPO %token TEXID %token TEXTSTYLE %token TITLE %token UNITSPACE -%token VOICE -%token VOICES %token WIDTH %token DOTS %token INT %token IDENTIFIER %token MELODIC_REQUEST_IDENTIFIER +%token CHORD_IDENTIFIER +%token VOICE_IDENTIFIER %token POST_REQUEST_IDENTIFIER +%token SCRIPT_IDENTIFIER +%token STAFF_IDENTIFIER %token REAL_IDENTIFIER +%token SCORE_IDENTIFIER %token REQUEST_IDENTIFIER %token REAL %token DURATION RESTNAME @@ -122,7 +127,7 @@ int fatal_error_i = 0; %type box %type open_request_parens close_request_parens close_plet_parens -%type music_chord music_chord_body +%type music_chord music_chord_body init_music_chord %type voice_elt full_element lyrics_elt command_elt %type int %type octave_quotes octave_quote @@ -133,14 +138,14 @@ int fatal_error_i = 0; %type dinterval %type intastint_list %type symtables symtables_body -%type melodic_request +%type melodic_request steno_melodic_req %type steno_note_req %type pitch_list %type midi_block midi_body %type duration_length -%type music -%type music_voice_body music_voice - +%type init_music +%type transposed_music_voice init_lyrics_voice +%type music_voice_body music_voice init_music_voice %type paper_block paper_body %type dim real %type unit @@ -154,6 +159,11 @@ int fatal_error_i = 0; %type symtable symtable_body %type mudela_text + +%left PRIORITY + +%expect 1 /* have to fix this. */ + %% mudela: /* empty */ @@ -169,33 +179,48 @@ mudela: /* empty */ */ add_declaration: declaration { lexer->add_identifier($1); + $1->init_b_ = init_parse_b; + $1->defined_ch_C_ = define_spots.pop(); } ; declarable_identifier: - STRING { $$ = $1; - if (lexer->lookup_identifier(*$1)) + STRING { + define_spots.push(lexer->here_ch_c_l()); + $$ = $1; + if (lexer->lookup_identifier(*$1)) warning("redeclaration of `" + *$1 + "'", lexer->here_ch_c_l()); } - | IDENTIFIER { $$ = new String($1->name); } + | IDENTIFIER { + define_spots.push(lexer->here_ch_c_l()); + $$ = new String($1->name); + } ; declaration: - declarable_identifier '=' staff_block { - $$ = new Staff_id(*$1, $3, IDENTIFIER); + declarable_identifier '=' score_block { + $$ = new Score_id(*$1, $3, SCORE_IDENTIFIER); + delete $1; + } + | declarable_identifier '=' staff_block { + $$ = new Staff_id(*$1, $3, STAFF_IDENTIFIER); delete $1; } - | declarable_identifier '=' music_voice { - $$ = new M_voice_id(*$1, $3, IDENTIFIER); + | declarable_identifier '=' init_music_voice { + $$ = new M_voice_id(*$1, $3, VOICE_IDENTIFIER); + delete $1; + } + | declarable_identifier '=' init_lyrics_voice { + $$ = new M_voice_id(*$1, $3, VOICE_IDENTIFIER); delete $1; } | declarable_identifier '=' script_definition { - $$ = new Script_id(*$1, $3, IDENTIFIER); + $$ = new Script_id(*$1, $3, SCRIPT_IDENTIFIER); delete $1; } - | declarable_identifier '=' music_chord { - $$ = new M_chord_id(*$1, $3, IDENTIFIER); + | declarable_identifier '=' init_music_chord { + $$ = new M_chord_id(*$1, $3, CHORD_IDENTIFIER); delete $1; } | declarable_identifier '=' symtables { @@ -234,21 +259,16 @@ score_block: /* handle error levels. */ $$->errorlevel_i_ = lexer->errorlevel_i_; lexer->errorlevel_i_ = 0; - - /* unbarf score without global music. */ - if (!$$-> score_wide_music_p_) { - $$-> score_wide_music_p_ = new Music_voice; - } } ; score_body: { $$ = new Input_score; } - | score_body staff_block { $$->add($2); } - | score_body COMMANDS '{' music_voice_body '}' { - $$->set($4); + | SCORE_IDENTIFIER { + $$ = $1->score(true); } + | score_body staff_block { $$->add($2); } | score_body paper_block { $$->set($2); } | score_body midi_block { $$->set($2); } | score_body error { @@ -269,7 +289,6 @@ intastint_list: */ paper_block: PAPER - '{' paper_body '}' { $$ = $3; } ; @@ -327,7 +346,7 @@ staff_block: staff_init: - IDENTIFIER { $$ = $1->staff(true); } + STAFF_IDENTIFIER { $$ = $1->staff(true); } | STRING { $$ = new Input_staff(*$1); delete $1; @@ -339,10 +358,7 @@ staff_init: staff_body: staff_init - | staff_body COMMANDS '{' music_voice_body '}' { - $$->set_score_wide($4); - } - | staff_body music { + | staff_body init_music { $2->set_default_group( "staff_music" + String($$->music_.size())); $$->add($2); } @@ -350,44 +366,80 @@ staff_body: } ; +/* + let the lexer switch mode. +*/ +init_music: + init_music_voice { $$ = $1; } + | init_music_chord { $$ = $1; } + | init_lyrics_voice { $$ = $1; } + ; + +init_lyrics_voice: + LYRICS { lexer->push_lyric_state(); } + music_voice { $$ = $3; lexer->pop_state(); } + ; + +init_music_voice: + MUSIC { lexer->push_note_state(); } + /* cont*/ music_voice + { $$=$3; lexer->pop_state(); } + ; +init_music_chord: + MUSIC { lexer->push_note_state(); } + /* cont*/ music_chord + { $$=$3; lexer->pop_state(); } + ; /* MUSIC */ -music: - music_voice { $$ = $1; } - | music_chord { $$ = $1; } + + + +transposed_music_voice: + steno_melodic_req music_voice { + $$ = $2; + $$->transpose(*$1); + delete $1; + } ; -music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; } +music_voice: '{' music_voice_body '}' { $$ = $2; } + | TRANSPOSE '{' transposed_music_voice '}' { + $$ = $3; + } ; music_voice_body: - IDENTIFIER { + VOICE_IDENTIFIER { $$ = $1->mvoice(true); } | /* */ { $$ = new Music_voice; } - | music_voice_body '+' IDENTIFIER { - $$->concatenate($3->mvoice(true)); - } | music_voice_body full_element { $$->add_elt($2); } | music_voice_body voice_command { } - | music_voice_body music { + | music_voice_body music_chord { $$->add($2); } + | music_voice_body CONCAT music_voice { + $$->add($3);/* niet echt */ + } | music_voice_body error { } - ; + | music_voice_body '>' { + fatal_error_i = 1; + yyerror("Confused by errors: bailing out"); + }; -music_chord: '{' music_chord_body '}' { $$ = $2; } +music_chord: '<' music_chord_body '>' { $$ = $2; } ; music_chord_body: - IDENTIFIER { + CHORD_IDENTIFIER { $$=$1->mchord(true); } | /* */ { @@ -396,15 +448,16 @@ music_chord_body: | MULTIVOICE { $$ = new Multi_voice_chord; } - | music_chord_body '+' IDENTIFIER { - $$->concatenate($3->mchord(true)); - } - | music_chord_body music { + | music_chord_body music_voice { $$->add($2); } | music_chord_body full_element { $$ ->add_elt($2); } + | music_chord_body '}' { + fatal_error_i = 1; + yyerror("Confused by errors: bailing out"); + } | music_chord_body error { } ; @@ -446,11 +499,13 @@ command_req: $$ = new Bar_req(*$2); delete $2; } - | METER '{' int '*' int '}' { + | METER '{' int '/' int '}' { Meter_change_req *m = new Meter_change_req; m->set($3,$5); // sorry hw, i need meter at output of track, // but don-t know where to get it... statics should go. + // HW : default: 4/4, meterchange reqs may change it. + Midi_def::num_i_s = $3; Midi_def::den_i_s = $5; $$ = m; @@ -520,7 +575,7 @@ pure_post_request: octave_quote: '\'' { $$ = 1; } - | '`' { $$ = -1; } + | '`' { $$ = -1 ; } ; octave_quotes: @@ -531,36 +586,45 @@ octave_quotes: /* URG!! */ -steno_note_req: +steno_melodic_req: MELODIC_REQUEST_IDENTIFIER { - $$ = new Note_req; - * (Melodic_req *) $$ = *$1->request(false)->melodic(); + $$ = $1->request(false)->clone()->melodic(); $$->octave_i_ += lexer->prefs.default_octave_i_; } - | octave_quote steno_note_req { - $2-> octave_i_ += $1; - $$ = $2; //ugh!! + | steno_melodic_req '\'' { + $$-> octave_i_ ++; } - | '!' steno_note_req { + | '`' steno_melodic_req { $$ = $2; - $2->forceacc_b_ = ! $2->forceacc_b_; + $2-> octave_i_ --; + } + ; + +steno_note_req: + steno_melodic_req { + $$ = new Note_req; + * (Melodic_req *) $$ = *$1; + delete $1; + } + | steno_note_req '!' { + $$->forceacc_b_ = ! $$->forceacc_b_; } + /* have to duration here. */ ; melodic_request: - MELODIC '{' int int int int '}' {/* ugh */ + MELODIC '{' int int int '}' {/* ugh */ $$ = new Melodic_req; $$->octave_i_ = $3; $$->notename_i_ = $4; $$->accidental_i_ = $5; - $$->forceacc_b_ = $6; } ; dynamic_req: DYNAMIC '{' int '}' { Absolute_dynamic_req *ad_p = new Absolute_dynamic_req; - ad_p ->loudness_ = $3; + ad_p ->loudness_ = (Dynamic_req::Loudness)$3; $$ =ad_p; } ; @@ -620,7 +684,7 @@ script_req: ; mudela_script: - IDENTIFIER { $$ = $1->script(true); } + SCRIPT_IDENTIFIER { $$ = $1->script(true); } | script_definition { $$ = $1; } | '^' { $$ = get_scriptdef('^'); } | '+' { $$ = get_scriptdef('+'); } @@ -739,6 +803,8 @@ default_duration: voice_elt: steno_note_req notemode_duration { + if (!lexer->note_state_b()) + yyerror("have to be in Note mode for notes"); $$ = get_note_element($1, $2); } | RESTNAME notemode_duration { @@ -749,7 +815,10 @@ voice_elt: lyrics_elt: mudela_text notemode_duration { + if (!lexer->lyric_state_b()) + yyerror("Have to be in Lyric mode for lyrics"); $$ = get_word_element($1, $2); + }; /* @@ -767,7 +836,7 @@ int: real { $$ = int($1); if ( distance($1,Real(int($$)) ) > 1e-8) - error( "integer expected", lexer->here_ch_c_l() ); + yyerror( "integer expected" ); } ; @@ -874,29 +943,30 @@ void parse_file(String init, String s) { *mlog << "Parsing ... "; - lexer = new My_flex_lexer; + lexer = new My_lily_lexer; #ifndef NPRINT yydebug = !monitor->silence("InitParser") && check_debug; lexer->set_debug( !monitor->silence("InitLexer") && check_debug); #endif - + init_parse_b = true; lexer->new_input(init); yyparse(); #ifndef NPRINT if (!monitor->silence("InitDeclarations") && check_debug) - lexer->print_declarations(); + lexer->print_init_declarations(); yydebug = !monitor->silence("Parser") && check_debug; lexer->set_debug( !monitor->silence("Lexer") && check_debug); #endif - + init_parse_b = false; lexer->new_input(s); yyparse(); + #ifdef NPRINT if (!monitor->silence("Declarations") && check_debug) - lexer->print_declarations(); + lexer->print_user_declarations(); #endif delete lexer; lexer = 0;