Update literals in the grammar reference

Add missing long literal suffix
Add binary integer literals
Introduce IntegerLiteral lexer rule, which is closer to the actual lexer

Issue #KT-22713 Fixed
This commit is contained in:
Sergey Igushkin
2018-02-20 21:09:26 +03:00
parent 41044cd277
commit 32df9c00ee
3 changed files with 23 additions and 5 deletions
@@ -803,7 +803,6 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
* : stringTemplate
* : NoEscapeString
* : IntegerLiteral
* : LongLiteral
* : CharacterLiteral
* : FloatLiteral
* : "null"
-1
View File
@@ -137,7 +137,6 @@ literalConstant
: stringTemplate
: NoEscapeString
: IntegerLiteral
: HexadecimalLiteral
: CharacterLiteral
: FloatLiteral
: "null"
+23 -3
View File
@@ -2,12 +2,23 @@
# Lexical structure
*/
[helper]
LongSuffix
: "L"
;
IntegerLiteral
: DecimalLiteral LongSuffix?
: HexadecimalLiteral LongSuffix?
: BinaryLiteral LongSuffix?
;
[helper]
Digit
: ["0".."9"]
;
IntegerLiteral
DecimalLiteral
: Digit
: Digit (Digit | "_")* Digit
;
@@ -22,10 +33,19 @@ HexDigit
;
HexadecimalLiteral
: "0x" HexDigit
: "0x" HexDigit (HexDigit | "_")* HexDigit
: "0" ("x" | "X") HexDigit
: "0" ("x" | "X") HexDigit (HexDigit | "_")* HexDigit
;
[helper]
BinaryDigit
: ("0" | "1")
;
BinaryLiteral
: "0" ("b" | "B") BinaryDigit
: "0" ("b" | "B") BinaryDigit (BinaryDigit | "_")* BinaryDigit
CharacterLiteral
: <character as in Java>
;