#include <strstream.h>
#include <ctype.h>
-
+#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"
#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()
identifier_assoc_p_ = new Assoc<String, Identifier*>;
errorlevel_i_ = 0;
post_quotes_b_ = false;
-
+ note_tab_p_ = new Notename_table;
}
int
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];
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()
for (Assoc_iter<String,Identifier*>
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
*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;
+}
%token BAR
%token CADENZA
+%token CLEAR
%token CLEF
%token CM_T
%token DURATIONCOMMAND
%token MM_T
%token MULTIVOICE
%token NOTE
+%token NOTENAMES
%token OCTAVECOMMAND
%token OUTPUT
%token PAPER
%token UNITSPACE
%token WIDTH
+/* escaped */
+%token E_EXCLAMATION E_SMALLER E_BIGGER E_CHAR
+
%token <i> DOTS
%token <i> INT
+%token <melreq> NOTENAME_ID
%token <id> REGS_IDENTIFIER
%token <id> IDENTIFIER
%token <id> MELODIC_REQUEST_IDENTIFIER
%type <paper> paper_block paper_body
%type <real> dim real
%type <real> unit
-%type <request> post_request pre_request command_req
+%type <request> post_request pre_request command_req verbose_command_req abbrev_command_req
%type <request> pure_post_request pure_post_request_choice
%type <request> script_req textscript_req dynamic_req
%type <score> score_block score_body
}
| 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
*/
}
| old_identifier {
THIS->remember_spot();
- $$ = new String($1->name);
+ $$ = new String($1->name_str_);
THIS->here_input().warning("redeclaration of `" + *$$ + "'");
}
;
staff_init:
- REGS_IDENTIFIER {
+ STAFF_IDENTIFIER {
+ $$ = $1->staff(true);
+ }
+ | REGS_IDENTIFIER {
$$ = new Input_staff;
$$->ireg_p_ = $1->iregs(true);
}
| 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);
$$-> set_spot( THIS->here_input());
}
/* cont: */
- command_req {
+ command_req {
$2-> set_spot( THIS->here_input());
$$->add($2);
;
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;
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 {
| ']' {
$$ = ']';
}
+ | E_SMALLER {
+ $$ = '<';
+ }
+ | E_BIGGER {
+ $$ = '>';
+ }
;
open_request_parens:
- ')' {
+ E_EXCLAMATION {
+ $$ = '!';
+ }
+ | ')' {
$$=')';
}
| '[' {
}
;
+
+
script_definition:
SCRIPT '{' script_body '}' { $$ = $3; }
;
;
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;
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;
pitch_list: {
$$ = new Array<Melodic_req*>;
}
- | pitch_list MELODIC_REQUEST_IDENTIFIER {
- $$->push($2->request(false)->clone()->melodic());
+ | pitch_list NOTENAME_ID {
+ $$->push($2->clone()->melodic());
}
;