From: David Kastrup Date: Mon, 22 Jul 2013 17:11:59 +0000 (+0200) Subject: Issue 3471: Allow decimal fractions with non-empty parts before and after '.' in... X-Git-Tag: release/2.17.23-1~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=680df85187d0f3862b1ef1cf7a14f8ad7b7f0ee9;p=lilypond.git Issue 3471: Allow decimal fractions with non-empty parts before and after '.' in music 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. --- diff --git a/lily/lexer.ll b/lily/lexer.ll index c1a6e4b0f4..9e25ed7887 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -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;