Letter-ending number literals removed (10L, 1.0d, 1.0f)

This commit is contained in:
Andrey Breslav
2011-03-16 15:22:49 +03:00
parent 495f1ea3b9
commit 6fb8ed823c
8 changed files with 574 additions and 592 deletions
+7 -7
View File
@@ -38,13 +38,13 @@ class IntRange<T> : Range<T>, Iterable<T> {
}
class Number {
val d : Double
val f : Float
val l : Long
val i : Int
val c : Char
val s : Short
val b : Byte
val dbl : Double
val flt : Float
val lng : Long
val int : Int
val chr : Char
val sht : Short
val byt : Byte
}
class Double : Number, Comparable<Double> {
+9 -7
View File
@@ -42,17 +42,19 @@ HEX_INTEGER_LITERAL=0[Xx]({HEX_DIGIT})*
BIN_INTEGER_LITERAL=0[Bb]({DIGIT})*
LONG_LITERAL=({INTEGER_LITERAL})[Ll]
FLOAT_LITERAL=(({FLOATING_POINT_LITERAL1})[Ff])|(({FLOATING_POINT_LITERAL2})[Ff])|(({FLOATING_POINT_LITERAL3})[Ff])|(({FLOATING_POINT_LITERAL4})[Ff])
DOUBLE_LITERAL=(({FLOATING_POINT_LITERAL1})[Dd]?)|(({FLOATING_POINT_LITERAL2})[Dd]?)|(({FLOATING_POINT_LITERAL3})[Dd]?)|(({FLOATING_POINT_LITERAL4})[Dd])
//FLOAT_LITERAL=(({FLOATING_POINT_LITERAL1})[Ff])|(({FLOATING_POINT_LITERAL2})[Ff])|(({FLOATING_POINT_LITERAL3})[Ff])|(({FLOATING_POINT_LITERAL4})[Ff])
//DOUBLE_LITERAL=(({FLOATING_POINT_LITERAL1})[Dd]?)|(({FLOATING_POINT_LITERAL2})[Dd]?)|(({FLOATING_POINT_LITERAL3})[Dd]?)|(({FLOATING_POINT_LITERAL4})[Dd])
DOUBLE_LITERAL={FLOATING_POINT_LITERAL1}|{FLOATING_POINT_LITERAL2}|{FLOATING_POINT_LITERAL3}|{FLOATING_POINT_LITERAL4}
FLOATING_POINT_LITERAL1=({DIGIT})+"."({DIGIT})+({EXPONENT_PART})?
FLOATING_POINT_LITERAL2="."({DIGIT})+({EXPONENT_PART})?
FLOATING_POINT_LITERAL3=({DIGIT})+({EXPONENT_PART})
FLOATING_POINT_LITERAL4=({DIGIT})+
EXPONENT_PART=[Ee]["+""-"]?({DIGIT})*
HEX_FLOAT_LITERAL={HEX_SIGNIFICAND}{BINARY_EXPONENT}[Ff]
HEX_DOUBLE_LITERAL={HEX_SIGNIFICAND}{BINARY_EXPONENT}[Dd]?
//HEX_DOUBLE_LITERAL={HEX_SIGNIFICAND}{BINARY_EXPONENT}[Dd]?
HEX_DOUBLE_LITERAL={HEX_SIGNIFICAND}{BINARY_EXPONENT}?
BINARY_EXPONENT=[Pp][+-]?{DIGIT}+
HEX_SIGNIFICAND={HEX_INTEGER_LITERAL}|{HEX_INTEGER_LITERAL}.|0[Xx]{HEX_DIGIT}*.{HEX_DIGIT}+
HEX_SIGNIFICAND={HEX_INTEGER_LITERAL}|{HEX_INTEGER_LITERAL}\.|0[Xx]{HEX_DIGIT}*\.{HEX_DIGIT}+
CHARACTER_LITERAL="'"([^\\\'\n]|{ESCAPE_SEQUENCE})*("'"|\\)?
// TODO: introduce symbols (e.g. 'foo) as another way to write string literals
@@ -76,10 +78,10 @@ RAW_STRING_LITERAL = {THREE_QUO} {QUO_STRING_CHAR}* {THREE_QUO}?
<YYINITIAL> {INTEGER_LITERAL}\.\. { yypushback(2); return JetTokens.INTEGER_LITERAL; }
<YYINITIAL> {INTEGER_LITERAL} { return JetTokens.INTEGER_LITERAL; }
<YYINITIAL> {LONG_LITERAL} { return JetTokens.LONG_LITERAL; }
//<YYINITIAL> {LONG_LITERAL} { return JetTokens.LONG_LITERAL; }
<YYINITIAL> {FLOAT_LITERAL} { return JetTokens.FLOAT_LITERAL; }
<YYINITIAL> {HEX_FLOAT_LITERAL} { return JetTokens.FLOAT_LITERAL; }
//<YYINITIAL> {FLOAT_LITERAL} { return JetTokens.FLOAT_LITERAL; }
//<YYINITIAL> {HEX_FLOAT_LITERAL} { return JetTokens.FLOAT_LITERAL; }
<YYINITIAL> {DOUBLE_LITERAL} { return JetTokens.FLOAT_LITERAL; }
<YYINITIAL> {HEX_DOUBLE_LITERAL} { return JetTokens.FLOAT_LITERAL; }
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -7,10 +7,10 @@ fun a(
a : foo = "dsf",
a : foo = """dsf""",
a : foo = 10.0,
a : foo = 10d,
a : foo = 10f,
a : foo = 10.0d,
a : foo = 10L,
a : foo = 10.dbl,
a : foo = 10.flt,
a : foo = 10.0.dbl,
a : foo = 10.lng,
a : foo = true,
a : foo = false,
a : foo = null,
+24 -8
View File
@@ -134,8 +134,12 @@ JetFile: SimpleExpressions.jet
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
FLOAT_CONSTANT
PsiElement(FLOAT_CONSTANT)('10d')
DOT_QIALIFIED_EXPRESSION
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('10')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('dbl')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
@@ -150,8 +154,12 @@ JetFile: SimpleExpressions.jet
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
FLOAT_CONSTANT
PsiElement(FLOAT_CONSTANT)('10f')
DOT_QIALIFIED_EXPRESSION
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('10')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('flt')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
@@ -166,8 +174,12 @@ JetFile: SimpleExpressions.jet
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
FLOAT_CONSTANT
PsiElement(FLOAT_CONSTANT)('10.0d')
DOT_QIALIFIED_EXPRESSION
FLOAT_CONSTANT
PsiElement(FLOAT_CONSTANT)('10.0')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('dbl')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
@@ -182,8 +194,12 @@ JetFile: SimpleExpressions.jet
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
LONG_CONSTANT
PsiElement(LONG_LITERAL)('10L')
DOT_QIALIFIED_EXPRESSION
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('10')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('lng')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
-1
View File
@@ -21,7 +21,6 @@ fun foo() {
is null => foo
is 1 => foo
is A.b => foo
is 1l => foo
is 1.0 => foo
is 'c' => foo
is "sadfsa" => foo
-13
View File
@@ -266,19 +266,6 @@ JetFile: When.jet
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
WHEN_ENTRY
WHEN_CONDITION
PsiElement(is)('is')
PsiWhiteSpace(' ')
EXPRESSION_PATTERN
LONG_CONSTANT
PsiElement(LONG_LITERAL)('1l')
PsiWhiteSpace(' ')
PsiElement(DOUBLE_ARROW)('=>')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
WHEN_ENTRY
WHEN_CONDITION
PsiElement(is)('is')
@@ -54,17 +54,14 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertType("0b1", library.getIntType());
assertType("0B1", library.getIntType());
assertType("1l", library.getLongType());
assertType("1L", library.getLongType());
assertType("1.lng", library.getLongType());
assertType("1.0", library.getDoubleType());
assertType("1.0d", library.getDoubleType());
assertType("1.0D", library.getDoubleType());
assertType("1.0.dbl", library.getDoubleType());
assertType("0x1.fffffffffffffp1023", library.getDoubleType());
assertType("1.0f", library.getFloatType());
assertType("1.0F", library.getFloatType());
assertType("0x1.fffffffffffffp1023f", library.getFloatType());
assertType("1.0.flt", library.getFloatType());
assertType("0x1.fffffffffffffp1023.flt", library.getFloatType());
assertType("true", library.getBooleanType());
assertType("false", library.getBooleanType());
@@ -341,62 +338,62 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
public void testOverloads() throws Exception {
assertType("new Functions<String>().f()", "Unit");
assertType("new Functions<String>().f(1)", "Int");
assertType("new Functions<String>().f(1d)", (String) null);
assertType("new Functions<String>().f(1.0)", (String) null);
assertType("new Functions<Double>().f((1, 1))", "Double");
assertType("new Functions<Double>().f(1d)", "Any");
assertType("new Functions<Double>().f(1.0)", "Any");
assertType("new Functions<Byte>().f<String>(\"\")", "Byte");
assertType("new Functions<Byte>().f<String>(1)", (String) null);
assertType("f()", "Unit");
assertType("f(1)", "Int");
assertType("f(1f, 1)", "Float");
assertType("f<String>(1f)", "String");
assertType("f(1.flt, 1)", "Float");
assertType("f<String>(1.flt)", "String");
assertType("f(1.0)", (String) null);
}
public void testPlus() throws Exception {
assertType("1d.plus(1d)", "Double");
assertType("1d.plus(1f)", "Double");
assertType("1d.plus(1L)", "Double");
assertType("1d.plus(1)", "Double");
assertType("1.0.plus(1.dbl)", "Double");
assertType("1.0.plus(1.flt)", "Double");
assertType("1.0.plus(1.lng)", "Double");
assertType("1.0.plus(1)", "Double");
assertType("1f.plus(1d)", "Double");
assertType("1f.plus(1f)", "Float");
assertType("1f.plus(1L)", "Float");
assertType("1f.plus(1)", "Float");
assertType("1.flt.plus(1.dbl)", "Double");
assertType("1.flt.plus(1.flt)", "Float");
assertType("1.flt.plus(1.lng)", "Float");
assertType("1.flt.plus(1)", "Float");
assertType("1L.plus(1d)", "Double");
assertType("1L.plus(1f)", "Float");
assertType("1L.plus(1L)", "Long");
assertType("1L.plus(1)", "Long");
assertType("1.lng.plus(1.dbl)", "Double");
assertType("1.lng.plus(1.flt)", "Float");
assertType("1.lng.plus(1.lng)", "Long");
assertType("1.lng.plus(1)", "Long");
assertType("1.plus(1d)", "Double");
assertType("1.plus(1f)", "Float");
assertType("1.plus(1L)", "Long");
assertType("1.plus(1.dbl)", "Double");
assertType("1.plus(1.flt)", "Float");
assertType("1.plus(1.lng)", "Long");
assertType("1.plus(1)", "Int");
assertType("'1'.plus(1d)", "Double");
assertType("'1'.plus(1f)", "Float");
assertType("'1'.plus(1L)", "Long");
assertType("'1'.plus(1.dbl)", "Double");
assertType("'1'.plus(1.flt)", "Float");
assertType("'1'.plus(1.lng)", "Long");
assertType("'1'.plus(1)", "Int");
assertType("'1'.plus('1')", "Int");
assertType("(1:Short).plus(1d)", "Double");
assertType("(1:Short).plus(1f)", "Float");
assertType("(1:Short).plus(1L)", "Long");
assertType("(1:Short).plus(1.dbl)", "Double");
assertType("(1:Short).plus(1.flt)", "Float");
assertType("(1:Short).plus(1.lng)", "Long");
assertType("(1:Short).plus(1)", "Int");
assertType("(1:Short).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1d)", "Double");
assertType("(1:Byte).plus(1f)", "Float");
assertType("(1:Byte).plus(1L)", "Long");
assertType("(1:Byte).plus(1.dbl)", "Double");
assertType("(1:Byte).plus(1.flt)", "Float");
assertType("(1:Byte).plus(1.lng)", "Long");
assertType("(1:Byte).plus(1)", "Int");
assertType("(1:Byte).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1:Byte)", "Int");
assertType("\"1\".plus(1d)", "String");
assertType("\"1\".plus(1f)", "String");
assertType("\"1\".plus(1L)", "String");
assertType("\"1\".plus(1.dbl)", "String");
assertType("\"1\".plus(1.flt)", "String");
assertType("\"1\".plus(1.lng)", "String");
assertType("\"1\".plus(1)", "String");
assertType("\"1\".plus('1')", "String");
}