function foo() {
float f = 5.;
}
Above is parsed as a valid code.
function foo() {
float f = 5.4e;
}
Above gives multiple error messages for a single error. Below are the error messages and the resulting tree.
// Error messages
xxx.bal:0:0:missing digit
xxx.bal:0:0:invalid token '5.4e'
xxx.bal:0:0:missing MISSING[]
// Resulting tree
function foo() {
float f = MISSING[]5.4e;
}
function foo() {
float f = 5.e1;
}
Above also get parsed as a valid code.
@SupunS I allowed case I and III intentionally. Test cases for them also added.
floating-point-literal := DecimalFloatingPointNumber
DecimalFloatingPointNumber := DottedDecimalNumber [Exponent] [FloatingPointTypeSuffix]
DottedDecimalNumber := DecimalNumber . Digit*
IIUC , DecimalNumber . Digit* means it is allowed have no digits after dot token right?
I will have a look on case II. :)
@SupunS I allowed case I and III intentionally. Test cases for them also added.
floating-point-literal := DecimalFloatingPointNumber DecimalFloatingPointNumber := DottedDecimalNumber [Exponent] [FloatingPointTypeSuffix] DottedDecimalNumber := DecimalNumber . Digit*IIUC , DecimalNumber . Digit* means it is allowed have no digits after dot token right?
I see. Yes you are correct. I didn't notice that part.
I think for case-III, we can log an error in the lexer, but still return a valid floating-point-literal token, so that the rest of the parser will work normally.. WDYT?
I think for case-III, we can log an error in the lexer, but still return a valid floating-point-literal token, so that the rest of the parser will work normally.. WDYT?
Case III should be fine. I think you are referring to case II here. Yeah we can do that change. +1
Yes, I meant Case-II
Similar to case II, we have another two scenarios where numerical literals are processed as invalid tokens.
float f = 02.3 float f = 0x.p12Are we going to allow them to parse as well while logging an error at lexer level?
hmm.. yeah we should do that.
Anyway, I'm lowering the priority of the issue since this doesn't break any code, and only an improvement.