From d196d51e07f50f3510c43ad375c5559b58860023 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 29 Sep 2025 09:39:49 +0200 Subject: java: Add tokens support for Java 21 Some new keywords, I opted to modify java-8 grammar to use the new names, even if they are not going to match anything. Makes the tokenizer easier to write. --- data/java-8/tokens.grammar | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'data/java-8/tokens.grammar') diff --git a/data/java-8/tokens.grammar b/data/java-8/tokens.grammar index 3521ac0..3941b94 100644 --- a/data/java-8/tokens.grammar +++ b/data/java-8/tokens.grammar @@ -43,7 +43,13 @@ Identifier: IdentifierChars: JavaLetter {JavaLetterOrDigit} +# Java 8 only has reserved keywords, but use modern names +# here to make a shared tokenizer simpler. Keyword: + ReservedKeyword + ContextualKeyword + +ReservedKeyword: abstract continue for @@ -95,14 +101,20 @@ Keyword: super while +ContextualKeyword: + Literal: IntegerLiteral FloatingPointLiteral BooleanLiteral CharacterLiteral StringLiteral + TextBlock NullLiteral +# Java 8 doesn't have TextBlock, but add it as newer grammers have it +TextBlock: + IntegerLiteral: DecimalIntegerLiteral HexIntegerLiteral -- cgit v1.3