]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
* scm/define-music-types.scm (music-descriptions): don't use
[lilypond.git] / lily / parser.yy
index 3623abc0c63ed9cf6a7aa5500229b5137ea48492..b12b03e79682db542cdbe03a4d75a2eebe96fbf1 100644 (file)
@@ -41,9 +41,9 @@ FIXME:
 #include "paper-book.hh"
 #include "output-def.hh"
 #include "scm-hash.hh"
-#include "scm-option.hh"
+#include "program-option.hh"
 #include "score.hh"
-#include "text-item.hh"
+#include "text-interface.hh"
 #include "warn.hh"
 
 #define MY_MAKE_MUSIC(x)  make_music_by_name (ly_symbol2scm (x))
@@ -199,7 +199,7 @@ make_music_relative (Pitch start, Music *music)
 Music*
 make_lyric_combine_music (SCM name, Music *music)
 {
-       Music *combine = MY_MAKE_MUSIC ("NewLyricCombineMusic");
+       Music *combine = MY_MAKE_MUSIC ("LyricCombineMusic");
        combine->set_property ("element", music->self_scm ());
        combine->set_property ("associated-context", name);
        return combine;
@@ -225,13 +225,13 @@ of the parse stack onto the heap. */
 %{
 
 int
-yylex (YYSTYPE *s, YYLTYPE *l, void *v)
+yylex (YYSTYPE *s, YYLTYPE *loc, void *v)
 {
        Lily_parser *pars = (Lily_parser*) v;
        Lily_lexer *lex = pars->lexer_;
 
        lex->lexval = (void*) s;
-       lex->lexloc = l;
+       lex->lexloc = loc;
        lex->prepare_for_next_token ();
        return lex->yylex ();
 }
@@ -257,13 +257,11 @@ or
 %pure_parser
 %locations
 
-/* FIXME: The third option is an alias that will be used to display
-   the syntax error.  There's a bug (reported with patch) in bison CVS
-   that prints double backslashes
+/* The third option is an alias that will be used to display the
+   syntax error.  Bison CVS now correctly handles backslash escapes.
+
+   FIXME: Bison needs to translate some of these, eg, STRING.
 
-   bison.ly:1:5: error: syntax error, unexpected \\book", expecting '{'
-   \book
-       \book %expect \book error here
 */     
    
 /* Keyword tokens with plain escaped name.  */
@@ -281,6 +279,7 @@ or
 %token CONSISTS "\\consists"
 %token CONTEXT "\\context"
 %token DEFAULT "\\default"
+%token DEFAULTCHILD "\\defaultchild"
 %token DENIES "\\denies"
 %token DESCRIPTION "\\description"
 %token DRUMMODE "\\drummode"
@@ -425,7 +424,6 @@ parser.yy:352.8-24: warning: symbol `"\\<"' used more than once as a literal str
 %type <book> book_block
 %type <book> book_body
 
-%type <i> bare_int
 %type <i> bare_unsigned
 %type <i> bass_mod
 %type <i> dots
@@ -789,22 +787,24 @@ score_block:
        ;
 
 score_body:
-       /**/    {
-               $$ = new Score;
+       Music {
+               SCM m = $1->self_scm ();
+               scm_gc_unprotect_object (m);
+               SCM scorify = ly_lily_module_constant ("scorify-music");
+               SCM score = scm_call_2 (scorify, m, THIS->self_scm ());
+
+               // pass ownernship to C++ again. 
+               scm_gc_protect_object (score);
+               $$ = unsmob_score (score);
                $$->set_spot (@$);
        }
        | SCORE_IDENTIFIER {
-               $$ = new Score ( *unsmob_score ($1));
+               $$ = unsmob_score ($1);
                $$->set_spot (@$);
        }
        | score_body object_id_setting {
                $$->user_key_ = ly_scm2string ($2);
        }
-       | score_body Music {
-               SCM m = $2->self_scm ();
-               scm_gc_unprotect_object (m);
-               $$->set_music (m, THIS->self_scm ());
-       }
        | score_body lilypond_header    {
                $$->header_ = $2;
        }
@@ -996,7 +996,7 @@ Repeated_music:
                        r-> set_property ("element", beg->self_scm ());
                        scm_gc_unprotect_object (beg->self_scm ());
                        }
-               r->set_property ("repeat-count", scm_int2num (times >? 1));
+               r->set_property ("repeat-count", scm_int2num (max (times, 1)));
 
                r-> set_property ("elements",alts);
                if (ly_c_equal_p ($2, scm_makfrom0str ("tremolo"))) {
@@ -1425,6 +1425,7 @@ context_def_mod:
        | REMOVE { $$ = ly_symbol2scm ("remove"); }
 
        | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
+       | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
        | DENIES { $$ = ly_symbol2scm ("denies"); }
 
        | ALIAS { $$ = ly_symbol2scm ("alias"); }
@@ -1520,8 +1521,17 @@ scalar: string {
        | LYRICS_STRING {
                $$ = $1;
        }
-        | bare_int {
-               $$ = scm_int2num ($1);
+       | bare_number {
+               $$ = $1;
+/*             if (scm_integer_p ($1) == SCM_BOOL_T)
+               {
+                       int k = scm_to_int (scm_inexact_to_exact ($1));
+                       $$ = k;
+               } else
+               {
+                       THIS->parser_error (@1, _ ("need integer number arg"));
+                       $$ = 0;
+               }*/
        }
         | embedded_scm {
                $$ = $1;
@@ -2089,14 +2099,10 @@ optional_notemode_duration:
        {
                Duration dd = THIS->default_duration_;
                $$ = dd.smobbed_copy ();
-
-               THIS->beam_check ($$);
        }
        | multiplied_duration   {
                $$ = $1;
                THIS->default_duration_ = *unsmob_duration ($$);
-
-               THIS->beam_check ($$);
        }
        ;
 
@@ -2485,23 +2491,6 @@ bare_unsigned:
        }
        ;
 
-bare_int:
-       bare_number {
-               if (scm_integer_p ($1) == SCM_BOOL_T)
-               {
-                       int k = scm_to_int ($1);
-                       $$ = k;
-               } else
-               {
-                       THIS->parser_error (@1, _ ("need integer number arg"));
-                       $$ = 0;
-               }
-       }
-       | '-' bare_int {
-               $$ = -$2;
-       }
-       ;
-
 exclamations:
                { $$ = 0; }
        | exclamations '!'      { $$ ++; }
@@ -2575,7 +2564,7 @@ markup_braced_list:
        ;
 
 markup_braced_list_body:
-       /* empty */     {  $$ = scm_list (SCM_EOL); }
+       /* empty */     {  $$ = SCM_EOL; }
        | markup_braced_list_body markup {
                $$ = scm_cons ($2, $1);
        }
@@ -2649,7 +2638,8 @@ simple_markup:
        
 markup:
        markup_head_1_list simple_markup        {
-               $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2)));
+               SCM mapper = ly_lily_module_constant ("map-markup-command-list");
+               $$ = scm_car (scm_call_2 (mapper, $1, scm_list_1 ($2)));
        }
        | simple_markup {
                $$ = $1;
@@ -2673,30 +2663,6 @@ Lily_parser::do_yyparse ()
 }
 
 
-/*
-Should make this optional?    It will also complain when you do
-
-       [s4]
-
-which is entirely legitimate.
-
-Or we can scrap it. Barchecks should detect wrong durations, and
-skipTypesetting speeds it up a lot.
-*/
-
-void
-Lily_parser::beam_check (SCM dur)
-{
-  Duration *d = unsmob_duration (dur);
-  if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
-    {
-      Music *m = unsmob_music (last_beam_start_);
-      m->origin ()->warning (_f ("suspect duration in beam: %s",
-      d->to_string ()));
-    }
-  last_beam_start_ = SCM_EOL;
-}
-