From: David Kastrup Date: Sat, 31 Aug 2013 16:57:09 +0000 (+0200) Subject: Issue 3527: parser.yy: allow "scalar" to be a negative literal number X-Git-Tag: release/2.17.26-1~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c7320b8c6dd5ef813602526c340a3e30c2cc91f7;p=lilypond.git Issue 3527: parser.yy: allow "scalar" to be a negative literal number 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. --- diff --git a/lily/parser.yy b/lily/parser.yy index e6eb1c7435..a1e1a9f080 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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