]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.y
release: 0.1.11
[lilypond.git] / lily / parser.y
index cf4b75c8c2d63ce35637eb5cdaf9a2293bf8b372..a8612c44d41416ae975a989b6ba5fb6b088b565b 100644 (file)
@@ -1,7 +1,18 @@
 %{ // -*-Fundamental-*-
+
+/*
+  parser.y -- YACC parser for mudela
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+           Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
 #include <iostream.h>
 
-#define MUDELA_VERSION "0.0.60"
+// mmm
+#define MUDELA_VERSION "0.1.1"
 
 #include "script-def.hh"
 #include "symtable.hh"
 #include "musical-request.hh"
 #include "my-lily-parser.hh"
 #include "text-def.hh"
-#include "input-register.hh"
+#include "input-translator.hh"
 #include "score.hh"
 #include "music-list.hh"
+#include "header.hh"
+#include "duration-convert.hh"
 
 #ifndef NDEBUG
 #define YYDEBUG 1
     Box *box;
     Chord * chord;
     Duration *duration;
-    Identifier *id;    
-    Input_register * iregs;
+    Identifier *id;
+    Input_translator* itrans;
     Music *music;
     Music_list *musiclist;
     Score *score;
+    Header *header;
     Interval *interval;
     Lookup*lookup;
     Melodic_req * melreq;
+    Music_output_def * outputdef;
     Midi_def* midi;
     Moment *moment;
     Note_req *notereq;
@@ -66,6 +81,7 @@
     Symtable * symtable;
     Symtables * symtables;
     Text_def * textdef;
+    Tempo_req *tempo;
     char c;
     const char *consstr;
     int i;
 }
 %{
 
-int 
+int
 yylex(YYSTYPE *s,  void * v_l)
 {
        My_lily_parser   *pars_l = (My_lily_parser*) v_l;
        My_lily_lexer * lex_l = pars_l->lexer_p_;
-       
+
        lex_l->lexval_l = (void*) s;
        return lex_l->yylex();
 }
@@ -89,7 +105,6 @@ yylex(YYSTYPE *s,  void * v_l)
 %pure_parser
 
 /* tokens which are not keywords */
-%token CONCAT
 
 %token ALIAS
 %token BAR
@@ -100,28 +115,26 @@ yylex(YYSTYPE *s,  void * v_l)
 %token CONSISTS
 %token ACCEPTS
 %token CM_T
-%token DURATIONCOMMAND
+%token DURATION
 %token ABSDYNAMIC
 %token END
-%token GEOMETRIC
 %token GROUPING
 %token GROUP
-%token REQUESTREGISTER
+%token REQUESTTRANSLATOR
 %token HSHIFT
+%token HEADER
 %token IN_T
 %token ID
-%token INIT_END
 %token LYRIC
 %token KEY
 %token MELODIC
+%token MIDI
 %token MELODIC_REQUEST
 %token METER
-%token MIDI
 %token MM_T
 %token MULTI
-%token NOTE
 %token NOTENAMES
-%token OCTAVECOMMAND
+%token OCTAVE
 %token OUTPUT
 %token PAPER
 %token PARTIAL
@@ -141,8 +154,6 @@ yylex(YYSTYPE *s,  void * v_l)
 %token TEXID
 %token TEXTSTYLE
 %token TITLE
-%token UNITSPACE
-%token WIDTH
 %token VERSION
 
 /* escaped */
@@ -151,77 +162,88 @@ yylex(YYSTYPE *s,  void * v_l)
 %type <i>      dots
 %token <i>     INT
 %token <melreq>        NOTENAME_ID
+%token <id>    DURATION_IDENTIFIER
 %token <id>    IDENTIFIER
-%token <id>    MELODIC_REQUEST_IDENTIFIER 
+%token <id>    MELODIC_REQUEST_IDENTIFIER
 %token <id>    MUSIC_IDENTIFIER
 %token <id>    VOICE_IDENTIFIER
 %token <id>    POST_REQUEST_IDENTIFIER
 %token <id>    SCRIPT_IDENTIFIER
-%token <id>    STAFF_IDENTIFIER
+%token <id>    COMMAND_IDENTIFIER
 %token <id>    REAL_IDENTIFIER
+%token <id>    INPUT_TRANS_IDENTIFIER
 %token <id>    INT_IDENTIFIER
 %token <id>    SCORE_IDENTIFIER
+%token <id>    MIDI_IDENTIFIER
+%token <id>    PAPER_IDENTIFIER
 %token <id>    REQUEST_IDENTIFIER
-%token <real>  REAL 
+%token <real>  REAL
 %token <string>        DURATION RESTNAME
 %token <string>        STRING
-%token <i>     POST_QUOTES 
+%token <string> FIELDNAME RECORDLINE
+%token <i>     POST_QUOTES
 %token <i>     PRE_QUOTES
 
-
+%type <outputdef> output_def
+%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 <music>  simple_element music_elt full_element lyrics_elt command_elt
 %type <i>      int
 %type <i>      script_dir
-%type <id>     declaration
-%type <duration>       explicit_duration notemode_duration
+%type <id>     identifier_init
+%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 <melreq> melodic_request steno_melodic_req
 %type <notereq>        steno_note_req
-%type <melreqvec>      pitch_list 
+%type <melreqvec>      pitch_list
 %type <midi>   midi_block midi_body
 %type <moment> duration_length
 
 %type <music>  Music transposed_music
-%type <musiclist> Voice Voice_body 
+%type <musiclist> Voice Voice_body
 %type <chord>  Chord Chord_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>        script_req  dynamic_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 <textdef> text_def
-%type <string> declarable_identifier
 %type <string> script_abbreviation
-%type <id>     old_identifier
 %type <symbol> symboldef
 %type <symtable>       symtable symtable_body
-%type <iregs>  input_register_spec input_register_spec_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 {
+               delete THIS->default_header_p_ ;
+               THIS->default_header_p_ = $2;
+       }
        | mudela score_block {
-               add_score($2);          
+               add_score($2);
        }
        | mudela add_declaration { }
        | mudela error
-       | mudela check_version { } 
+       | mudela check_version { }
        | mudela add_notenames { }
-       | mudela input_register_spec { add_global_input_register($2); }
        ;
 
 check_version:
        VERSION STRING ';'              {
-               if (*$2 != MUDELA_VERSION) {
+               if ( String( *$2 ) != MUDELA_VERSION) {
                        if (THIS->ignore_version_b_) {
                                THIS->here_input().error("Incorrect mudela version");
                        } else {
@@ -246,133 +268,190 @@ notenames_body:
                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
 */
-add_declaration: declaration   {
-               THIS->lexer_p_->add_identifier($1);
-               $1->init_b_ = THIS->init_parse_b_;
-               $1->set_spot(THIS->pop_spot());
-       }
-       ;
 
-declarable_identifier:
+add_declaration:
        STRING {
                THIS->remember_spot();
-           $$ = $1;
        }
-       | old_identifier { 
-               THIS->remember_spot();
-               $$ = new String($1->name_str_); 
-               THIS->here_input().warning("redeclaration of `" + *$$ + "'");
+       /* cont */ '=' identifier_init {
+           THIS->lexer_p_->set_identifier(*$1, $4);
+           $4->init_b_ = THIS->init_parse_b_;
+           $4->set_spot(THIS->pop_spot());
        }
        ;
+identifier_init:
+       score_block {
+               $$ = new Score_id($1, SCORE_IDENTIFIER);
 
+       }
+       | paper_block {
+               $$ = new Paper_def_id($1, PAPER_IDENTIFIER);
 
-old_identifier:
-       IDENTIFIER
-       |       MELODIC_REQUEST_IDENTIFIER 
-       |       POST_REQUEST_IDENTIFIER
-       |       SCRIPT_IDENTIFIER
-       |       REAL_IDENTIFIER
-       |       SCORE_IDENTIFIER
-       |       REQUEST_IDENTIFIER
-       ;
+       }
+       | midi_block {
+               $$ = new Midi_def_id($1, MIDI_IDENTIFIER);
 
-declaration:
-       declarable_identifier '=' score_block {
-               $$ = new Score_id(*$1, $3, SCORE_IDENTIFIER);
-               delete $1;
        }
-       | declarable_identifier '=' script_definition {
-               $$ = new Script_id(*$1, $3, SCRIPT_IDENTIFIER);
-               delete $1;
+       | script_definition {
+               $$ = new Script_id($1, SCRIPT_IDENTIFIER);
+
        }
-       | declarable_identifier '=' Music  {
-               $$ = new Music_id(*$1, $3, MUSIC_IDENTIFIER);
-               delete $1;
+       | Music  {
+               $$ = new Music_id($1, MUSIC_IDENTIFIER);
+
        }
-       | declarable_identifier '=' symtables {
-               $$ = new Lookup_id(*$1, $3, IDENTIFIER);
-               delete $1;
+       | symtables {
+               $$ = new Lookup_id($1, IDENTIFIER);
+
        }
-       | declarable_identifier '=' real        {
-               $$ = new Real_id(*$1, new Real($3), REAL_IDENTIFIER);
-               delete $1;
+       | real  {
+               $$ = new Real_id(new Real($1), REAL_IDENTIFIER);
+
        }
-       
-       | declarable_identifier '=' post_request {
-               $$ = new Request_id(*$1, $3, POST_REQUEST_IDENTIFIER);
-               delete $1;
+       | int   {
+               $$ = new Int_id(new int($1), INT_IDENTIFIER);
+
        }
-       | declarable_identifier '=' melodic_request {
-               $$ = new Request_id(*$1, $3, MELODIC_REQUEST_IDENTIFIER);
-               delete $1;
+       | post_request {
+               $$ = new Request_id($1, POST_REQUEST_IDENTIFIER);
+
+       }
+       | melodic_request {
+               $$ = new Request_id($1, MELODIC_REQUEST_IDENTIFIER);
+
+       }
+       | input_translator_spec {
+               $$ = new Input_translator_id ( $1, INPUT_TRANS_IDENTIFIER);
+       }
+       | explicit_duration {
+               $$ = new Duration_id( $1, DURATION_IDENTIFIER);
        }
        ;
 
 
 
-input_register_spec:
-       REQUESTREGISTER '{' input_register_spec_body '}'
+input_translator_spec:
+       REQUESTTRANSLATOR '{' input_translator_spec_body '}'
                { $$ = $3; }
        ;
 
-input_register_spec_body:
-       STRING  { 
-               $$ = new Input_register; 
-               $$->name_str_ =*$1;
+input_translator_spec_body:
+       INPUT_TRANS_IDENTIFIER  {
+               $$ = $1->input_translator();
+               $$-> set_spot( THIS->here_input() );
+       }
+       | STRING STRING {
+               $$ = new Input_translator;
+               $$->base_str_ = *$1;
+               $$->type_str_ =*$2;
+               $$->set_spot ( THIS->here_input() );
                delete $1;
+               delete $2;
+       }
+       | input_translator_spec_body ID STRING ';' {
+               $$-> default_id_str_ = *$3;
+               delete $3;
        }
-       | input_register_spec_body ALIAS STRING ';' {
+       | input_translator_spec_body ALIAS STRING ';' {
                $$-> alias_str_arr_.push(*$3);
                delete $3;
        }
-       | input_register_spec_body CONSISTS STRING ';'  {
+       | input_translator_spec_body CONSISTS STRING ';'        {
                $$-> consists_str_arr_.push(*$3);
                delete $3;
        }
-       | input_register_spec_body CONTAINS input_register_spec {
+       | input_translator_spec_body CONTAINS input_translator_spec {
                $$->add($3);
        }
        ;
+
 /*
        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());
-               if (!$$->paper_p_ && ! $$->midi_p_)
-                       $$->paper_p_ = THIS->default_paper();
+               if (!$$->def_p_arr_.size ())
+                       $$->add ( THIS->default_paper());
 
                /* handle error levels. */
                $$->errorlevel_i_ = THIS->error_level_i_;
                THIS->error_level_i_ = 0;
+               if (!$$->header_p_ && THIS->default_header_p_)
+                       $$->header_p_ = new Header(*THIS->default_header_p_);
        }
        ;
 
-score_body:            { 
-               $$ = new Score; 
+score_body:            {
+               $$ = new Score;
        }
        | SCORE_IDENTIFIER {
-               $$ = $1->score(true);
+               $$ = $1->score();
+       }
+       | score_body mudela_header      {
+               $$->header_p_ = $2;
        }
        | score_body Music      {
                $$->music_p_ = $2;
        }
-       | score_body paper_block                {
-               $$->paper_p_ = $2;      
-       }
-       | score_body midi_block         { 
-               $$->midi_p_ = $2;
+       | score_body output_def {
+               $$->add( $2);
        }
        | score_body error {
 
        }
        ;
 
+output_def:
+       paper_block {
+               $$ = $1;
+       }
+       |  midi_block           {
+               $$= $1;
+       }
+       ;
+
 intastint_list:
        /* */   { $$ =new Array<int>; }
        | intastint_list int '*' int    {
@@ -391,16 +470,25 @@ paper_block:
 
 paper_body:
        /* empty */                     {
-               $$ = THIS->default_paper();
-
+               $$ = THIS->default_paper(); // paper / video / engrave
+       }
+       | PAPER_IDENTIFIER      {
+               $$ = $1->paperdef();
        }
-       | paper_body WIDTH dim ';'              { $$->linewidth = $3;}
-       | paper_body OUTPUT STRING ';'  { $$->outfile = *$3;
+       | paper_body OUTPUT STRING ';'  { 
+               $$->outfile_str_ = *$3;
                delete $3;
        }
        | paper_body symtables          { $$->set($2); }
-       | paper_body UNITSPACE dim ';'  { $$->whole_width = $3; }
-       | paper_body GEOMETRIC REAL ';' { $$->geometric_ = $3; }
+       | paper_body STRING '=' dim ';'         {
+               $$->set_var(*$2, $4);
+       }
+       | paper_body STRING '=' real ';' {
+               $$->set_var(*$2, $4);
+       }
+       | paper_body input_translator_spec      {
+               $$->set( $2 );
+       }
        | paper_body error {
 
        }
@@ -415,23 +503,33 @@ midi_block:
        '{' midi_body '}'       { $$ = $3; }
        ;
 
-midi_body: 
-               $$ = new Midi_def; 
+midi_body: /* empty */                 {
+               $$ = THIS->default_midi();
        }
-       | midi_body OUTPUT STRING ';'   { 
-               $$->outfile_str_ = *$3; 
-               delete $3; 
+       | midi_body OUTPUT STRING ';'   {
+               $$->outfile_str_ = *$3;
+               delete $3;
        }
-       | midi_body TEMPO notemode_duration ':' int ';' {
-               $$->set_tempo( $3->length(), $5 );
+       | midi_body tempo_request ';' {
+               $$->set_tempo( $2->dur_.length(), $2->metronome_i_ );
+               delete $2;
+       }
+       | midi_body input_translator_spec       {
+               $$->set( $2 );
        }
        | midi_body error {
 
        }
        ;
 
-
-
+tempo_request:
+       TEMPO entered_notemode_duration '=' int         {
+               $$ = new Tempo_req;
+               $$->dur_ = *$2;
+               delete $2;
+               $$-> metronome_i_ = $4;
+       }
+       ;
 
 /*
        MUSIC
@@ -449,7 +547,7 @@ Voice_body:
        }
        | Voice_body ID STRING STRING ';'       {
                $$ = new Voice;
-               $$->type_str_ = *$3;    
+               $$->type_str_ = *$3;
                $$->id_str_ = *$4;
                delete $3;
                delete $4;
@@ -464,17 +562,17 @@ Music:
        | Voice         { $$ = $1; }
        | Chord                 { $$ = $1; }
        | transposed_music      { $$ = $1; }
-       | MUSIC_IDENTIFIER      { $$ = $1->music(true); }
-       | MELODIC 
-               { THIS->lexer_p_->push_note_state(); } 
+       | MUSIC_IDENTIFIER      { $$ = $1->music(); }
+       | MELODIC
+               { THIS->lexer_p_->push_note_state(); }
        Music
                { $$=$3; THIS->lexer_p_->pop_state(); }
 
-       | LYRIC 
-               { THIS->lexer_p_->push_lyric_state(); } 
+       | LYRIC
+               { THIS->lexer_p_->push_lyric_state(); }
        Music
                { $$ = $3; THIS->lexer_p_->pop_state(); }
-       ; 
+       ;
 
 Chord:
        '<' Chord_body '>'      { $$  = $2; }
@@ -489,9 +587,9 @@ Chord_body:
                $$->multi_level_i_=$3;
        }
        | Chord_body ID STRING STRING ';'       {
-               $$->type_str_ = *$3;    
+               $$->type_str_ = *$3;
                $$->id_str_ = *$4;
-               delete $4; 
+               delete $4;
                delete $3;
        }
        | Chord_body Music {
@@ -516,44 +614,37 @@ full_element:
                THIS->add_requests((Chord*)$2);//ugh
                $$ = $2;
        }
+       | command_elt
        | voice_command ';'     { $$ = 0; }
-       ;       
+       ;
 
 simple_element:
-       music_elt 
+       music_elt
        | lyrics_elt
-       | command_elt
        ;
 
 command_elt:
-/* empty */    {
-               $$ = new Voice_element;
-               $$-> set_spot( THIS->here_input());
-       }
-/* cont: */
        command_req {
-               $2-> set_spot( THIS->here_input());
-               ((Chord*)$$) ->add($2);//ugh
+               $$ = new Request_chord;
+               $$-> set_spot( THIS->here_input());
+               $1-> set_spot( THIS->here_input());
+               ((Chord*)$$) ->add($1);//ugh
 
        }
-       | GROUP STRING ';' { // ugh ugh ugh
-               Change_reg *chr_p = new Change_reg;
-               $$ = chr_p;
-               chr_p-> type_str_ = "Voice_group_registers"; //ugh
-               chr_p-> id_str_ = *$2;
-               delete $2;
-       }
        ;
 
 command_req:
-       abbrev_command_req      
+       abbrev_command_req
        | verbose_command_req ';'       { $$ = $1; }
        ;
 
 abbrev_command_req:
-        '|'                            { 
+        '|'                            {
                $$ = new Barcheck_req;
        }
+       | COMMAND_IDENTIFIER    {
+               $$ = $1->request();
+       }
        ;
 
 verbose_command_req:
@@ -567,20 +658,22 @@ verbose_command_req:
                // 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 = $2;
                Midi_def::den_i_s = $4;
                $$ = m;
        }
        | SKIP duration_length {
                Skip_req * skip_p = new Skip_req;
-               skip_p->duration_ = Duration(1,0);
-               skip_p->duration_.set_plet($2->numerator().as_long(), 
+               skip_p->duration_.set_plet($2->numerator().as_long(),
                        $2->denominator().as_long());
-               
+
                delete $2;
                $$ = skip_p;
        }
+       | tempo_request {
+               $$ = $1;
+       }
        | CADENZA int   {
                $$ = new Cadenza_req($2);
        }
@@ -598,7 +691,7 @@ verbose_command_req:
                $$ = 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_ = *$2;
                $$ = key_p;
@@ -607,7 +700,6 @@ verbose_command_req:
        | GROUPING intastint_list {
                $$ = get_grouping_req(*$2); delete $2;
        }
-       
        ;
 
 post_requests:
@@ -623,10 +715,10 @@ post_requests:
 
 post_request:
        POST_REQUEST_IDENTIFIER {
-               $$ = (Request*)$1->request(true);
+               $$ = (Request*)$1->request();
        }
-       |close_request_parens   { 
-               $$ = THIS->get_parens_request($1); 
+       |close_request_parens   {
+               $$ = THIS->get_parens_request($1);
        }
        | script_req
        | dynamic_req
@@ -642,10 +734,10 @@ steno_melodic_req:
                $$ = $1->clone()->musical()->melodic();
                $$->octave_i_ += THIS->default_octave_i_;
        }
-       | steno_melodic_req POST_QUOTES         {  
+       | steno_melodic_req POST_QUOTES         {
                $$-> octave_i_ += $2;
        }
-       | PRE_QUOTES steno_melodic_req   {  
+       | PRE_QUOTES steno_melodic_req   {
                $$ = $2;
                $2-> octave_i_ -= $1;
        }
@@ -659,7 +751,7 @@ steno_note_req:
        }
        | steno_note_req   '!'          {
                $$->forceacc_b_ = ! $$->forceacc_b_;
-       } 
+       }
        /* have to duration here. */
        ;
 
@@ -672,6 +764,14 @@ melodic_request:
        }
        ;
 
+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;
@@ -681,7 +781,7 @@ dynamic_req:
        | SPANDYNAMIC '{' int int '}' {
                Span_dynamic_req * sp_p = new Span_dynamic_req;
                sp_p->spantype = $4;
-               sp_p-> dynamic_dir_i_  = $3;
+               sp_p-> dynamic_dir_  = $3;
                $$ = sp_p;
        }
        ;
@@ -689,7 +789,8 @@ dynamic_req:
 close_plet_parens:
        ']' INT '/' INT {
                $$ = ']';
-               THIS->default_duration_.set_plet($2,$4);
+               THIS->plet_.type_i_ = $4;
+               THIS->plet_.iso_i_ = $2;
        }
        ;
 
@@ -697,10 +798,10 @@ close_request_parens:
        '~'     {
                $$ = '~';
        }
-       | '('   { 
+       | '('   {
                $$='(';
        }
-       | ']'   { 
+       | ']'   {
                $$ = ']';
        }
        | close_plet_parens {
@@ -717,7 +818,8 @@ close_request_parens:
 open_plet_parens:
        '[' INT '/' INT {
                $$ = '[';
-               THIS->default_duration_.set_plet($2,$4);
+               THIS->plet_.type_i_ = $4;
+               THIS->plet_.iso_i_ = $2;
        }
        ;
 
@@ -725,7 +827,7 @@ open_request_parens:
        E_EXCLAMATION   {
                $$ = '!';
        }
-       | ')'   { 
+       | ')'   {
                $$=')';
        }
        | '['   {
@@ -747,31 +849,31 @@ script_body:
                s->set_from_input(*$1,$2, $3,$4,$5, $6);
                $$  = s;
                delete $1;
-       }       
+       }
        ;
 
 script_req:
-       script_dir gen_script_def               { 
+       script_dir gen_script_def               {
                Musical_script_req *m = new Musical_script_req;
-               $$ = m; 
+               $$ = m;
                m-> scriptdef_p_ = $2;
                m-> set_spot ( THIS->here_input() );
-               m-> dir_i_  = $1;
+               m-> dir_  = $1;
        }
        ;
 
 gen_script_def:
        text_def        { $$ = $1; }
-       | mudela_script { $$ = $1; 
+       | mudela_script { $$ = $1;
                $$-> set_spot( THIS->here_input() );
        }
        ;
 
 text_def:
-       STRING { 
+       STRING {
                Text_def *t  = new Text_def;
                $$ = t;
-               t->text_str_ = *$1; 
+               t->text_str_ = *$1;
                delete $1;
                t->style_str_ = THIS->textstyle_str_;
                $$->set_spot( THIS->here_input() );
@@ -789,12 +891,12 @@ script_abbreviation:
                $$ = get_scriptdef('.');
        }
        ;
-       
+
 mudela_script:
-       SCRIPT_IDENTIFIER               { $$ = $1->script(true); }
+       SCRIPT_IDENTIFIER               { $$ = $1->script(); }
        | script_definition             { $$ = $1; }
-       | script_abbreviation           { 
-               $$ = THIS->lexer_p_->lookup_identifier(*$1)->script(true);
+       | script_abbreviation           {
+               $$ = THIS->lexer_p_->lookup_identifier(*$1)->script();
                delete $1;
        }
        ;
@@ -812,9 +914,9 @@ pre_requests:
        }
        ;
 
-pre_request: 
-       open_request_parens     { 
-               $$ = THIS->get_parens_request($1); 
+pre_request:
+       open_request_parens     {
+               $$ = THIS->get_parens_request($1);
        }
        ;
 
@@ -822,15 +924,15 @@ voice_command:
        PLET     INT '/' INT {
                THIS->default_duration_.set_plet($2,$4);
        }
-       | DURATIONCOMMAND STRING {
+       | DURATION STRING {
                THIS->set_duration_mode(*$2);
                delete $2;
        }
-       | DURATIONCOMMAND 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
@@ -850,11 +952,11 @@ voice_command:
        }
        ;
 
-duration_length:       
+duration_length:
        {
                $$ = new Moment(0,1);
        }
-       | duration_length explicit_duration             {       
+       | duration_length explicit_steno_duration               {
                *$$ += $2->length();
        }
        ;
@@ -864,38 +966,48 @@ dots:
        | dots '.'      { $$ ++; }
        ;
 
-notemode_duration:
-       /* */           { 
+entered_notemode_duration:
+       /* */           {
                $$ = new Duration(THIS->default_duration_);
        }
        | dots          {
                $$ = new Duration(THIS->default_duration_);
                $$->dots_i_  = $1;
        }
-       | explicit_duration     {
+       | explicit_steno_duration       {
                THIS->set_last_duration($1);
                $$ = $1;
        }
        ;
 
-explicit_duration:
+notemode_duration:
+       entered_notemode_duration {
+               $$ = $1;
+               $$->plet_.type_i_ *= THIS->plet_.type_i_;
+               $$->plet_.iso_i_ *= THIS->plet_.iso_i_;
+       }
+       ;
+
+explicit_steno_duration:
        int             {
                $$ = new Duration;
                if ( !Duration::duration_type_b($1) )
                        THIS->parser_error("Not a duration");
                else {
-                       $$->type_i_ = $1;
-                       $$->set_plet(THIS->default_duration_);
+                       $$->durlog_i_ = Duration_convert::i2_type($1);
                     }
        }
-       | explicit_duration '.'         {
+       | DURATION_IDENTIFIER   {
+               $$ = $1->duration();
+       }
+       | explicit_steno_duration '.'   {
                $$->dots_i_ ++;
        }
-       | explicit_duration '*' int  {
-               $$->plet_.iso_i_ *= $3; 
+       | explicit_steno_duration '*' int  {
+               $$->plet_.iso_i_ *= $3;
        }
-       | explicit_duration '/' int {
-               $$->plet_.type_i_ *= $3; 
+       | explicit_steno_duration '/' int {
+               $$->plet_.type_i_ *= $3;
        }
        ;
 
@@ -915,6 +1027,7 @@ music_elt:
 
 lyrics_elt:
        text_def notemode_duration                      {
+       /* this sux! text-def should be feature of lyric-engraver. */
                if (!THIS->lexer_p_->lyric_state_b())
                        THIS->parser_error("Have to be in Lyric mode for lyrics");
                $$ = THIS->get_word_element($1, $2);
@@ -937,7 +1050,9 @@ int:
                $$ = $1;
        }
        | INT_IDENTIFIER        {
-               $$ = * $1->intid(0);
+               int *i_p = $1->intid();
+               $$ = *i_p;
+               delete i_p;
        }
        ;
 
@@ -947,10 +1062,12 @@ real:
                $$ = $1;
        }
        | REAL_IDENTIFIER               {
-               $$ = * $1->real(0);             
+               Real *r_p = $1->real();
+               $$ = * r_p;
+               delete r_p;
        }
        ;
-       
+
 
 
 dim:
@@ -963,7 +1080,7 @@ unit:      CM_T            { $$ = 1 CM; }
        |MM_T           { $$ = 1 MM; }
        |PT_T           { $$ = 1 PT; }
        ;
-       
+
 /*
        symbol tables
 */
@@ -976,7 +1093,7 @@ symtables_body:
                $$ = new Lookup;
        }
        | IDENTIFIER            {
-               $$ = new Lookup(*$1->lookup(true));
+               $$ = $1->lookup();
        }
        | symtables_body TEXID STRING           {
                $$->texsetting = *$3;
@@ -1023,13 +1140,13 @@ box:
        ;
 
 dinterval: dim dim             {
-               $$ = new Interval($1, $2);      
+               $$ = new Interval($1, $2);
        }
        ;
 
 %%
 
-void 
+void
 My_lily_parser::set_yydebug(bool b )
 {
 #ifdef YYDEBUG
@@ -1045,7 +1162,14 @@ My_lily_parser::do_yyparse()
 Paper_def*
 My_lily_parser::default_paper()
 {
-    return new Paper_def(
-       lexer_p_->lookup_identifier("default_table")->lookup(true));
+       Identifier *id = lexer_p_->lookup_identifier( "default_paper" );
+       return id ? id->paperdef() : new Paper_def ;
+}
+
+Midi_def*
+My_lily_parser::default_midi()
+{
+       Identifier *id = lexer_p_->lookup_identifier( "default_midi" );
+       return id ? id->mididef() : new Midi_def ;
 }