]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
* lily/include/book.hh (class Book): idem.
[lilypond.git] / lily / parser.yy
index 7c04cb0c262f46160f64e10044a6a2f92f29eb55..dff3ee921df7746974d42a129b52594a1ea464ed 100644 (file)
@@ -74,7 +74,6 @@ using namespace std;
 #include "context-def.hh"
 #include "dimensions.hh"
 #include "file-path.hh"
-#include "input-smob.hh"
 #include "input.hh"
 #include "international.hh"
 #include "lily-guile.hh"
@@ -250,7 +249,6 @@ If we give names, Bison complains.
 %token CHORDMODIFIERS
 %token LYRIC_MARKUP
 %token MULTI_MEASURE_REST
-%token SCM_T
 
 
 %token <i> DIGIT
@@ -301,7 +299,7 @@ If we give names, Bison complains.
 %token <scm> REAL
 %token <scm> RESTNAME
 %token <scm> SCM_IDENTIFIER
-%token <scm> SCM_T
+%token <scm> SCM_TOKEN
 %token <scm> SCORE_IDENTIFIER
 %token <scm> STRING
 %token <scm> STRING_IDENTIFIER
@@ -504,7 +502,7 @@ toplevel_expression:
        ;
 
 embedded_scm:
-       SCM_T
+       SCM_TOKEN
        | SCM_IDENTIFIER
        ;
 
@@ -535,15 +533,6 @@ assignment_id:
 
 assignment:
        assignment_id '=' identifier_init  {
-               if (! is_regular_identifier ($1))
-               {
-#if 0
-                       /* no longer valid with dashes in \paper{} block. */ 
-                       @1.warning (_ ("identifier should have alphabetic characters only"));
-#endif
-               }
-
-
                PARSER->lexer_->set_identifier ($1, $3);
 
 /*
@@ -616,11 +605,11 @@ context_def_spec_block:
 context_def_spec_body:
        /**/ {
                $$ = Context_def::make_scm ();
-               unsmob_context_def ($$)->set_spot (@$);
+               unsmob_context_def ($$)->origin ()->set_spot (@$);
        }
        | CONTEXT_DEF_IDENTIFIER {
                $$ = $1;
-               unsmob_context_def ($$)->set_spot (@$);
+               unsmob_context_def ($$)->origin ()->set_spot (@$);
        }
        | context_def_spec_body GROBDESCRIPTIONS embedded_scm {
                Context_def*td = unsmob_context_def ($$);
@@ -652,14 +641,15 @@ book_block:
 book_body:
        {
                $$ = new Book;
-               $$->set_spot (@$);
+               $$->origin ()->set_spot (@$);
                $$->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (PARSER->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
                $$->paper_->unprotect ();
                $$->header_ = PARSER->lexer_->lookup_identifier ("$defaultheader"); 
        }
        | BOOK_IDENTIFIER {
                $$ = unsmob_book ($1);
-               $$->set_spot (@$);
+               $$->protect ();
+               $$->origin ()->set_spot (@$);
        }
        | book_body paper_block {
                $$->paper_ = $2;
@@ -700,11 +690,12 @@ score_body:
                // pass ownernship to C++ again.
                $$ = unsmob_score (score);
                $$->protect ();
-               $$->set_spot (@$);
+               $$->origin ()->set_spot (@$);
        }
        | SCORE_IDENTIFIER {
                $$ = unsmob_score ($1);
-               $$->set_spot (@$);
+               $$->protect ();
+               $$->origin ()->set_spot (@$);
        }
        | score_body object_id_setting {
                $$->user_key_ = ly_scm2string ($2);
@@ -740,6 +731,7 @@ paper_block:
                if ($$->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
                {
                        PARSER->parser_error (@1, _ ("need \\paper for paper block"));
+                       $1->unprotect ();
                        $$ = get_paper (PARSER);
                }
        }
@@ -788,9 +780,11 @@ output_def_body:
        }
        | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER    {
                $1->unprotect ();
+
                Output_def *o = unsmob_output_def ($3);
                o->input_origin_.set_spot (@$);
                $$ = o;
+               $$->protect ();
                PARSER->lexer_->remove_scope ();
                PARSER->lexer_->add_scope (o->scope_);
        }
@@ -2360,17 +2354,26 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
                *destination = sid;
                return STRING_IDENTIFIER;
        } else if (unsmob_book (sid)) {
-               *destination = unsmob_book (sid)->clone ()->self_scm ();
+               Book *book =  unsmob_book (sid)->clone ();
+               *destination = book->self_scm ();
+               book->unprotect ();
+
                return BOOK_IDENTIFIER;
        } else if (scm_is_number (sid)) {
                *destination = sid;
                return NUMBER_IDENTIFIER;
        } else if (unsmob_context_def (sid)) {
-               *destination = unsmob_context_def (sid)->clone_scm ();
+               Context_def *def= unsmob_context_def (sid)->clone ();
+
+               *destination = def->self_scm ();
+               def->unprotect ();
+               
                return CONTEXT_DEF_IDENTIFIER;
        } else if (unsmob_score (sid)) {
                Score *score = new Score (*unsmob_score (sid));
                *destination = score->self_scm ();
+
+               score->unprotect ();
                return SCORE_IDENTIFIER;
        } else if (Music *mus = unsmob_music (sid)) {
                mus = mus->clone ();
@@ -2381,6 +2384,7 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
                bool is_event = scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
                        != SCM_BOOL_F;
 
+               mus->unprotect ();
                return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
        } else if (unsmob_duration (sid)) {
                *destination = unsmob_duration (sid)->smobbed_copy ();
@@ -2388,8 +2392,9 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
        } else if (unsmob_output_def (sid)) {
                Output_def *p = unsmob_output_def (sid);
                p = p->clone ();
-
+       
                *destination = p->self_scm ();
+               p->unprotect ();
                return OUTPUT_DEF_IDENTIFIER;
        } else if (Text_interface::is_markup (sid)) {
                *destination = sid;