From: fred Date: Sun, 24 Mar 2002 19:38:37 +0000 (+0000) Subject: lilypond-0.0.49 X-Git-Tag: release/1.5.59~4996 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e63870c2bf7441863152a0b7f0b471854837527e;p=lilypond.git lilypond-0.0.49 --- diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 6ff46f282c..28505097c0 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -8,11 +8,11 @@ #include #include - +#include "notename-table.hh" #include "interval.hh" #include "identifier.hh" #include "assoc-iter.hh" -#include "out/parser.hh" +#include "parser.hh" #include "keyword.hh" #include "assoc.hh" #include "my-lily-lexer.hh" @@ -21,48 +21,50 @@ #include "parseconstruct.hh" static Keyword_ent the_key_tab[]={ - "bar", BAR, - "cadenza", CADENZA, - "clef", CLEF, - "cm", CM_T, - "duration", DURATIONCOMMAND, - "absdynamic", ABSDYNAMIC, - "group", GROUP, - "geometric", GEOMETRIC, - "in", IN_T, - "inputregister", INPUT_REGS, - "lyric", LYRIC, - "key", KEY, - "melodic" , MELODIC, - "melodic_request", MELODIC_REQUEST, - "meter", METER, - "midi", MIDI, - "mm", MM_T, - "multivoice", MULTIVOICE, - "note", NOTE, - "octave", OCTAVECOMMAND, - "output", OUTPUT, - "partial", PARTIAL, - "paper", PAPER, - "plet", PLET, - "pt", PT_T, - "score", SCORE, - "script", SCRIPT, - "skip", SKIP, - "staff", STAFF, - "start", START_T, - "stem", STEM, - "table", TABLE, - "spandynamic", SPANDYNAMIC, - "symboltables", SYMBOLTABLES, - "tempo", TEMPO, - "texid", TEXID, - "textstyle", TEXTSTYLE, - "transpose", TRANSPOSE, - "unitspace", UNITSPACE, - "width", WIDTH, - "grouping", GROUPING, - 0,0 + {"bar", BAR}, + {"cadenza", CADENZA}, + {"clear", CLEAR}, + {"clef", CLEF}, + {"cm", CM_T}, + {"duration", DURATIONCOMMAND}, + {"absdynamic", ABSDYNAMIC}, + {"group", GROUP}, + {"geometric", GEOMETRIC}, + {"in", IN_T}, + {"inputregister", INPUT_REGS}, + {"lyric", LYRIC}, + {"key", KEY}, + {"melodic" , MELODIC}, + {"melodic_request", MELODIC_REQUEST}, + {"meter", METER}, + {"midi", MIDI}, + {"mm", MM_T}, + {"multivoice", MULTIVOICE}, + {"note", NOTE}, + {"notenames", NOTENAMES}, + {"octave", OCTAVECOMMAND}, + {"output", OUTPUT}, + {"partial", PARTIAL}, + {"paper", PAPER}, + {"plet", PLET}, + {"pt", PT_T}, + {"score", SCORE}, + {"script", SCRIPT}, + {"skip", SKIP}, + {"staff", STAFF}, + {"start", START_T}, + {"stem", STEM}, + {"table", TABLE}, + {"spandynamic", SPANDYNAMIC}, + {"symboltables", SYMBOLTABLES}, + {"tempo", TEMPO}, + {"texid", TEXID}, + {"textstyle", TEXTSTYLE}, + {"transpose", TRANSPOSE}, + {"unitspace", UNITSPACE}, + {"width", WIDTH}, + {"grouping", GROUPING}, + {0,0} }; My_lily_lexer::My_lily_lexer() @@ -71,7 +73,7 @@ My_lily_lexer::My_lily_lexer() identifier_assoc_p_ = new Assoc; errorlevel_i_ = 0; post_quotes_b_ = false; - + note_tab_p_ = new Notename_table; } int @@ -83,7 +85,7 @@ My_lily_lexer::lookup_keyword(String s) Identifier* My_lily_lexer::lookup_identifier(String s) { - if (!identifier_assoc_p_->elt_query(s)) + if (!identifier_assoc_p_->elt_b(s)) return 0; return (*identifier_assoc_p_)[s]; @@ -93,8 +95,8 @@ My_lily_lexer::lookup_identifier(String s) void My_lily_lexer::add_identifier(Identifier*i) { - delete lookup_identifier(i->name); - (*identifier_assoc_p_)[i->name] = i; + delete lookup_identifier(i->name_str_); + (*identifier_assoc_p_)[i->name_str_] = i; } My_lily_lexer::~My_lily_lexer() @@ -104,12 +106,9 @@ My_lily_lexer::~My_lily_lexer() for (Assoc_iter ai(*identifier_assoc_p_); ai.ok(); ai++) { mtor << "deleting: " << ai.key()<<'\n'; - Identifier *i_p = ai.val(); - if (!i_p->accessed_b_ && !i_p->init_b_) - i_p->warning("Variable not used"); - delete ai.val(); } + delete note_tab_p_; delete identifier_assoc_p_; } void @@ -129,12 +128,28 @@ My_lily_lexer::LexerError(char const *s) *mlog << "error at EOF" << s << '\n'; } else { errorlevel_i_ |= 1; - error(String(s)); - // FIXME. -/*Input spot(source_l_g = here_spot(); + + Input spot(source_file_l(),here_ch_C()); spot.error( s ); - */ } } +Melodic_req* +My_lily_lexer::lookup_melodic_req_l(String 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); +} + +void +My_lily_lexer::clear_notenames() +{ + delete note_tab_p_; + note_tab_p_ = new Notename_table; +} diff --git a/lily/parser.y b/lily/parser.y index 69ef223a4e..fd81c4f08f 100644 --- a/lily/parser.y +++ b/lily/parser.y @@ -95,6 +95,7 @@ yylex(YYSTYPE *s, void * v_l) %token BAR %token CADENZA +%token CLEAR %token CLEF %token CM_T %token DURATIONCOMMAND @@ -114,6 +115,7 @@ yylex(YYSTYPE *s, void * v_l) %token MM_T %token MULTIVOICE %token NOTE +%token NOTENAMES %token OCTAVECOMMAND %token OUTPUT %token PAPER @@ -137,8 +139,12 @@ yylex(YYSTYPE *s, void * v_l) %token UNITSPACE %token WIDTH +/* escaped */ +%token E_EXCLAMATION E_SMALLER E_BIGGER E_CHAR + %token DOTS %token INT +%token NOTENAME_ID %token REGS_IDENTIFIER %token IDENTIFIER %token MELODIC_REQUEST_IDENTIFIER @@ -179,7 +185,7 @@ yylex(YYSTYPE *s, void * v_l) %type paper_block paper_body %type dim real %type unit -%type post_request pre_request command_req +%type post_request pre_request command_req verbose_command_req abbrev_command_req %type pure_post_request pure_post_request_choice %type script_req textscript_req dynamic_req %type score_block score_body @@ -205,9 +211,23 @@ mudela: /* empty */ } | mudela add_declaration { } | mudela error + | mudela add_notenames { } ; - +add_notenames: + NOTENAMES '{' notenames_body '}' + ; +notenames_body: + /**/ { + } + | notenames_body CLEAR { + THIS->clear_notenames(); + } + | notenames_body STRING '=' melodic_request { + THIS->add_notename(*$2, $4); + delete $2; + } + ; /* DECLARATIONS */ @@ -225,7 +245,7 @@ declarable_identifier: } | old_identifier { THIS->remember_spot(); - $$ = new String($1->name); + $$ = new String($1->name_str_); THIS->here_input().warning("redeclaration of `" + *$$ + "'"); } ; @@ -424,7 +444,10 @@ staff_block: staff_init: - REGS_IDENTIFIER { + STAFF_IDENTIFIER { + $$ = $1->staff(true); + } + | REGS_IDENTIFIER { $$ = new Input_staff; $$->ireg_p_ = $1->iregs(true); } @@ -502,7 +525,7 @@ music_voice_body: | music_voice_body full_element { $$->add_elt($2); } - | music_voice_body voice_command { + | music_voice_body voice_command ';' { } | music_voice_body music_chord { $$->add($2); @@ -565,7 +588,7 @@ command_elt: $$-> set_spot( THIS->here_input()); } /* cont: */ - command_req { + command_req { $2-> set_spot( THIS->here_input()); $$->add($2); @@ -573,52 +596,60 @@ command_elt: ; command_req: + abbrev_command_req + | verbose_command_req ';' { $$ = $1; } + ; + +abbrev_command_req: '|' { $$ = new Barcheck_req; } - | BAR STRING { + ; + +verbose_command_req: + BAR STRING { $$ = new Bar_req(*$2); delete $2; } - | METER '{' int '/' int '}' { + | METER int '/' int { Meter_change_req *m = new Meter_change_req; - m->set($3,$5); + m->set($2,$4); // 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; + Midi_def::num_i_s = $2; + Midi_def::den_i_s = $4; $$ = m; } - | SKIP '{' duration_length '}' { + | SKIP duration_length { Skip_req * skip_p = new Skip_req; - skip_p->duration_ = *$3; - delete $3; + skip_p->duration_ = *$2; + delete $2; $$ = skip_p; } - | CADENZA '{' int '}' { - $$ = new Cadenza_req($3); + | CADENZA int { + $$ = new Cadenza_req($2); } - | PARTIAL '{' duration_length '}' { - $$ = new Partial_measure_req(*$3); - delete $3; + | PARTIAL duration_length { + $$ = new Partial_measure_req(*$2); + delete $2; } - | STEM '{' int '}' { - $$ = get_stemdir_req($3); + | STEM int { + $$ = get_stemdir_req($2); } | CLEF STRING { $$ = new Clef_change_req(*$2); delete $2; } - | KEY '{' pitch_list '}' { + | KEY pitch_list { Key_change_req *key_p= new Key_change_req; - key_p->melodic_p_arr_ = *$3; + key_p->melodic_p_arr_ = *$2; $$ = key_p; - delete $3; + delete $2; } - | GROUPING '{' intastint_list '}' { - $$ = get_grouping_req(*$3); delete $3; + | GROUPING intastint_list { + $$ = get_grouping_req(*$2); delete $2; } | GROUP STRING { $$ = new Group_change_req; @@ -669,8 +700,8 @@ pure_post_request_choice: URG!! */ steno_melodic_req: - MELODIC_REQUEST_IDENTIFIER { - $$ = $1->request(false)->clone()->melodic(); + NOTENAME_ID { + $$ = $1->clone()->melodic(); $$->octave_i_ += THIS->default_octave_i_; } | steno_melodic_req POST_QUOTES { @@ -730,10 +761,19 @@ close_request_parens: | ']' { $$ = ']'; } + | E_SMALLER { + $$ = '<'; + } + | E_BIGGER { + $$ = '>'; + } ; open_request_parens: - ')' { + E_EXCLAMATION { + $$ = '!'; + } + | ')' { $$=')'; } | '[' { @@ -741,6 +781,8 @@ open_request_parens: } ; + + script_definition: SCRIPT '{' script_body '}' { $$ = $3; } ; @@ -813,21 +855,30 @@ pre_request: ; voice_command: - PLET '{' INT '/' INT '}' { - THIS->default_duration_.set_plet($3,$5); + PLET INT '/' INT { + THIS->default_duration_.set_plet($2,$4); } - | DURATIONCOMMAND '{' STRING '}' { - THIS->set_duration_mode(*$3); - delete $3; + | DURATIONCOMMAND STRING { + THIS->set_duration_mode(*$2); + delete $2; } - | DURATIONCOMMAND '{' notemode_duration '}' { - THIS->default_duration_ = *$3; - delete $3; + | DURATIONCOMMAND notemode_duration { + THIS->default_duration_ = *$2; + delete $2; } - | OCTAVECOMMAND { THIS->default_octave_i_ = 2; } + | OCTAVECOMMAND { + /* + This is weird, but default_octave_i_ + is used in steno_note_req too + + c' -> default_octave_i_ == 1 + */ + /* why can't we have \oct{0} iso \oct{c'}*/ + THIS->default_octave_i_ = 1; } /* cont */ - '{' steno_melodic_req '}' { - THIS->default_octave_i_ = $4->octave_i_; + steno_melodic_req { + THIS->default_octave_i_ = $3->octave_i_; + delete $3; } | TEXTSTYLE STRING { THIS->textstyle_str_ = *$2; @@ -861,7 +912,10 @@ notemode_duration: explicit_duration: int { $$ = new Duration; - $$->type_i_ = $1; + if ( !Duration::duration_type_b($1) ) + THIS->parser_error("Not a duration"); + else + $$->type_i_ = $1; } | explicit_duration DOTS { $$->dots_i_ = $2; @@ -901,8 +955,8 @@ lyrics_elt: pitch_list: { $$ = new Array; } - | pitch_list MELODIC_REQUEST_IDENTIFIER { - $$->push($2->request(false)->clone()->melodic()); + | pitch_list NOTENAME_ID { + $$->push($2->clone()->melodic()); } ;