Skip to content

Commit 94e125a

Browse files
authored
Merge pull request #1256 from AviAvni/underscore-literals
Underscore literals - fix float parsing and add negative tests
2 parents 3365a62 + 37092ed commit 94e125a

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

src/fsharp/lex.fsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ let xint8 = xinteger 'y'
203203
let xint16 = xinteger 's'
204204
let xint = xinteger
205205
let xint32 = xinteger 'l'
206-
let floatp = digit ((digit | separator)* digit)? '.' (digit (digit | separator)*)?
207-
let floate = digit ((digit | separator)* digit)? ('.' (digit (digit | separator)*)? )? ('e'| 'E') ['+' '-']? digit (digit | separator)*
206+
let floatp = digit ((digit | separator)* digit)? '.' (digit ((digit | separator)* digit)?)?
207+
let floate = digit ((digit | separator)* digit)? ('.' (digit ((digit | separator)* digit)?)? )? ('e'| 'E') ['+' '-']? digit ((digit | separator)* digit)?
208208
let float = floatp | floate
209209
let bignum = integer ('I' | 'N' | 'Z' | 'Q' | 'R' | 'G')
210210
let ieee64 = float
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//<Expects id="FS1156" span="(18,11-18,13)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
2+
//<Expects id="FS1156" span="(18,14-18,19)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
3+
//<Expects id="FS0599" span="(18,13-18,14)" status="error">Missing qualification after '.'</Expects>
4+
//<Expects id="FS1156" span="(19,11-19,19)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
5+
//<Expects id="FS1156" span="(20,29-20,42)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
6+
//<Expects id="FS1156" span="(22,10-22,13)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
7+
//<Expects id="FS1156" span="(23,10-23,15)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
8+
//<Expects id="FS1156" span="(24,10-24,15)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
9+
//<Expects id="FS1156" span="(25,10-25,15)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
10+
//<Expects id="FS1156" span="(26,10-26,14)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
11+
//<Expects id="FS1156" span="(27,10-27,15)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
12+
//<Expects id="FS1156" span="(28,10-28,15)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
13+
//<Expects id="FS1156" span="(29,10-29,15)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
14+
//<Expects id="FS1156" span="(30,11-30,18)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
15+
//<Expects id="FS1156" span="(31,11-31,18)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
16+
//<Expects id="FS1156" span="(32,11-32,16)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>
17+
18+
let pi1 = 3_.1415F
19+
let pi2 = 3._1415F
20+
let socialSecurityNumber1 = 999_99_9999_L
21+
let x1 = _52
22+
let x2 = 52_
23+
let x3 = 0_x52
24+
let x4 = 0x_52
25+
let x5 = 0x52_
26+
let x6 = 052_
27+
let x7 = 0_o52
28+
let x8 = 0o_52
29+
let x9 = 0o52_
30+
let x10 = 2.1_e2F
31+
let x11 = 2.1e_2F
32+
let x12 = 1.0_F

tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ NOMONO,NoMT SOURCE=E_BasicConstantsBigNum40.fsx SCFLAGS="--test:ErrorRanges" # E
1313
SOURCE=DecimalLiterals02.fs # DecimalLiterals02.fs
1414

1515
SOURCE=FullSetOfEscapeCharacters.fs # FullSetOfEscapeCharacters.fs
16+
SOURCE=E_UnderscoreLiterals.fs SCFLAGS="--test:ErrorRanges" # E_UnderscoreLiterals.fs

0 commit comments

Comments
 (0)