]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
*** empty log message ***
[lilypond.git] / lily / parser.yy
index 012e2be3d1c9c3de3564580e34d075ad4875bcaa..7dccfe006b23040f09682c435841b8bd0d61b649 100644 (file)
 
 /*
   Two shift/reduce problems:
-    - empty music-list
-    - empty pre-events
-
-
-
-(bullshit.
-
-s/r:
 
 1.     foo = bar.
 
-       "bar" -> String -> Lyric -> Music
+       "bar" -> String -> Lyric -> Music -> music-assignment
 
-       "bar" -> String
+       "bar" -> String -> string-assignment
 
 
 2.  \repeat
@@ -79,6 +71,7 @@ TODO:
 #include "music-sequence.hh"
 #include "input-smob.hh"
 #include "event.hh"
+#include "text-item.hh"
 
 bool
 regular_identifier_b (SCM id)
@@ -95,6 +88,15 @@ regular_identifier_b (SCM id)
   return v;
 }
 
+SCM
+make_simple_markup (SCM a)
+{
+       static SCM simple;
+       if (!simple)
+       simple = scm_c_eval_string ("simple-markup");
+
+       return scm_list_n (simple, a, SCM_UNDEFINED);
+}
 
 
 bool
@@ -274,6 +276,17 @@ yylex (YYSTYPE *s,  void * v)
 %token <i>     UNSIGNED
 %token <scm>   REAL
 
+%token MARKUP
+%token <scm> MARKUP_HEAD_MARKUP0
+%token <scm> MARKUP_HEAD_MARKUP0_MARKUP1
+%token <scm> MARKUP_HEAD_SCM0
+%token <scm> MARKUP_HEAD_SCM0_MARKUP1
+%token <scm> MARKUP_HEAD_SCM0_SCM1 
+%token <scm> MARKUP_HEAD_SCM0_SCM1_MARKUP2
+
+%token <scm> MARKUP_IDENTIFIER MARKUP_HEAD_LIST0
+%type <scm> markup markup_line markup_list  markup_list_body full_markup 
+
 %type <outputdef> output_def
 %type <scm>    lilypond_header lilypond_header_body
 %type <music>  open_event_parens close_event_parens open_event close_event
@@ -452,6 +465,9 @@ identifier_init:
                $$ = $1->self_scm ();
                scm_gc_unprotect_object ($$);
        }
+       | full_markup {
+               $$ = $1;
+       }
        | output_def {
                $$ = $1->self_scm ();
                scm_gc_unprotect_object ($$);
@@ -1617,11 +1633,18 @@ gen_text_def:
                t->set_spot (THIS->here_input ());
                $$ = t;
        }
-       | string {
+       | full_markup {
                Music *t = MY_MAKE_MUSIC("TextScriptEvent");
                t->set_mus_property ("text", $1);
                t->set_spot (THIS->here_input ());
+               $$ = t; 
+       }
+       | string {
+               Music *t = MY_MAKE_MUSIC("TextScriptEvent");
+               t->set_mus_property ("text", make_simple_markup ($1));
+               t->set_spot (THIS->here_input ());
                $$ = t;
+       
        }
        | DIGIT {
                Music * t = MY_MAKE_MUSIC("FingerEvent");
@@ -2140,6 +2163,72 @@ questions:
        ;
 
 
+
+full_markup:
+       MARKUP_IDENTIFIER {
+               $$ = $1;
+       }
+       | MARKUP 
+               { THIS->lexer_->push_markup_state (); }
+       markup
+               { $$ = $3;
+                 THIS->lexer_->pop_state ();
+               }
+       ;
+       
+markup:
+       STRING {
+               $$ = make_simple_markup ($1);
+       }
+       | MARKUP_HEAD_MARKUP0 markup {
+               $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
+       }
+       | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup {
+               $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
+       }
+       | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
+               $$  = scm_list_n ($1, $2, $3, SCM_UNDEFINED); 
+       }
+       | markup_line {
+               $$ = $1;
+       }
+       | MARKUP_HEAD_LIST0 markup_list {
+               $$ = scm_list_n ($1,$2, SCM_UNDEFINED);
+       }
+       | MARKUP_HEAD_SCM0 embedded_scm {
+               $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
+       }
+       | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
+               $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
+       }
+       | MARKUP_IDENTIFIER {
+               $$ = $1;
+       }
+       
+       ;
+
+markup_list:
+       '<' markup_list_body '>' { $$ = scm_reverse_x ($2, SCM_EOL); }
+       ;
+
+markup_line:
+       '{' markup_list_body '}' {
+               static SCM line ;
+               if (!line)
+                       line = scm_c_eval_string ("line-markup");
+       
+               $$ = scm_list_n (line, scm_reverse_x ($2, SCM_EOL), SCM_UNDEFINED);
+       }
+       ;
+
+markup_list_body:
+       /**/ {  $$ = SCM_EOL; }
+       | markup_list_body markup {
+               $$ = gh_cons ($2, $1) ;
+       }
+       ;
+
+
 %%
 
 void
@@ -2184,6 +2273,13 @@ My_lily_parser::beam_check (SCM dur)
 }
 
 
+
+bool
+markup_p (SCM x)
+{
+       return gh_pair_p (x)
+               && SCM_BOOL_F != scm_object_property (gh_car (x), ly_symbol2scm ("markup-signature"));
+}
 /*
 It is a little strange, to have this function in this file, but
 otherwise, we have to import music classes into the lexer.
@@ -2220,36 +2316,10 @@ My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
 
                *destination = p->self_scm();
                return MUSIC_OUTPUT_DEF_IDENTIFIER;
+       } else if (new_markup_p (sid)) {
+               *destination = sid;
+               return MARKUP_IDENTIFIER;
        }
+
        return -1;      
 }
-#if 0
-
-markup:
-       STRING {
-               $$ = scm_list_n (scm_c_eval_string ("simple-markup"), $1, SCM_UNDEFINED);
-       }
-       | MARKUP_HEAD0 markup
-       | MARKUP_HEAD1 SCM_T markup
-       | MARKUP_HEAD2 markup
-       | MARKUP_LIST_HEAD 
-       | MARKUP_LIST_HEAD 
-       | markup_list {
-               $$ = $1 
-       ;
-
-markup_list:
-       '<' markup_list_body '>' { $$ = scm_reverse_x ($1, SCM_EOL); }
-       ;
-
-markup_line:
-       '{' markup_list_body '}' { $$ = .. scm_reverse_x ($1, SCM_EOL); }
-       
-       ;
-markup_list_body:
-       /**/ {  $$ = SCM_EOL; }
-       markup_list_body markup {
-               $$ = gh_cons ($2, $1) ;
-       }
-       ;
-#endif