lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parser.yy: allow "scalar" to be a negative literal number (issue 132


From: dak
Subject: Re: parser.yy: allow "scalar" to be a negative literal number (issue 13270048)
Date: Sun, 01 Sep 2013 16:49:59 +0000

Reviewers: Janek Warchol,


https://codereview.appspot.com/13270048/diff/1/lily/parser.yy
File lily/parser.yy (right):

https://codereview.appspot.com/13270048/diff/1/lily/parser.yy#newcode2328
lily/parser.yy:2328: | SCM_IDENTIFIER
On 2013/09/01 16:25:39, Janek Warchol wrote:
just curious: this SCM_IDENTIFIER is for things like #LEFT?

No.  It's for \xxx or $xxx kind of things not belonging in any other
xxx_IDENTIFIER category.  #LEFT would be SCM_TOKEN instead (and is
covered by embedded_scm_arg).

https://codereview.appspot.com/13270048/diff/1/lily/parser.yy#newcode2351
lily/parser.yy:2351: // not of the kind requiring the full closedness
folderol.
On 2013/09/01 16:25:39, Janek Warchol wrote:
Please avoid using uncommon words like "folderol".  They are funny,
but only for
native speakers ;-)

The dictionary offers "humbug", "balderdash", "poppycock", "rubbish",
"tripe", "trumpery", "trash", "wish-wash", "applesauce", "codswallop" as
alternative words but most of them have not quite the same connotations,
and it's not like those that are similar in meaning are in more common
use.

While most code passages in LilyPond are documented without venturing
beyond the most common 1000 English words (mostly because they are not
venturing beyond any word at all), I think this should already be a
notable improvement over the standard state.

Description:
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.

Please review this at https://codereview.appspot.com/13270048/

Affected files:
  M lily/parser.yy


Index: lily/parser.yy
diff --git a/lily/parser.yy b/lily/parser.yy
index 48dc5680b3bc5cae6b1d16fa962a50b68e2e8d96..6f5c11f6aa4b55d082dbf5d086216fc917958535 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
        | lyric_element
        ;
@@ -2334,7 +2345,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 folderol.
        | bare_number
+       | '-' bare_number
+       {
+               $$ = scm_difference ($2, SCM_UNDEFINED);
+       }
        | FRACTION
        | lyric_element
        ;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]