ballerina-platform / nballerina

Ballerina compiler that generates native executables.
https://ballerina.io/
Apache License 2.0
139 stars 46 forks source link

Implement hexadecimal floating point literals #326

Open jclark opened 3 years ago

jclark commented 3 years ago

These are documented here:

https://ballerina.io/spec/lang/2021R1/#HexFloatingPointLiteral

They can be parsed with float:fromHexString.

ushirask commented 3 years ago

They can be parsed with float:fromHexString.

@jclark float:fromHexString is giving me the following error

error: {ballerina}TypeCastError {"message":"incompatible types: 'handle' cannot be cast to '(float|error)'"} at ballerina.lang.float.1_0_0:fromHexString(float.bal:367)

manuranga commented 3 years ago

@ushirask please create an issue in ballerina-lang repo with a minimal test case.

ushirask commented 3 years ago

@ushirask please create an issue in ballerina-lang repo with a minimal test case.

created in https://github.com/ballerina-platform/ballerina-lang/issues/32220#issue-973862104

jclark commented 3 years ago

Your test case is not a valid https://ballerina.io/spec/lang/2021R1/#HexFloatingPointLiteral

Do you get an error when you pass valid literals?

jclark commented 3 years ago

When parsing the literal, don't allow a trailing . (i.e. the token cannot have a . without a following hex digit). This is for consistency with the change we made to decimal literals.