]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
parser.yy et al: make UNSIGNED a Scheme value token
[lilypond.git] / lily / parser.yy
index 1e693c89c04a7988e3fe22dd9c6d2209553dee9c..67196eec112bfe14777168c9c43e910ad697865a 100644 (file)
@@ -56,6 +56,14 @@ or
     \repeat { \repeat } \alternative
 */
 
+%nonassoc COMPOSITE
+%left ADDLYRICS
+
+ /* ADDLYRICS needs to have lower precedence than FUNCTION_ARGUMENTS,
+  * or we won't be able to tell music apart from closed_music without
+  * lookahead in the context of function calls.
+  */
+
 %right FUNCTION_ARGUMENTS
       MARKUP LYRICS_STRING MARKUP_IDENTIFIER STRING STRING_IDENTIFIER
       MARKUPLIST WITH CONTEXT_MOD_IDENTIFIER MARKUPLIST_IDENTIFIER
@@ -70,7 +78,6 @@ or
 
  /* The above are the symbols that can start function arguments */
 
-%left ADDLYRICS
 %left PREC_TOP
 
 
@@ -288,7 +295,7 @@ If we give names, Bison complains.
 
 
 %token <i> E_UNSIGNED
-%token <i> UNSIGNED
+%token <scm> UNSIGNED
 
 /* Artificial tokens, for more generic function syntax */
 %token <i> EXPECT_MARKUP "markup?"
@@ -1085,7 +1092,7 @@ braced_music_list:
 
 music:
        simple_music
-       | composite_music %prec FUNCTION_ARGUMENTS
+       | composite_music %prec COMPOSITE
        ;
 
 
@@ -1485,7 +1492,7 @@ new_lyrics:
 re_rhythmed_music:
        composite_music new_lyrics {
                $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
-       } %prec FUNCTION_ARGUMENTS
+       } %prec COMPOSITE
        | LYRICSTO simple_string {
                PARSER->lexer_->push_lyric_state ();
        } music {
@@ -2163,7 +2170,7 @@ gen_text_def:
 fingering:
        UNSIGNED {
                Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
-               t->set_property ("digit", scm_from_int ($1));
+               t->set_property ("digit", $1);
                $$ = t->unprotect ();
        }
        ;
@@ -2251,7 +2258,7 @@ multiplied_duration:
 fraction:
        FRACTION { $$ = $1; }
        | UNSIGNED '/' UNSIGNED {
-               $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
+               $$ = scm_cons ($1, $3);
        }
        ;
 
@@ -2276,9 +2283,7 @@ tremolo_type:
        ;
 
 bass_number:
-       UNSIGNED {
-               $$ = scm_from_int ($1);
-       }
+       UNSIGNED { $$ = $1; }
        | STRING { $$ = $1; }
        | full_markup { $$ = $1; }
        ;
@@ -2585,7 +2590,7 @@ number_factor:
 
 bare_number:
        UNSIGNED        {
-               $$ = scm_from_int ($1);
+               $$ = $1;
        }
        | REAL          {
                $$ = $1;
@@ -2596,7 +2601,7 @@ bare_number:
        | REAL NUMBER_IDENTIFIER        {
                $$ = scm_from_double (scm_to_double ($1) *scm_to_double ($2));
        }
-       | UNSIGNED NUMBER_IDENTIFIER    {
+       | bare_unsigned NUMBER_IDENTIFIER       {
                $$ = scm_from_double ($1 *scm_to_double ($2));
        }
        ;
@@ -2604,15 +2609,13 @@ bare_number:
 
 bare_unsigned:
        UNSIGNED {
-                       $$ = $1;
+               $$ = scm_to_int ($1);
        }
        ;
 
 unsigned_number:
-       bare_unsigned  { $$ = scm_from_int ($1); }
-       | NUMBER_IDENTIFIER {
-               $$ = $1;
-       }
+       UNSIGNED
+       | NUMBER_IDENTIFIER
        ;
 
 exclamations: