From c0372e3b28cd2cbc7046461cf6ca637b44e8731d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Tue, 9 Jan 2024 15:00:46 +0100 Subject: [PATCH] simple language: regen lexer with current jflex version --- .../intellij/sdk/language/SimpleLexer.java | 258 ++++++++++-------- 1 file changed, 150 insertions(+), 108 deletions(-) diff --git a/simple_language_plugin/src/main/gen/org/intellij/sdk/language/SimpleLexer.java b/simple_language_plugin/src/main/gen/org/intellij/sdk/language/SimpleLexer.java index b51639d00..0192581c4 100644 --- a/simple_language_plugin/src/main/gen/org/intellij/sdk/language/SimpleLexer.java +++ b/simple_language_plugin/src/main/gen/org/intellij/sdk/language/SimpleLexer.java @@ -1,6 +1,7 @@ -/* The following code was generated by JFlex 1.7.0 tweaked for IntelliJ platform */ +// Copyright 2000-2024 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Generated by JFlex 1.9.1 http://jflex.de/ (tweaked for IntelliJ platform) +// source: Simple.flex -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.language; import com.intellij.lexer.FlexLexer; @@ -9,11 +10,6 @@ import org.intellij.sdk.language.psi.SimpleTypes; import com.intellij.psi.TokenType; -/** - * This class is a scanner generated by - * JFlex 1.7.0 - * from the specification file Simple.flex - */ class SimpleLexer implements FlexLexer { /** This character denotes the end of file */ @@ -32,40 +28,76 @@ class SimpleLexer implements FlexLexer { * at the beginning of a line * l is of the form l = 2*k, k a non negative integer */ - private static final int ZZ_LEXSTATE[] = { + private static final int ZZ_LEXSTATE[] = { 0, 0, 1, 1 }; - /** - * Translates characters to character classes - * Chosen bits are [9, 6, 6] - * Total runtime size is 1568 bytes + /** + * Top-level table for translating characters to character classes */ - public static int ZZ_CMAP(int ch) { - return ZZ_CMAP_A[(ZZ_CMAP_Y[ZZ_CMAP_Z[ch>>12]|((ch>>6)&0x3f)]<<6)|(ch&0x3f)]; + private static final int [] ZZ_CMAP_TOP = zzUnpackcmap_top(); + + private static final String ZZ_CMAP_TOP_PACKED_0 = + "\1\0\37\u0100\1\u0200\267\u0100\10\u0300\u1020\u0100"; + + private static int [] zzUnpackcmap_top() { + int [] result = new int[4352]; + int offset = 0; + offset = zzUnpackcmap_top(ZZ_CMAP_TOP_PACKED_0, offset, result); + return result; } - /* The ZZ_CMAP_Z table has 272 entries */ - static final char ZZ_CMAP_Z[] = zzUnpackCMap( - "\1\0\1\100\1\200\u010d\100"); + private static int zzUnpackcmap_top(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } - /* The ZZ_CMAP_Y table has 192 entries */ - static final char ZZ_CMAP_Y[] = zzUnpackCMap( - "\1\0\1\1\1\2\175\3\1\4\77\3"); - /* The ZZ_CMAP_A table has 320 entries */ - static final char ZZ_CMAP_A[] = zzUnpackCMap( - "\11\0\1\4\1\2\1\1\1\5\1\3\22\0\1\7\1\10\1\0\1\10\26\0\1\11\2\0\1\11\36\0\1"+ - "\6\50\0\1\1\242\0\2\1\26\0"); + /** + * Second-level tables for translating characters to character classes + */ + private static final int [] ZZ_CMAP_BLOCKS = zzUnpackcmap_blocks(); - /** + private static final String ZZ_CMAP_BLOCKS_PACKED_0 = + "\11\0\1\1\1\2\1\3\1\4\1\5\22\0\1\6"+ + "\1\7\1\0\1\7\26\0\1\10\2\0\1\10\36\0"+ + "\1\11\50\0\1\3\u01a2\0\2\3\326\0\u0100\12"; + + private static int [] zzUnpackcmap_blocks() { + int [] result = new int[1024]; + int offset = 0; + offset = zzUnpackcmap_blocks(ZZ_CMAP_BLOCKS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackcmap_blocks(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** * Translates DFA states to action switch labels. */ private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\2\0\2\1\1\2\1\3\1\4\1\5\2\6\2\7"+ - "\1\3\1\7\1\0\2\4\1\0\1\2\2\6"; + "\2\0\1\1\1\2\1\1\1\3\1\4\1\5\1\6"+ + "\2\7\1\6\1\7\1\5\1\0\2\3\1\0\1\6"+ + "\1\2\1\6"; private static int [] zzUnpackAction() { int [] result = new int[21]; @@ -87,15 +119,15 @@ class SimpleLexer implements FlexLexer { } - /** + /** * Translates a state to a row index in the transition table */ private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\12\0\24\0\36\0\50\0\62\0\74\0\106"+ - "\0\120\0\132\0\50\0\144\0\156\0\170\0\62\0\202"+ - "\0\214\0\156\0\132\0\226\0\240"; + "\0\0\0\13\0\26\0\41\0\54\0\67\0\102\0\115"+ + "\0\130\0\143\0\41\0\156\0\171\0\204\0\115\0\217"+ + "\0\232\0\204\0\245\0\156\0\260"; private static int [] zzUnpackRowMap() { int [] result = new int[21]; @@ -107,7 +139,7 @@ class SimpleLexer implements FlexLexer { private static int zzUnpackRowMap(String packed, int offset, int [] result) { int i = 0; /* index in packed string */ int j = offset; /* index in unpacked array */ - int l = packed.length(); + int l = packed.length() - 1; while (i < l) { int high = packed.charAt(i++) << 16; result[j++] = high | packed.charAt(i++); @@ -115,34 +147,36 @@ class SimpleLexer implements FlexLexer { return j; } - /** + /** * The transition table of the DFA */ - private static final int [] ZZ_TRANS = zzUnpackTrans(); + private static final int [] ZZ_TRANS = zzUnpacktrans(); private static final String ZZ_TRANS_PACKED_0 = - "\1\3\1\4\1\5\1\4\2\5\1\6\1\5\1\7"+ - "\1\10\1\11\1\12\1\13\1\12\1\14\1\13\1\15"+ - "\1\16\2\11\2\3\1\0\1\3\2\0\1\17\1\0"+ - "\1\3\1\0\1\3\1\4\1\5\1\4\2\5\1\17"+ - "\1\5\1\3\2\0\5\5\1\0\1\5\11\0\1\3"+ - "\2\0\2\7\1\0\1\3\2\20\1\21\1\20\1\7"+ - "\1\20\12\0\2\11\1\0\2\11\1\0\1\22\4\11"+ - "\1\23\1\5\2\23\1\5\1\22\1\23\3\11\1\24"+ - "\1\16\1\24\1\14\1\16\1\22\1\14\5\11\1\25"+ - "\6\11\1\0\1\5\1\16\1\5\2\16\1\0\1\16"+ - "\2\0\2\20\2\0\10\20\2\0\3\20\1\7\2\20"+ - "\1\11\1\24\1\5\2\24\1\5\1\22\1\24\7\11"+ - "\1\0\1\22\3\11"; + "\1\3\2\4\1\5\1\4\1\5\1\4\1\6\1\7"+ + "\1\10\1\3\1\11\1\12\1\13\1\14\1\13\1\14"+ + "\1\15\2\11\1\16\1\11\1\3\2\0\1\3\1\0"+ + "\1\3\1\0\1\3\1\0\1\17\1\3\1\0\6\4"+ + "\4\0\1\3\2\4\1\5\1\4\1\5\1\4\1\3"+ + "\1\0\1\17\1\3\1\6\1\20\1\0\1\6\1\20"+ + "\1\3\1\20\1\6\1\20\1\21\1\6\21\0\1\3"+ + "\4\0\2\11\1\0\1\11\1\0\4\11\1\22\2\11"+ + "\1\12\1\15\1\23\1\15\1\23\1\12\2\11\1\22"+ + "\2\11\1\24\1\4\1\24\1\4\2\24\2\11\1\22"+ + "\1\11\1\0\2\15\1\4\1\15\1\4\1\15\4\0"+ + "\5\11\1\25\4\11\1\0\2\20\1\0\2\20\1\0"+ + "\7\20\1\0\2\20\1\0\1\6\4\20\1\11\1\23"+ + "\1\4\1\23\1\4\2\23\2\11\1\22\5\11\1\0"+ + "\4\11\1\22\1\11"; - private static int [] zzUnpackTrans() { - int [] result = new int[170]; + private static int [] zzUnpacktrans() { + int [] result = new int[187]; int offset = 0; - offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + offset = zzUnpacktrans(ZZ_TRANS_PACKED_0, offset, result); return result; } - private static int zzUnpackTrans(String packed, int offset, int [] result) { + private static int zzUnpacktrans(String packed, int offset, int [] result) { int i = 0; /* index in packed string */ int j = offset; /* index in unpacked array */ int l = packed.length(); @@ -169,12 +203,12 @@ class SimpleLexer implements FlexLexer { }; /** - * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + * ZZ_ATTRIBUTE[aState] contains the attributes of state {@code aState} */ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\2\0\5\1\1\11\6\1\1\0\2\1\1\0\3\1"; + "\2\0\4\1\1\11\7\1\1\0\2\1\1\0\3\1"; private static int [] zzUnpackAttribute() { int [] result = new int[21]; @@ -221,15 +255,26 @@ class SimpleLexer implements FlexLexer { from input */ private int zzEndRead; - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean zzAtBOL = true; - /** zzAtEOF == true <=> the scanner is at the EOF */ private boolean zzAtEOF; - /** denotes if the user-EOF-code has already been executed */ + /** Number of newlines encountered up to the start of the matched text. */ + @SuppressWarnings("unused") + private int yyline; + + /** Number of characters from the last newline up to the start of the matched text. */ + @SuppressWarnings("unused") + protected int yycolumn; + + /** Number of characters up to the start of the matched text. */ + @SuppressWarnings("unused") + private long yychar; + + /** Whether the scanner is currently at the beginning of a line. */ + @SuppressWarnings("unused") + private boolean zzAtBOL = true; + + /** Whether the user-EOF-code has already been executed. */ private boolean zzEOFDone; @@ -243,26 +288,22 @@ class SimpleLexer implements FlexLexer { } - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table + /** Returns the maximum size of the scanner buffer, which limits the size of tokens. */ + private int zzMaxBufferLen() { + return Integer.MAX_VALUE; + } + + /** Whether the scanner buffer can grow to accommodate a larger token. */ + private boolean zzCanGrow() { + return true; + } + + /** + * Translates raw input code points to DFA table row */ - private static char [] zzUnpackCMap(String packed) { - int size = 0; - for (int i = 0, length = packed.length(); i < length; i += 2) { - size += packed.charAt(i); - } - char[] map = new char[size]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < packed.length()) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); - } - return map; + private static int zzCMap(int input) { + int offset = input & 255; + return offset == input ? ZZ_CMAP_BLOCKS[offset] : ZZ_CMAP_BLOCKS[ZZ_CMAP_TOP[input >> 8] | offset]; } public final int getTokenStart() { @@ -394,7 +435,7 @@ class SimpleLexer implements FlexLexer { private void zzDoEOF() { if (!zzEOFDone) { zzEOFDone = true; - + } } @@ -406,7 +447,8 @@ class SimpleLexer implements FlexLexer { * @return the next token * @exception java.io.IOException if any I/O-Error occurs */ - public IElementType advance() throws java.io.IOException { + public IElementType advance() throws java.io.IOException + { int zzInput; int zzAction; @@ -440,7 +482,7 @@ class SimpleLexer implements FlexLexer { while (true) { if (zzCurrentPosL < zzEndReadL) { - zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/); + zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL); zzCurrentPosL += Character.charCount(zzInput); } else if (zzAtEOF) { @@ -462,11 +504,11 @@ class SimpleLexer implements FlexLexer { break zzForAction; } else { - zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/); + zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL); zzCurrentPosL += Character.charCount(zzInput); } } - int zzNext = zzTransL[ zzRowMapL[zzState] + ZZ_CMAP(zzInput) ]; + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMap(zzInput) ]; if (zzNext == -1) break zzForAction; zzState = zzNext; @@ -485,45 +527,45 @@ class SimpleLexer implements FlexLexer { if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { zzAtEOF = true; - zzDoEOF(); + zzDoEOF(); return null; } else { switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 1: + case 1: { yybegin(YYINITIAL); return SimpleTypes.KEY; - } - // fall through + } + // fall through case 8: break; - case 2: + case 2: { yybegin(YYINITIAL); return TokenType.WHITE_SPACE; - } - // fall through + } + // fall through case 9: break; - case 3: - { return TokenType.BAD_CHARACTER; - } - // fall through - case 10: break; - case 4: + case 3: { yybegin(YYINITIAL); return SimpleTypes.COMMENT; - } - // fall through - case 11: break; - case 5: + } + // fall through + case 10: break; + case 4: { yybegin(WAITING_VALUE); return SimpleTypes.SEPARATOR; - } - // fall through + } + // fall through + case 11: break; + case 5: + { return TokenType.BAD_CHARACTER; + } + // fall through case 12: break; - case 6: + case 6: { yybegin(YYINITIAL); return SimpleTypes.VALUE; - } - // fall through + } + // fall through case 13: break; - case 7: + case 7: { yybegin(WAITING_VALUE); return TokenType.WHITE_SPACE; - } - // fall through + } + // fall through case 14: break; default: zzScanError(ZZ_NO_MATCH);