]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.y
patch::: 0.0.74pre.jcn1: pats
[lilypond.git] / lily / parser.y
index 0eb8d019688baaf3bc42805162b69fdab502d35b..2607a2ed089d0257fd3308ed8785aada8832c8b1 100644 (file)
@@ -1,7 +1,18 @@
 %{ // -*-Fundamental-*-
+
+/*
+  parser.y -- lily parser
+
+  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.57"
+// mmm
+#define MUDELA_VERSION "0.0.61"
 
 #include "script-def.hh"
 #include "symtable.hh"
@@ -11,9 +22,6 @@
 #include "paper-def.hh"
 #include "midi-def.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"
 #include "identifier.hh"
 #include "command-request.hh"
 #include "musical-request.hh"
-#include "voice-element.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"
 
 #ifndef NDEBUG
 #define YYDEBUG 1
     Array<String> * strvec;
     Array<int> *intvec;
     Box *box;
+    Chord * chord;
     Duration *duration;
     Identifier *id;    
-    Input_register * iregs;
-    Input_music *music;
-    Input_score *score;
-    Input_staff *staff;    
+    Input_translator* itrans;
+    Music *music;
+    Music_list *musiclist;
+    Score *score;
     Interval *interval;
     Lookup*lookup;
     Melodic_req * melreq;
     Midi_def* midi;
     Moment *moment;
-    Music_general_chord *chord;
-    Music_voice *mvoice;
     Note_req *notereq;
     Paper_def *paper;
     Real real;
     Request * request;
-    Script_def * script;
+    General_script_def * script;
     String *string;
     Symbol * symbol;
     Symtable * symtable;
     Symtables * symtables;
     Text_def * textdef;
-    Voice *voice;    
-    Voice_element *el; 
     char c;
     const char *consstr;
     int i;
@@ -84,26 +90,26 @@ 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_;
        
-       if (pars_l->first_b_) {
-               pars_l->first_b_ = false;
-               pars_l->do_init_file();
-       }
-
        lex_l->lexval_l = (void*) s;
        return lex_l->yylex();
 }
 
 
 %}
+
 %pure_parser
 
 /* tokens which are not keywords */
 %token CONCAT
 
+%token ALIAS
 %token BAR
 %token CADENZA
 %token CLEAR
 %token CLEF
+%token CONTAINS
+%token CONSISTS
+%token ACCEPTS
 %token CM_T
 %token DURATIONCOMMAND
 %token ABSDYNAMIC
@@ -111,18 +117,19 @@ yylex(YYSTYPE *s,  void * v_l)
 %token GEOMETRIC
 %token GROUPING
 %token GROUP
-%token INPUT_REGS
+%token REQUESTTRANSLATOR
 %token HSHIFT
 %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 MULTIVOICE
+%token MULTI
 %token NOTE
 %token NOTENAMES
 %token OCTAVECOMMAND
@@ -152,19 +159,21 @@ yylex(YYSTYPE *s,  void * v_l)
 /* escaped */
 %token E_EXCLAMATION E_SMALLER E_BIGGER E_CHAR
 
-%token <i>     DOTS
+%type <i>      dots
 %token <i>     INT
 %token <melreq>        NOTENAME_ID
-%token <id>    REGS_IDENTIFIER
 %token <id>    IDENTIFIER
 %token <id>    MELODIC_REQUEST_IDENTIFIER 
-%token <id>    CHORD_IDENTIFIER
+%token <id>    MUSIC_IDENTIFIER
 %token <id>    VOICE_IDENTIFIER
 %token <id>    POST_REQUEST_IDENTIFIER
 %token <id>    SCRIPT_IDENTIFIER
 %token <id>    STAFF_IDENTIFIER
 %token <id>    REAL_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 <string>        DURATION RESTNAME
@@ -174,9 +183,9 @@ yylex(YYSTYPE *s,  void * v_l)
 
 
 %type <box>    box
-%type <c>      open_request_parens close_request_parens close_plet_parens
-%type <chord>  music_chord music_chord_body  init_music_chord
-%type <el>     voice_elt full_element lyrics_elt command_elt
+%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
@@ -189,31 +198,27 @@ yylex(YYSTYPE *s,  void * v_l)
 %type <melreqvec>      pitch_list 
 %type <midi>   midi_block midi_body
 %type <moment> duration_length
-%type <music>  init_music
-%type <mvoice>  simple_horizontal_music horizontal_music  horizontal_music_body
-%type <mvoice>  transposed_music_voice init_lyrics_voice
-%type <mvoice> music_voice_body init_music_voice  
+
+%type <music>  Music transposed_music
+%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>        pure_post_request pure_post_request_choice
-%type <request>        script_req textscript_req dynamic_req 
+%type <request>        script_req  dynamic_req 
 %type <score>  score_block score_body
-%type <script> script_definition script_body mudela_script
-%type <staff>  staff_block staff_init staff_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 <textdef>        mudela_text
-%type <iregs>  input_regs input_regs_body
+%type <itrans> input_translator_spec input_translator_spec_body
 
 %left PRIORITY
 
-%expect 1      /* have to fix this. */
-
 %%
 
 mudela:        /* empty */
@@ -224,15 +229,8 @@ mudela:    /* empty */
        | mudela error
        | mudela check_version { } 
        | mudela add_notenames { }
-       | mudela init_end       {}
        ;
 
-init_end: INIT_END ';'         {
-           THIS->print_declarations();
-           THIS->init_parse_b_ = false;
-           THIS->set_debug();
-       }
-       ;
 check_version:
        VERSION STRING ';'              {
                if (*$2 != MUDELA_VERSION) {
@@ -286,15 +284,11 @@ declarable_identifier:
 old_identifier:
        IDENTIFIER
        |       MELODIC_REQUEST_IDENTIFIER 
-       |       CHORD_IDENTIFIER
-       |       VOICE_IDENTIFIER
        |       POST_REQUEST_IDENTIFIER
        |       SCRIPT_IDENTIFIER
-       |       STAFF_IDENTIFIER
        |       REAL_IDENTIFIER
        |       SCORE_IDENTIFIER
        |       REQUEST_IDENTIFIER
-       |       REGS_IDENTIFIER
        ;
 
 declaration:
@@ -302,24 +296,20 @@ declaration:
                $$ = new Score_id(*$1, $3, SCORE_IDENTIFIER);
                delete $1;
        }
-       | declarable_identifier '=' staff_block  {
-               $$ = new Staff_id(*$1, $3, STAFF_IDENTIFIER);
-               delete $1; 
-       }
-       | declarable_identifier '=' init_music_voice {
-               $$ = new M_voice_id(*$1, $3, VOICE_IDENTIFIER);
+       | declarable_identifier '=' paper_block {
+               $$ = new Paper_def_id(*$1, $3, PAPER_IDENTIFIER);
                delete $1;
        }
-       | declarable_identifier '=' init_lyrics_voice {
-               $$ = new M_voice_id(*$1, $3, VOICE_IDENTIFIER);
+       | declarable_identifier '=' midi_block {
+               $$ = new Midi_def_id(*$1, $3, MIDI_IDENTIFIER);
                delete $1;
        }
        | declarable_identifier '=' script_definition {
                $$ = new Script_id(*$1, $3, SCRIPT_IDENTIFIER);
                delete $1;
        }
-       | declarable_identifier '=' init_music_chord  {
-               $$ = new M_chord_id(*$1, $3, CHORD_IDENTIFIER);
+       | declarable_identifier '=' Music  {
+               $$ = new Music_id(*$1, $3, MUSIC_IDENTIFIER);
                delete $1;
        }
        | declarable_identifier '=' symtables {
@@ -330,8 +320,11 @@ declaration:
                $$ = new Real_id(*$1, new Real($3), REAL_IDENTIFIER);
                delete $1;
        }
-       
-       | declarable_identifier '=' pure_post_request {
+       | declarable_identifier '=' int {
+               $$ = new Int_id(*$1, new int($3), INT_IDENTIFIER);
+               delete $1;
+       }
+       | declarable_identifier '=' post_request {
                $$ = new Request_id(*$1, $3, POST_REQUEST_IDENTIFIER);
                delete $1;
        }
@@ -339,33 +332,38 @@ declaration:
                $$ = new Request_id(*$1, $3, MELODIC_REQUEST_IDENTIFIER);
                delete $1;
        }
-       | declarable_identifier '=' input_regs  {
-               $$ = new Input_regs_id(*$1, $3, REGS_IDENTIFIER);
-               delete $1;
-       }
        ;
 
 
-input_regs:
-       INPUT_REGS
-               { THIS->remember_spot(); }
-       '{' input_regs_body '}'
-       {
-               $$ = $4;
-               $$->set_spot(THIS->pop_spot());
-       }
+
+input_translator_spec:
+       REQUESTTRANSLATOR '{' input_translator_spec_body '}'
+               { $$ = $3; }
        ;
 
-input_regs_body:
-       REGS_IDENTIFIER         {
-               $$ = $1->iregs(true);
+input_translator_spec_body:
+       STRING STRING   { 
+               $$ = new Input_translator; 
+               $$->base_str_ = *$1;
+               $$->type_str_ =*$2;
+               $$->set_spot ( THIS->here_input() );
+               delete $1;
+               delete $2;
        }
-       |STRING { 
-               $$ = new Input_register;
-               $$->name_str_ = *$1;
+       | input_translator_spec_body ID STRING ';' {
+               $$-> default_id_str_ = *$3;
+               delete $3;
        }
-       | input_regs_body input_regs {
-               $$->add($2);
+       | input_translator_spec_body ALIAS STRING ';' {
+               $$-> alias_str_arr_.push(*$3);
+               delete $3;
+       }
+       | input_translator_spec_body CONSISTS STRING ';'        {
+               $$-> consists_str_arr_.push(*$3);
+               delete $3;
+       }
+       | input_translator_spec_body CONTAINS input_translator_spec {
+               $$->add($3);
        }
        ;
 
@@ -387,14 +385,20 @@ score_block:
        ;
 
 score_body:            { 
-               $$ = new Input_score; 
+               $$ = new Score; 
        }
        | 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 Music      {
+               $$->music_p_ = $2;
+       }
+       | score_body paper_block                {
+               $$->paper_p_ = $2;      
+       }
+       | score_body midi_block         { 
+               $$->midi_p_ = $2;
+       }
        | score_body error {
 
        }
@@ -418,16 +422,21 @@ paper_block:
 
 paper_body:
        /* empty */                     {
-               $$ = THIS->default_paper();
-
+               $$ = THIS->default_paper(); // paper / video / engrave
        }
-       | 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 {
 
        }
@@ -442,195 +451,116 @@ midi_block:
        '{' midi_body '}'       { $$ = $3; }
        ;
 
-midi_body: 
-               $$ = new Midi_def; 
+midi_body: /* empty */                 {
+               $$ = THIS->default_midi(); // midi / audio / perform
        }
-       | midi_body OUTPUT STRING       { 
+       | midi_body OUTPUT STRING ';'   { 
                $$->outfile_str_ = *$3; 
                delete $3; 
        }
-       | midi_body TEMPO notemode_duration ':' int {
+       | midi_body TEMPO notemode_duration ':' int ';' {
                $$->set_tempo( $3->length(), $5 );
        }
-       | midi_body error {
-
-       }
-       ;
-
-/*
-       STAFFs
-*/
-staff_block:
-       STAFF   { THIS->remember_spot(); }
-/*cont*/       '{' staff_body '}'      {
-               $$ = $4; 
-               $$-> set_spot(THIS->pop_spot());
-       }
-       | { THIS->remember_spot(); }
-/*cont*/       STAFF_IDENTIFIER        { 
-               $$ = $2->staff(true); 
-               $$-> set_spot(THIS->pop_spot());
-       }
-       ;
-
-
-
-staff_init:
-        STAFF_IDENTIFIER {
-               $$ = $1->staff(true);
-       }
-       | REGS_IDENTIFIER {
-               $$ = new Input_staff;
-               $$->ireg_p_ = $1->iregs(true);
-       }
-       | input_regs    {
-               $$ = new Input_staff;
-               $$->ireg_p_ = $1;
-       }
-       ;
-
-staff_body:
-       staff_init
-       | staff_body init_music {
-               $$ = $1;
-               $2->set_default_group( "staff_music" + String($$->music_.size()));
-               $$->add($2);
-       }
-       | staff_body error {
+       | midi_body input_translator_spec       {
+               $$->set( $2 );
        }
-       ;
+       | midi_body error {
 
-/*
-       let the lexer switch mode.
-*/
-init_music:
-       init_music_voice        { $$ = $1; }
-       | init_music_chord      { $$ = $1; }
-       | init_lyrics_voice     { $$ = $1; }
-       | VOICE_IDENTIFIER      { 
-               $$ = $1->mvoice(true);
        }
        ;
 
-init_lyrics_voice:
-       LYRIC { THIS->lexer_p_->push_lyric_state(); } 
-       horizontal_music { $$ = $3; THIS->lexer_p_->pop_state(); }
-       ;
-
-init_music_voice:
-       MELODIC { THIS->lexer_p_->push_note_state(); } 
-       /* cont*/ horizontal_music
-               { $$=$3; THIS->lexer_p_->pop_state(); }
-       ;
-
-init_music_chord:
-       { THIS->lexer_p_->push_note_state(); } 
-       /* cont*/ music_chord
-                 { $$=$2; THIS->lexer_p_->pop_state(); }
-       ;
 /*
        MUSIC
 */
 
-horizontal_music:
-       '{' horizontal_music_body '}'   {
+Voice:
+       '{' Voice_body '}'      {
                $$ = $2;
        }
        ;
 
-horizontal_music_body:
-       simple_horizontal_music                         {
-               $$ = $1;
+Voice_body:
+       /**/            {
+               $$ = new Voice;
        }
-       | horizontal_music_body CONCAT simple_horizontal_music  {
-               $$->add($3);/* niet echt */
-       }
-       ;
-
-
-simple_horizontal_music:
-       TRANSPOSE '{' transposed_music_voice '}' {
-               $$ = $3;
-       }
-       | VOICE_IDENTIFIER {
-               $$ = $1->mvoice(true);
+       | Voice_body ID STRING STRING ';'       {
+               $$ = new Voice;
+               $$->type_str_ = *$3;    
+               $$->id_str_ = *$4;
+               delete $3;
+               delete $4;
        }
-       | music_voice_body      {
-               $$ = $1;
+       | Voice_body Music              {
+               $$->add($2);
        }
        ;
 
+Music:
+       full_element            { $$ = $1; }
+       | Voice         { $$ = $1; }
+       | Chord                 { $$ = $1; }
+       | transposed_music      { $$ = $1; }
+       | MUSIC_IDENTIFIER      { $$ = $1->music(true); }
+       | MELODIC 
+               { THIS->lexer_p_->push_note_state(); } 
+       Music
+               { $$=$3; THIS->lexer_p_->pop_state(); }
 
-transposed_music_voice:
-       steno_melodic_req horizontal_music { 
-               $$ = $2;
-               $$->transpose(*$1);
-               delete $1;
-       }
-       ;
+       | LYRIC 
+               { THIS->lexer_p_->push_lyric_state(); } 
+       Music
+               { $$ = $3; THIS->lexer_p_->pop_state(); }
+       ; 
 
+Chord:
+       '<' Chord_body '>'      { $$  = $2; }
+       ;
 
-music_voice_body:
-        /* */  {
-               $$ = new Music_voice;
+Chord_body:
+       /**/    {
+               $$ = new Chord;
+               $$-> multi_level_i_ = 1;
        }
-       | music_voice_body full_element {
-               $$->add_elt($2);
+       | Chord_body MULTI INT ';' {
+               $$->multi_level_i_=$3;
        }
-       | music_voice_body voice_command ';' {
+       | Chord_body ID STRING STRING ';'       {
+               $$->type_str_ = *$3;    
+               $$->id_str_ = *$4;
+               delete $4; 
+               delete $3;
        }
-       | music_voice_body music_chord  {
+       | Chord_body Music {
                $$->add($2);
        }
-       | music_voice_body error {
-       }
-       | music_voice_body '>' {
-               THIS->fatal_error_i_ = 1;
-               THIS->parser_error("Confused by errors: bailing out");
-       }
        ;
 
-music_chord:  '<' music_chord_body '>' { $$ = $2; }
-       ;
-
-music_chord_body:
-       CHORD_IDENTIFIER {
-               $$=$1->mchord(true);
-       }
-       | /* */ {
-               $$ = new Voice_group_chord;
-       }
-       | MULTIVOICE {
-               $$ = new Multi_voice_chord;
-       }
-       | music_chord_body horizontal_music {
-               $$->add($2);
-       }
-       | music_chord_body full_element {
-               $$ ->add_elt($2);
-       }
-       | music_chord_body '}' {
-               THIS->fatal_error_i_ = 1;
-               THIS->parser_error("Confused by errors: bailing out");
-       }
-       | music_chord_body error {
+transposed_music:
+       TRANSPOSE steno_melodic_req Music {
+               $$ = $3;
+               $$ -> transpose($2);
+               delete $2;
        }
        ;
 
+
 /*
        VOICE ELEMENTS
 */
-full_element:  pre_requests voice_elt post_requests {
-               THIS->add_requests($2);
-               $$ = $2;
-       }
-       | pre_requests lyrics_elt post_requests {
-               THIS->add_requests($2);
+full_element:
+       pre_requests simple_element post_requests       {
+               THIS->add_requests((Chord*)$2);//ugh
                $$ = $2;
-        }
-       | command_elt
+       }
+       | voice_command ';'     { $$ = 0; }
        ;       
 
+simple_element:
+       music_elt 
+       | lyrics_elt
+       | command_elt
+       ;
+
 command_elt:
 /* empty */    {
                $$ = new Voice_element;
@@ -639,9 +569,16 @@ command_elt:
 /* cont: */
        command_req {
                $2-> set_spot( THIS->here_input());
-               $$->add($2);
+               ((Chord*)$$) ->add($2);//ugh
 
        }
+       | GROUP STRING ';' { // ugh ugh ugh
+               Change_reg *chr_p = new Change_reg;
+               $$ = chr_p;
+               chr_p-> type_str_ = "Voice_group_engravers"; //ugh
+               chr_p-> id_str_ = *$2;
+               delete $2;
+       }
        ;
 
 command_req:
@@ -673,7 +610,10 @@ verbose_command_req:
        }
        | SKIP duration_length {
                Skip_req * skip_p = new Skip_req;
-               skip_p->duration_ = *$2;
+               skip_p->duration_ = Duration(1,0);
+               skip_p->duration_.set_plet($2->numerator().as_long(), 
+                       $2->denominator().as_long());
+               
                delete $2;
                $$ = skip_p;
        }
@@ -703,11 +643,7 @@ verbose_command_req:
        | GROUPING intastint_list {
                $$ = get_grouping_req(*$2); delete $2;
        }
-       | GROUP STRING          {
-               $$ = new Group_change_req;
-               $$ -> command()->groupchange()->newgroup_str_ = *$2;
-               delete $2;
-       }
+       
        ;
 
 post_requests:
@@ -718,31 +654,17 @@ post_requests:
                $2->set_spot( THIS->here_input());
                THIS->post_reqs.push($2);
        }
-       | post_requests close_plet_parens INT '/' INT { 
-               THIS->post_reqs.push( THIS->get_parens_request($2) ); 
-               THIS->post_reqs.push( get_plet_request( $2, $3, $5 ) ); 
-       }
        ;
 
-post_request:
-       pure_post_request
-       | POST_REQUEST_IDENTIFIER       {
-               $$ = $1->request(false)->clone();
-       }
-       ;
 
-pure_post_request: 
-       pure_post_request_choice        {
-               $$ = $1;
-               $$->set_spot( THIS->here_input());
+post_request:
+       POST_REQUEST_IDENTIFIER {
+               $$ = (Request*)$1->request(true);
        }
-       ;
-pure_post_request_choice:
-       close_request_parens    { 
+       |close_request_parens   { 
                $$ = THIS->get_parens_request($1); 
        }
        | script_req
-       | textscript_req
        | dynamic_req
        ;
 
@@ -753,7 +675,7 @@ pure_post_request_choice:
 */
 steno_melodic_req:
        NOTENAME_ID     {
-               $$ = $1->clone()->melodic();
+               $$ = $1->clone()->musical()->melodic();
                $$->octave_i_ += THIS->default_octave_i_;
        }
        | steno_melodic_req POST_QUOTES         {  
@@ -792,7 +714,7 @@ dynamic_req:
                ad_p ->loudness_ = (Dynamic_req::Loudness)$3;
                $$ =ad_p;
        }
-       |SPANDYNAMIC '{' int int '}' {
+       | SPANDYNAMIC '{' int int '}' {
                Span_dynamic_req * sp_p = new Span_dynamic_req;
                sp_p->spantype = $4;
                sp_p-> dynamic_dir_i_  = $3;
@@ -801,8 +723,9 @@ dynamic_req:
        ;
 
 close_plet_parens:
-       ']' {
+       ']' INT '/' INT {
                $$ = ']';
+               THIS->default_duration_.set_plet($2,$4);
        }
        ;
 
@@ -816,6 +739,9 @@ close_request_parens:
        | ']'   { 
                $$ = ']';
        }
+       | close_plet_parens {
+               $$ = ']';
+       }
        | E_SMALLER {
                $$ = '<';
        }
@@ -823,7 +749,14 @@ close_request_parens:
                $$ = '>';
        }
        ;
-  
+
+open_plet_parens:
+       '[' INT '/' INT {
+               $$ = '[';
+               THIS->default_duration_.set_plet($2,$4);
+       }
+       ;
+
 open_request_parens:
        E_EXCLAMATION   {
                $$ = '!';
@@ -834,6 +767,8 @@ open_request_parens:
        | '['   {
                $$='[';
        }
+       | open_plet_parens {
+       }
        ;
 
 
@@ -843,30 +778,42 @@ script_definition:
        ;
 
 script_body:
-       STRING int int int int          {
-               $$ = new Script_def(*$1,$2, $3,$4,$5);
+       STRING int int int int int              {
+               Script_def *s = new Script_def;
+               s->set_from_input(*$1,$2, $3,$4,$5, $6);
+               $$  = s;
                delete $1;
        }       
        ;
 
-textscript_req:
-       script_dir mudela_text          { $$ = get_text_req($1,$2); }
+script_req:
+       script_dir gen_script_def               { 
+               Musical_script_req *m = new Musical_script_req;
+               $$ = m; 
+               m-> scriptdef_p_ = $2;
+               m-> set_spot ( THIS->here_input() );
+               m-> dir_i_  = $1;
+       }
        ;
 
-mudela_text:
-       STRING                  { 
-               $$ = new Text_def;
-               $$->text_str_ = *$1; 
-               delete $1;
-               $$->style_str_ = THIS->textstyle_str_;
+gen_script_def:
+       text_def        { $$ = $1; }
+       | mudela_script { $$ = $1; 
+               $$-> set_spot( THIS->here_input() );
        }
        ;
 
-script_req:
-       script_dir mudela_script        { 
-               $$ = get_script_req($1, $2);
+text_def:
+       STRING { 
+               Text_def *t  = new Text_def;
+               $$ = t;
+               t->text_str_ = *$1; 
+               delete $1;
+               t->style_str_ = THIS->textstyle_str_;
+               $$->set_spot( THIS->here_input() );
        }
        ;
+
 script_abbreviation:
        '^'             { $$ = get_scriptdef('^'); }
        | '+'           { $$ = get_scriptdef('+'); }
@@ -874,9 +821,7 @@ script_abbreviation:
        | '|'           { $$ = get_scriptdef('|'); }
        | 'o'           { $$ = get_scriptdef('o'); }
        | '>'           { $$ = get_scriptdef('>'); }
-       | DOTS          {
-               if ( $1 > 1 ) 
-                   THIS->here_input().warning( "too many staccato dots"  );
+       | '.'           {
                $$ = get_scriptdef('.');
        }
        ;
@@ -942,7 +887,7 @@ voice_command:
        ;
 
 duration_length:       
-        {
+       {
                $$ = new Moment(0,1);
        }
        | duration_length explicit_duration             {       
@@ -950,13 +895,18 @@ duration_length:
        }
        ;
 
+dots:
+       '.'             { $$ = 1; }
+       | dots '.'      { $$ ++; }
+       ;
+
 notemode_duration:
        /* */           { 
                $$ = new Duration(THIS->default_duration_);
        }
-       | DOTS          {
+       | dots          {
                $$ = new Duration(THIS->default_duration_);
-               $$->dots_i_ = $1;
+               $$->dots_i_  = $1;
        }
        | explicit_duration     {
                THIS->set_last_duration($1);
@@ -974,8 +924,8 @@ explicit_duration:
                        $$->set_plet(THIS->default_duration_);
                     }
        }
-       | explicit_duration DOTS        {
-               $$->dots_i_ = $2;
+       | explicit_duration '.'         {
+               $$->dots_i_ ++;
        }
        | explicit_duration '*' int  {
                $$->plet_.iso_i_ *= $3; 
@@ -986,7 +936,7 @@ explicit_duration:
        ;
 
 
-voice_elt:
+music_elt:
        steno_note_req notemode_duration                {
                if (!THIS->lexer_p_->note_state_b())
                        THIS->parser_error("have to be in Note mode for notes");
@@ -1000,7 +950,7 @@ voice_elt:
        ;
 
 lyrics_elt:
-       mudela_text notemode_duration                   {
+       text_def notemode_duration                      {
                if (!THIS->lexer_p_->lyric_state_b())
                        THIS->parser_error("Have to be in Lyric mode for lyrics");
                $$ = THIS->get_word_element($1, $2);
@@ -1014,23 +964,22 @@ pitch_list:                      {
                $$ = new Array<Melodic_req*>;
        }
        | pitch_list NOTENAME_ID        {
-               $$->push($2->clone()->melodic());
+               $$->push($2->clone()->musical()->melodic());
        }
        ;
 
 int:
-       real                    {
-               $$ = int($1);
-               if ( distance($1,Real(int($$)) ) > 1e-8)
-                       yyerror( "integer expected" );
+       INT                     {
+               $$ = $1;
+       }
+       | INT_IDENTIFIER        {
+               $$ = * $1->intid(0);
        }
        ;
 
+
 real:
-       INT                     {
-               $$ = Real($1);
-       }
-       | REAL          {
+       REAL            {
                $$ = $1;
        }
        | REAL_IDENTIFIER               {
@@ -1063,7 +1012,7 @@ symtables_body:
                $$ = new Lookup;
        }
        | IDENTIFIER            {
-               $$ = new Lookup(*$1->lookup(true));
+               $$ = $1->lookup(true);
        }
        | symtables_body TEXID STRING           {
                $$->texsetting = *$3;
@@ -1132,7 +1081,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(true) : new Paper_def ;
+}
+
+Midi_def*
+My_lily_parser::default_midi()
+{
+       Identifier *id = lexer_p_->lookup_identifier( "default_midi" );
+       return id ? id->mididef(true) : new Midi_def ;
 }