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 * : stringTemplate
* : NoEscapeString * : NoEscapeString
* : IntegerLiteral * : IntegerLiteral
* : LongLiteral
* : CharacterLiteral * : CharacterLiteral
* : FloatLiteral * : FloatLiteral
* : "null" * : "null"
-1
View File
@@ -137,7 +137,6 @@ literalConstant
: stringTemplate : stringTemplate
: NoEscapeString : NoEscapeString
: IntegerLiteral : IntegerLiteral
: HexadecimalLiteral
: CharacterLiteral : CharacterLiteral
: FloatLiteral : FloatLiteral
: "null" : "null"
+23 -3
View File
@@ -2,12 +2,23 @@
# Lexical structure # Lexical structure
*/ */
[helper]
LongSuffix
: "L"
;
IntegerLiteral
: DecimalLiteral LongSuffix?
: HexadecimalLiteral LongSuffix?
: BinaryLiteral LongSuffix?
;
[helper] [helper]
Digit Digit
: ["0".."9"] : ["0".."9"]
; ;
IntegerLiteral DecimalLiteral
: Digit : Digit
: Digit (Digit | "_")* Digit : Digit (Digit | "_")* Digit
; ;
@@ -22,10 +33,19 @@ HexDigit
; ;
HexadecimalLiteral HexadecimalLiteral
: "0x" HexDigit : "0" ("x" | "X") HexDigit
: "0x" HexDigit (HexDigit | "_")* HexDigit : "0" ("x" | "X") HexDigit (HexDigit | "_")* HexDigit
; ;
[helper]
BinaryDigit
: ("0" | "1")
;
BinaryLiteral
: "0" ("b" | "B") BinaryDigit
: "0" ("b" | "B") BinaryDigit (BinaryDigit | "_")* BinaryDigit
CharacterLiteral CharacterLiteral
: <character as in Java> : <character as in Java>
; ;