Keep track of original constant notation in untyped tree
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
**Is your feature request related to a problem? Please describe.**
When the user types a constant in a custom format, this information is lost in the untyped tree.
Example
```fsharp
let a = 1.
```
This exact notation `1.` is parsed correctly and ends up being `SynExpr.Const (SynConst.Double 1.0))`.
**Describe the solution you'd like**
I'd like to see the original format the user typed in the untyped tree.
Something like
```fsharp
[]
type SynConst =
// ...
| Double of notation:string * value:double
```
**Describe alternatives you've considered**
This information can be retrieved from the F# tokens.
**Additional context**
At first glance, this seems quite doable.
We can extend the F# token for the constant:
`pars.fsy`
```
%token IEEE64
```
```
| IEEE64
{ let notation, value = $1
SynConst.Double (notation, value) }
```
`lex.fsl`
```
| ieee64
{ let v = lexeme lexbuf
IEEE64 (v, try float(lexeme lexbuf) with _ -> fail args lexbuf (FSComp.SR.lexInvalidFloat()) 0.0) }
```
There are multiple constants where I see this gain (`chars` for example).
Contributor guide
Assessment
This issue has not been assessed yet.