The definiton for floating point literal in Scala is
floatingPointLiteral ::= digit {digit} ‘.’ digit {digit} [exponentPart] [floatType]
| ‘.’ digit {digit} [exponentPart] [floatType]
| digit {digit} exponentPart [floatType]
| digit {digit} [exponentPart] floatType
exponentPart ::= (‘E’ | ‘e’) [‘+’ | ‘-’] digit {digit}
floatType ::= ‘F’ | ‘f’ | ‘D’ | ‘d’
When I try to input floating point literal that starts with a dot I get an error:
scala> .123
^
error: ';' expected but double literal found.
If is assign such literal to some variable everything is fine
scala> val x = .123
x: Double = 0.123
Why it behaves like that?