]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3471: Allow decimal fractions with non-empty parts before and after '.' in...
authorDavid Kastrup <dak@gnu.org>
Mon, 22 Jul 2013 17:11:59 +0000 (19:11 +0200)
committerDavid Kastrup <dak@gnu.org>
Sat, 27 Jul 2013 09:13:35 +0000 (11:13 +0200)
This permits writing things like

mkMove = #(define-music-function
        (parser location x y)
        ( number? number? )
        #{ \once \override TextScript #'extra-offset = #(cons x y)
        #})

{
\mkMove 4.4 -3.3
c1^"XY"
}

Since integers are accepted in this kind of usage, not accepting
floating point numbers appears inconsistent.

While in INITIAL mode like inside of layout blocks real numbers can
be written like 4. or -.3 for historic reasons, permitting this inside
of music could easily lead to confusion with durations or
articulations, so those spellings remain invalid in music modes.

Decimal fractions are also not accepted in \chordmode since this would
preclude chord entry like c:13.11^3.7 and similar.

lily/lexer.ll

index c1a6e4b0f43665380e51fca28eec4d19895725ab..9e25ed788735e0af6191c715188ce597fb966a66 100644 (file)
@@ -156,6 +156,7 @@ E_UNSIGNED  \\{N}+
 FRACTION       {N}+\/{N}+
 INT            -?{UNSIGNED}
 REAL           ({INT}\.{N}*)|(-?\.{N}+)
+STRICTREAL      {UNSIGNED}\.{UNSIGNED}
 WHITE          [ \n\t\f\r]
 HORIZONTALWHITE                [ \t]
 BLACK          [^ \n\t\f\r]
@@ -492,8 +493,12 @@ BOM_UTF8   \357\273\277
                yylval =  scan_fraction (YYText ());
                return FRACTION;
        }
-       {UNSIGNED}/\/   | // backup rule
-       {UNSIGNED}              {
+       {STRICTREAL}    {
+               yylval = scm_c_read_string (YYText ());
+               return REAL;
+       }
+       {UNSIGNED}/[/.] | // backup rule
+       {UNSIGNED}      {
                yylval = scm_c_read_string (YYText ());
                return UNSIGNED;
        }
@@ -539,7 +544,11 @@ BOM_UTF8   \357\273\277
                yylval =  scan_fraction (YYText ());
                return FRACTION;
        }
-       {UNSIGNED}/\/   | // backup rule
+       {STRICTREAL}    {
+               yylval = scm_c_read_string (YYText ());
+               return REAL;
+       }
+       {UNSIGNED}/[/.] | // backup rule
        {UNSIGNED}              {
                yylval = scm_c_read_string (YYText ());
                return UNSIGNED;