]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3527: parser.yy: allow "scalar" to be a negative literal number
authorDavid Kastrup <dak@gnu.org>
Sat, 31 Aug 2013 16:57:09 +0000 (18:57 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 6 Sep 2013 07:03:49 +0000 (09:03 +0200)
This makes the syntax of the value for \override (a hardwired syntax
construct which accepts a "scalar") and \tweak (which is a music
function accepting an expression of type "scheme?" possibly ending up
as a negative number) more comparable.

lily/parser.yy

index e6eb1c7435dd5242263f9f2b046cd38f4ea0a6ea..a1e1a9f080704571d1b9568ea5a91581726c605e 100644 (file)
@@ -2327,6 +2327,17 @@ scalar:
        embedded_scm_arg
        | SCM_IDENTIFIER
        | bare_number
+       // The following is a rather defensive variant of admitting
+       // negative numbers: the grammar would permit number_factor or
+       // even number_expression.  However, function arguments allow
+       // only this simple kind of negative number, so to have things
+       // like \tweak and \override behave reasonably similar, it
+       // makes sense to rule out things like -- which are rather an
+       // accent in function argument contexts.
+       | '-' bare_number
+       {
+               $$ = scm_difference ($2, SCM_UNDEFINED);
+       }
        | FRACTION
        | STRING
        | full_markup
@@ -2335,7 +2346,15 @@ scalar:
 scalar_closed:
        embedded_scm_arg_closed
        | SCM_IDENTIFIER
+       // for scalar_closed to be an actually closed (no lookahead)
+       // expression, we'd need to use bare_number_closed here.  It
+       // turns out that the only use of scalar_closed in TEMPO is
+       // not of the kind requiring the full closedness criterion.
        | bare_number
+       | '-' bare_number
+       {
+               $$ = scm_difference ($2, SCM_UNDEFINED);
+       }
        | FRACTION
        | STRING
        | full_markup