From 81f6747e944f39de52be630349ed8b6325dde44c Mon Sep 17 00:00:00 2001 From: Qihan Cai Date: Thu, 27 Apr 2023 12:37:28 +1000 Subject: [PATCH] improve multiclass refined value and sliceelement based on the [documentation](https://llvm.org/docs/TableGen/ProgRef.html) --- .../grammar/_TableGenLexer.java | 365 ++++++++++-------- .../parser/TableGenParser.java | 356 +++++++++-------- .../psi/TableGenAssertStmt.java | 16 + .../psi/TableGenDeclaration.java | 2 +- .../psi/TableGenDefmStmt.java | 2 +- .../psi/TableGenMultiClassID.java | 3 + .../psi/TableGenMultiClassStatement.java | 25 ++ .../psi/TableGenMultiClassStmt.java | 5 +- .../psi/TableGenSliceElement.java | 16 + .../psi/TableGenSliceElements.java | 13 + .../tablegenintellij/psi/TableGenTypes.java | 37 +- .../tablegenintellij/psi/TableGenValue.java | 3 + .../psi/TableGenValueSuffix.java | 3 + .../tablegenintellij/psi/TableGenVisitor.java | 26 +- ...yImpl.java => TableGenAssertStmtImpl.java} | 18 +- .../psi/impl/TableGenDeclarationImpl.java | 4 +- .../psi/impl/TableGenDefmStmtImpl.java | 4 +- .../psi/impl/TableGenMultiClassIDImpl.java | 6 + ...a => TableGenMultiClassStatementImpl.java} | 26 +- .../psi/impl/TableGenMultiClassStmtImpl.java | 10 +- ...mpl.java => TableGenSliceElementImpl.java} | 16 +- ...pl.java => TableGenSliceElementsImpl.java} | 10 +- .../psi/impl/TableGenValueImpl.java | 6 + .../psi/impl/TableGenValueSuffixImpl.java | 6 + .../grammar/_TableGenLexer.flex | 8 +- .../tablegenintellij/grammar/tablegen.bnf | 44 ++- 26 files changed, 621 insertions(+), 409 deletions(-) create mode 100644 src/main/gen/cn/codetector/tablegenintellij/psi/TableGenAssertStmt.java create mode 100644 src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassStatement.java create mode 100644 src/main/gen/cn/codetector/tablegenintellij/psi/TableGenSliceElement.java create mode 100644 src/main/gen/cn/codetector/tablegenintellij/psi/TableGenSliceElements.java rename src/main/gen/cn/codetector/tablegenintellij/psi/impl/{TableGenMultiBodyImpl.java => TableGenAssertStmtImpl.java} (66%) rename src/main/gen/cn/codetector/tablegenintellij/psi/impl/{TableGenMultiBodyItemImpl.java => TableGenMultiClassStatementImpl.java} (56%) rename src/main/gen/cn/codetector/tablegenintellij/psi/impl/{TableGenMultiObjectBodyImpl.java => TableGenSliceElementImpl.java} (64%) rename src/main/gen/cn/codetector/tablegenintellij/psi/impl/{TableGenMultiBodyListImpl.java => TableGenSliceElementsImpl.java} (69%) diff --git a/src/main/gen/cn/codetector/tablegenintellij/grammar/_TableGenLexer.java b/src/main/gen/cn/codetector/tablegenintellij/grammar/_TableGenLexer.java index eef1245..3026a62 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/grammar/_TableGenLexer.java +++ b/src/main/gen/cn/codetector/tablegenintellij/grammar/_TableGenLexer.java @@ -55,10 +55,10 @@ public static int ZZ_CMAP(int ch) { /* The ZZ_CMAP_A table has 320 entries */ static final char ZZ_CMAP_A[] = zzUnpackCMap( - "\11\0\1\5\1\2\2\4\1\3\22\0\1\5\1\0\1\14\1\0\1\12\5\0\1\7\4\0\1\6\12\10\7\0"+ - "\32\11\1\17\1\15\1\22\1\0\1\11\1\0\1\33\1\13\1\31\1\23\1\24\1\25\1\34\1\40"+ - "\1\30\2\11\1\26\1\36\1\16\1\32\2\11\1\37\1\41\1\27\1\35\1\42\4\11\1\20\1\0"+ - "\1\21\7\0\1\1\242\0\2\1\26\0"); + "\11\0\1\5\1\2\2\4\1\3\22\0\1\5\1\23\1\14\1\0\1\12\5\0\1\7\4\0\1\6\12\10\7"+ + "\0\1\47\11\11\1\44\17\11\1\17\1\15\1\21\1\0\1\11\1\0\1\34\1\13\1\32\1\24\1"+ + "\25\1\26\1\35\1\41\1\31\2\11\1\27\1\37\1\16\1\33\2\11\1\40\1\42\1\30\1\36"+ + "\1\43\1\46\1\11\1\45\1\11\1\20\1\0\1\22\7\0\1\1\242\0\2\1\26\0"); /** * Translates DFA states to action switch labels. @@ -67,16 +67,16 @@ public static int ZZ_CMAP(int ch) { private static final String ZZ_ACTION_PACKED_0 = "\1\0\1\1\1\2\1\1\1\3\1\4\1\1\1\4"+ - "\2\1\11\4\1\5\1\0\1\6\1\4\1\0\1\7"+ - "\2\0\10\4\1\10\1\11\4\4\1\0\1\12\1\7"+ - "\1\0\1\13\1\14\3\4\1\15\2\4\1\16\5\4"+ - "\1\5\1\17\1\0\1\20\2\4\1\21\2\4\1\22"+ - "\1\23\2\4\1\24\2\4\1\0\2\4\1\25\2\4"+ - "\1\26\2\4\1\27\1\30\1\31\3\4\1\32\1\33"+ - "\1\34\3\4\1\35"; + "\2\1\1\5\12\4\1\6\1\0\1\7\1\4\1\0"+ + "\1\10\2\0\1\11\1\0\10\4\1\12\1\13\5\4"+ + "\1\0\1\14\1\10\1\0\1\15\1\16\3\4\1\17"+ + "\2\4\1\20\6\4\1\6\1\21\1\22\1\23\2\4"+ + "\1\24\2\4\1\25\1\26\2\4\1\27\5\4\1\30"+ + "\2\4\1\31\3\4\1\32\1\33\3\4\1\34\1\4"+ + "\1\35\1\36\6\4\1\37\3\4\1\40"; private static int [] zzUnpackAction() { - int [] result = new int[97]; + int [] result = new int[111]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -101,22 +101,23 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\43\0\106\0\151\0\214\0\257\0\322\0\365"+ - "\0\u0118\0\u013b\0\u015e\0\u0181\0\u01a4\0\u01c7\0\u01ea\0\u020d"+ - "\0\u0230\0\u0253\0\u0276\0\u0299\0\u02bc\0\u02df\0\u0302\0\u0118"+ - "\0\43\0\u0325\0\u0348\0\u036b\0\u038e\0\u03b1\0\u03d4\0\u03f7"+ - "\0\u041a\0\u043d\0\u0460\0\u0483\0\257\0\u04a6\0\u04c9\0\u04ec"+ - "\0\u050f\0\u0532\0\u0555\0\u0118\0\u0578\0\u059b\0\257\0\u05be"+ - "\0\u05e1\0\u0604\0\257\0\u0627\0\u064a\0\257\0\u066d\0\u0690"+ - "\0\u06b3\0\u06d6\0\u06f9\0\u02bc\0\257\0\u071c\0\257\0\u073f"+ - "\0\u0762\0\257\0\u0785\0\u07a8\0\257\0\257\0\u07cb\0\u07ee"+ - "\0\257\0\u0811\0\u0834\0\u0857\0\u087a\0\u089d\0\257\0\u08c0"+ - "\0\u08e3\0\257\0\u0906\0\u0929\0\43\0\257\0\257\0\u094c"+ - "\0\u096f\0\u0992\0\257\0\257\0\257\0\u09b5\0\u09d8\0\u09fb"+ - "\0\257"; + "\0\0\0\50\0\120\0\170\0\240\0\310\0\360\0\u0118"+ + "\0\u0140\0\u0168\0\u0190\0\u01b8\0\u01e0\0\u0208\0\u0230\0\u0258"+ + "\0\u0280\0\u02a8\0\u02d0\0\u02f8\0\u0320\0\u0348\0\u0370\0\u0398"+ + "\0\u03c0\0\u0140\0\50\0\u03e8\0\u0410\0\u0438\0\u0190\0\u0460"+ + "\0\u0488\0\u04b0\0\u04d8\0\u0500\0\u0528\0\u0550\0\u0578\0\u05a0"+ + "\0\310\0\u05c8\0\u05f0\0\u0618\0\u0640\0\u0668\0\u0690\0\u06b8"+ + "\0\u0140\0\u06e0\0\u0708\0\310\0\u0730\0\u0758\0\u0780\0\310"+ + "\0\u07a8\0\u07d0\0\310\0\u07f8\0\u0820\0\u0848\0\u0870\0\u0898"+ + "\0\u08c0\0\u0370\0\310\0\50\0\310\0\u08e8\0\u0910\0\310"+ + "\0\u0938\0\u0960\0\310\0\310\0\u0988\0\u09b0\0\310\0\u09d8"+ + "\0\u0a00\0\u0a28\0\u0a50\0\u0a78\0\310\0\u0aa0\0\u0ac8\0\310"+ + "\0\u0af0\0\u0b18\0\u0b40\0\310\0\310\0\u0b68\0\u0b90\0\u0bb8"+ + "\0\310\0\u0be0\0\310\0\310\0\u0c08\0\u0c30\0\u0c58\0\u0c80"+ + "\0\u0ca8\0\u0cd0\0\310\0\u0cf8\0\u0d20\0\u0d48\0\310"; private static int [] zzUnpackRowMap() { - int [] result = new int[97]; + int [] result = new int[111]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -141,91 +142,108 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { private static final String ZZ_TRANS_PACKED_0 = "\2\2\4\3\1\4\1\2\1\5\1\6\1\7\1\10"+ "\1\11\1\2\1\6\1\12\3\2\1\13\1\14\1\15"+ - "\1\16\1\17\1\20\1\21\4\6\1\22\2\6\1\23"+ - "\1\6\45\0\4\3\43\0\1\24\1\25\43\0\1\5"+ - "\1\6\1\0\1\6\2\0\1\6\4\0\20\6\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\20\6\11\0"+ - "\1\26\1\0\1\26\2\0\1\26\4\0\20\26\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\5\6\1\27"+ - "\12\6\2\30\2\0\10\30\1\31\1\32\25\30\20\0"+ - "\1\33\32\0\2\6\1\0\1\6\2\0\1\6\4\0"+ - "\1\6\1\34\6\6\1\35\7\6\10\0\2\6\1\0"+ - "\1\6\2\0\1\6\4\0\3\6\1\36\14\6\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\5\6\1\37"+ - "\1\6\1\40\10\6\10\0\2\6\1\0\1\6\2\0"+ - "\1\6\4\0\1\6\1\41\3\6\1\42\12\6\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\15\6\1\43"+ - "\2\6\10\0\2\6\1\0\1\6\2\0\1\44\4\0"+ - "\2\6\1\45\15\6\10\0\2\6\1\0\1\6\2\0"+ - "\1\6\4\0\3\6\1\46\3\6\1\47\10\6\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\12\6\1\50"+ - "\5\6\10\0\2\6\1\0\1\6\2\0\1\6\4\0"+ - "\4\6\1\51\13\6\1\24\4\0\36\24\1\25\1\0"+ - "\1\25\2\0\2\25\1\52\33\25\10\0\2\26\1\0"+ - "\1\26\2\0\1\26\4\0\20\26\10\0\2\6\1\0"+ - "\1\6\2\0\1\6\4\0\4\6\1\53\13\6\2\30"+ - "\2\0\10\30\1\54\1\32\25\30\43\55\10\0\2\6"+ - "\1\0\1\6\2\0\1\6\4\0\2\6\1\56\15\6"+ - "\10\0\2\6\1\0\1\6\2\0\1\6\4\0\11\6"+ - "\1\57\6\6\10\0\2\6\1\0\1\6\2\0\1\6"+ - "\4\0\16\6\1\60\1\6\10\0\2\6\1\0\1\6"+ - "\2\0\1\6\4\0\1\6\1\61\16\6\10\0\2\6"+ - "\1\0\1\6\2\0\1\6\4\0\14\6\1\62\3\6"+ - "\10\0\2\6\1\0\1\6\2\0\1\6\4\0\4\6"+ - "\1\63\13\6\10\0\2\6\1\0\1\6\2\0\1\6"+ - "\4\0\16\6\1\64\1\6\10\0\2\6\1\0\1\6"+ - "\2\0\1\6\4\0\1\6\1\65\16\6\10\0\2\6"+ - "\1\0\1\6\2\0\1\6\4\0\4\6\1\66\1\6"+ - "\1\67\11\6\10\0\2\6\1\0\1\6\2\0\1\6"+ - "\4\0\10\6\1\70\7\6\10\0\2\6\1\0\1\6"+ - "\2\0\1\6\4\0\1\71\17\6\10\0\2\6\1\0"+ - "\1\6\2\0\1\6\4\0\3\6\1\72\14\6\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\14\6\1\73"+ - "\3\6\1\25\1\0\1\25\2\0\1\25\1\74\1\52"+ - "\33\25\10\0\2\6\1\0\1\6\2\0\1\6\4\0"+ - "\16\6\1\75\1\6\21\0\1\76\31\0\2\6\1\0"+ - "\1\6\2\0\1\6\4\0\13\6\1\77\2\6\1\100"+ - "\1\101\10\0\2\6\1\0\1\6\2\0\1\6\4\0"+ - "\1\6\1\102\16\6\10\0\2\6\1\0\1\6\2\0"+ - "\1\6\4\0\3\6\1\103\14\6\10\0\2\6\1\0"+ - "\1\6\2\0\1\6\4\0\1\6\1\104\16\6\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\4\6\1\105"+ - "\13\6\10\0\2\6\1\0\1\6\2\0\1\106\4\0"+ - "\20\6\10\0\2\6\1\0\1\6\2\0\1\6\4\0"+ - "\3\6\1\107\14\6\10\0\2\6\1\0\1\6\2\0"+ - "\1\6\4\0\16\6\1\110\1\6\10\0\2\6\1\0"+ - "\1\6\2\0\1\6\4\0\1\6\1\111\16\6\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\4\6\1\112"+ - "\13\6\10\0\2\6\1\0\1\6\2\0\1\6\4\0"+ - "\5\6\1\113\12\6\21\0\1\114\1\76\30\0\2\6"+ - "\1\0\1\6\2\0\1\6\4\0\1\6\1\115\16\6"+ - "\10\0\2\6\1\0\1\6\2\0\1\6\4\0\10\6"+ - "\1\116\7\6\10\0\2\6\1\0\1\6\2\0\1\6"+ - "\4\0\1\117\17\6\10\0\2\6\1\0\1\6\2\0"+ - "\1\6\4\0\10\6\1\120\7\6\10\0\2\6\1\0"+ - "\1\6\2\0\1\6\4\0\12\6\1\121\5\6\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\16\6\1\122"+ - "\1\6\10\0\2\6\1\0\1\6\2\0\1\6\4\0"+ - "\5\6\1\123\12\6\10\0\2\6\1\0\1\6\2\0"+ - "\1\124\4\0\20\6\22\0\1\125\30\0\2\6\1\0"+ - "\1\6\2\0\1\6\4\0\4\6\1\126\13\6\10\0"+ - "\2\6\1\0\1\6\2\0\1\6\4\0\14\6\1\127"+ - "\3\6\10\0\2\6\1\0\1\6\2\0\1\6\4\0"+ - "\6\6\1\130\11\6\10\0\2\6\1\0\1\6\2\0"+ - "\1\6\4\0\1\131\17\6\10\0\2\6\1\0\1\6"+ - "\2\0\1\6\4\0\6\6\1\132\11\6\10\0\2\6"+ - "\1\0\1\6\2\0\1\6\4\0\11\6\1\133\6\6"+ - "\10\0\2\6\1\0\1\6\2\0\1\6\4\0\15\6"+ - "\1\134\2\6\10\0\2\6\1\0\1\6\2\0\1\6"+ - "\4\0\1\6\1\135\16\6\10\0\2\6\1\0\1\6"+ - "\2\0\1\6\4\0\3\6\1\136\14\6\10\0\2\6"+ - "\1\0\1\6\2\0\1\6\4\0\10\6\1\137\7\6"+ - "\10\0\2\6\1\0\1\6\2\0\1\6\4\0\16\6"+ - "\1\140\1\6\10\0\2\6\1\0\1\6\2\0\1\6"+ - "\4\0\16\6\1\141\1\6"; + "\1\16\1\17\1\20\1\21\1\22\4\6\1\23\2\6"+ + "\1\24\1\6\1\25\3\6\52\0\4\3\50\0\1\26"+ + "\1\27\50\0\1\5\1\6\1\0\1\6\2\0\1\6"+ + "\5\0\24\6\10\0\2\6\1\0\1\6\2\0\1\6"+ + "\5\0\24\6\11\0\1\30\1\0\1\30\2\0\1\30"+ + "\5\0\24\30\10\0\2\6\1\0\1\6\2\0\1\6"+ + "\5\0\5\6\1\31\16\6\2\32\2\0\10\32\1\33"+ + "\1\34\32\32\20\0\1\35\40\0\1\36\1\0\1\36"+ + "\2\0\1\36\4\0\1\37\24\36\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\1\6\1\40\6\6\1\41"+ + "\13\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\3\6\1\42\20\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\5\6\1\43\1\6\1\44\14\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\1\6\1\45"+ + "\3\6\1\46\16\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\15\6\1\47\6\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\50\5\0\2\6\1\51\21\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\3\6\1\52"+ + "\3\6\1\53\14\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\12\6\1\54\11\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\4\6\1\55\17\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\1\6\1\56"+ + "\22\6\1\26\4\0\43\26\1\27\1\0\1\27\2\0"+ + "\2\27\1\57\40\27\10\0\2\30\1\0\1\30\2\0"+ + "\1\30\5\0\24\30\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\4\6\1\60\17\6\2\32\2\0\10\32"+ + "\1\61\1\34\32\32\21\35\1\0\1\62\25\35\10\0"+ + "\2\36\1\0\1\36\2\0\1\36\5\0\24\36\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\2\6\1\63"+ + "\21\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\11\6\1\64\12\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\16\6\1\65\5\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\1\6\1\66\22\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\14\6\1\67"+ + "\7\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\4\6\1\70\17\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\16\6\1\71\5\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\1\6\1\72\22\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\4\6\1\73"+ + "\1\6\1\74\15\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\10\6\1\75\13\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\1\76\23\6\10\0\2\6"+ + "\1\0\1\6\2\0\1\6\5\0\3\6\1\77\20\6"+ + "\10\0\2\6\1\0\1\6\2\0\1\6\5\0\14\6"+ + "\1\100\7\6\10\0\2\6\1\0\1\6\2\0\1\6"+ + "\5\0\21\6\1\101\2\6\1\27\1\0\1\27\2\0"+ + "\1\27\1\102\1\57\40\27\10\0\2\6\1\0\1\6"+ + "\2\0\1\6\5\0\16\6\1\103\5\6\21\0\1\104"+ + "\36\0\2\6\1\0\1\6\2\0\1\6\5\0\13\6"+ + "\1\105\2\6\1\106\1\107\4\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\1\6\1\110\22\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\3\6\1\111"+ + "\20\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\1\6\1\112\22\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\4\6\1\113\17\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\114\5\0\24\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\3\6\1\115\20\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\16\6\1\116"+ + "\5\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\1\6\1\117\22\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\4\6\1\120\17\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\5\6\1\121\16\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\22\6\1\122"+ + "\1\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\1\6\1\123\22\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\10\6\1\124\13\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\1\125\23\6\10\0\2\6"+ + "\1\0\1\6\2\0\1\6\5\0\10\6\1\126\13\6"+ + "\10\0\2\6\1\0\1\6\2\0\1\6\5\0\12\6"+ + "\1\127\11\6\10\0\2\6\1\0\1\6\2\0\1\6"+ + "\5\0\16\6\1\130\5\6\10\0\2\6\1\0\1\6"+ + "\2\0\1\6\5\0\5\6\1\131\16\6\10\0\2\6"+ + "\1\0\1\6\2\0\1\132\5\0\24\6\10\0\2\6"+ + "\1\0\1\6\2\0\1\6\5\0\7\6\1\133\14\6"+ + "\10\0\2\6\1\0\1\6\2\0\1\6\5\0\4\6"+ + "\1\134\17\6\10\0\2\6\1\0\1\6\2\0\1\6"+ + "\5\0\14\6\1\135\7\6\10\0\2\6\1\0\1\6"+ + "\2\0\1\6\5\0\6\6\1\136\15\6\10\0\2\6"+ + "\1\0\1\6\2\0\1\6\5\0\1\137\23\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\6\6\1\140"+ + "\15\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\11\6\1\141\12\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\14\6\1\142\7\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\15\6\1\143\6\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\1\6\1\144"+ + "\22\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\3\6\1\145\20\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\1\146\23\6\10\0\2\6\1\0\1\6"+ + "\2\0\1\6\5\0\10\6\1\147\13\6\10\0\2\6"+ + "\1\0\1\6\2\0\1\6\5\0\23\6\1\150\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\16\6\1\151"+ + "\5\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\16\6\1\152\5\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\16\6\1\153\5\6\10\0\2\6\1\0"+ + "\1\6\2\0\1\6\5\0\16\6\1\154\5\6\10\0"+ + "\2\6\1\0\1\6\2\0\1\6\5\0\1\6\1\155"+ + "\22\6\10\0\2\6\1\0\1\6\2\0\1\6\5\0"+ + "\14\6\1\156\7\6\10\0\2\6\1\0\1\6\2\0"+ + "\1\6\5\0\4\6\1\157\17\6"; private static int [] zzUnpackTrans() { - int [] result = new int[2590]; + int [] result = new int[3440]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -263,12 +281,12 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\1\0\1\11\22\1\1\0\2\1\1\0\1\11\2\0"+ - "\16\1\1\0\2\1\1\0\20\1\1\0\15\1\1\0"+ - "\10\1\1\11\14\1"; + "\1\0\1\11\24\1\1\0\2\1\1\0\1\11\2\0"+ + "\1\1\1\0\17\1\1\0\2\1\1\0\21\1\1\11"+ + "\53\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[97]; + int [] result = new int[111]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -577,147 +595,162 @@ else if (zzAtEOF) { { return BAD_CHARACTER; } // fall through - case 30: break; + case 33: break; case 2: { return WHITE_SPACE; } // fall through - case 31: break; + case 34: break; case 3: { return DEC_INT; } // fall through - case 32: break; + case 35: break; case 4: { return IDENTIFIER; } // fall through - case 33: break; + case 36: break; case 5: - { return COMMENTS; + { return BANG_OPR; } // fall through - case 34: break; + case 37: break; case 6: - { return VARNAME; + { return COMMENTS; } // fall through - case 35: break; + case 38: break; case 7: - { return STRING; + { return VARNAME; } // fall through - case 36: break; + case 39: break; case 8: - { return KEYWORDIN; + { return STRING; } // fall through - case 37: break; + case 40: break; case 9: - { return KEYWORDIF; + { return CONDITION; } // fall through - case 38: break; + case 41: break; case 10: - { return KEYWORDBIT; + { return KEYWORDIN; } // fall through - case 39: break; + case 42: break; case 11: - { return KEYWORDDEF; + { return KEYWORDIF; } // fall through - case 40: break; + case 43: break; case 12: - { return KEYWORDDAG; + { return KEYWORDBIT; } // fall through - case 41: break; + case 44: break; case 13: - { return KEYWORDLET; + { return KEYWORDDEF; } // fall through - case 42: break; + case 45: break; case 14: - { return KEYWORDINT; + { return KEYWORDDAG; } // fall through - case 43: break; + case 46: break; case 15: - { return KEYWORDBITS; + { return KEYWORDLET; } // fall through - case 44: break; + case 47: break; case 16: - { return KEYWORDDEFM; + { return KEYWORDINT; } // fall through - case 45: break; + case 48: break; case 17: - { return KEYWORDELSE; + { return KEYWORDBITS; } // fall through - case 46: break; + case 49: break; case 18: - { return KEYWORDLIST; + { return CODE_FRAGMENT; } // fall through - case 47: break; + case 50: break; case 19: - { return KEYWORDTHEN; + { return KEYWORDDEFM; } // fall through - case 48: break; + case 51: break; case 20: - { return KEYWORDCODE; + { return KEYWORDELSE; } // fall through - case 49: break; + case 52: break; case 21: - { return KEYWORDFIELD; + { return KEYWORDLIST; } // fall through - case 50: break; + case 53: break; case 22: - { return KEYWORDCLASS; + { return KEYWORDTHEN; } // fall through - case 51: break; + case 54: break; case 23: - { return CODE_FRAGMENT; + { return KEYWORDCODE; } // fall through - case 52: break; + case 55: break; case 24: - { return KEYWORDDEFSET; + { return KEYWORDFIELD; } // fall through - case 53: break; + case 56: break; case 25: - { return KEYWORDDEFVAR; + { return KEYWORDCLASS; } // fall through - case 54: break; + case 57: break; case 26: - { return KEYWORDSTRING; + { return KEYWORDDEFSET; } // fall through - case 55: break; + case 58: break; case 27: - { return KEYWORDFOREACH; + { return KEYWORDDEFVAR; } // fall through - case 56: break; + case 59: break; case 28: - { return KEYWORDINCLUDE; + { return KEYWORDSTRING; } // fall through - case 57: break; + case 60: break; case 29: + { return KEYWORDFOREACH; + } + // fall through + case 61: break; + case 30: + { return KEYWORDINCLUDE; + } + // fall through + case 62: break; + case 31: { return KEYWORDMULTICLASS; } // fall through - case 58: break; + case 63: break; + case 32: + { return KEYWORDASSERT; + } + // fall through + case 64: break; default: zzScanError(ZZ_NO_MATCH); } diff --git a/src/main/gen/cn/codetector/tablegenintellij/parser/TableGenParser.java b/src/main/gen/cn/codetector/tablegenintellij/parser/TableGenParser.java index 2534ae8..aaee9d1 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/parser/TableGenParser.java +++ b/src/main/gen/cn/codetector/tablegenintellij/parser/TableGenParser.java @@ -35,6 +35,21 @@ static boolean parse_root_(IElementType t, PsiBuilder b, int l) { return tableGenFile(b, l + 1); } + /* ********************************************************** */ + // KeywordAssert CONDITION "," STRING ";" + public static boolean assertStmt(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "assertStmt")) return false; + if (!nextTokenIs(b, KEYWORDASSERT)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokens(b, 0, KEYWORDASSERT, CONDITION); + r = r && consumeToken(b, ","); + r = r && consumeToken(b, STRING); + r = r && consumeToken(b, ";"); + exit_section_(b, m, ASSERT_STMT, r); + return r; + } + /* ********************************************************** */ // (":" baseClassListNE)? public static boolean baseClassList(PsiBuilder b, int l) { @@ -60,11 +75,12 @@ private static boolean baseClassList_0(PsiBuilder b, int l) { // subClassRef ("," subClassRef)* public static boolean baseClassListNE(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "baseClassListNE")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; boolean r; - Marker m = enter_section_(b, l, _NONE_, BASE_CLASS_LIST_NE, ""); + Marker m = enter_section_(b); r = subClassRef(b, l + 1); r = r && baseClassListNE_1(b, l + 1); - exit_section_(b, l, m, r, false, null); + exit_section_(b, m, BASE_CLASS_LIST_NE, r); return r; } @@ -339,18 +355,27 @@ private static boolean decimalInteger_0(PsiBuilder b, int l) { } /* ********************************************************** */ - // type IDENTIFIER ("=" value)? + // (type | "code") IDENTIFIER ("=" value)? public static boolean declaration(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "declaration")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, DECLARATION, ""); - r = type(b, l + 1); + r = declaration_0(b, l + 1); r = r && consumeToken(b, IDENTIFIER); r = r && declaration_2(b, l + 1); exit_section_(b, l, m, r, false, null); return r; } + // type | "code" + private static boolean declaration_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "declaration_0")) return false; + boolean r; + r = type(b, l + 1); + if (!r) r = consumeToken(b, KEYWORDCODE); + return r; + } + // ("=" value)? private static boolean declaration_2(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "declaration_2")) return false; @@ -403,7 +428,7 @@ public static boolean defmID(PsiBuilder b, int l) { } /* ********************************************************** */ - // KeywordDefm [value] ":" baseClassListNE ";" + // KeywordDefm [value] baseClassList ";" public static boolean defmStmt(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "defmStmt")) return false; if (!nextTokenIs(b, KEYWORDDEFM)) return false; @@ -411,8 +436,7 @@ public static boolean defmStmt(PsiBuilder b, int l) { Marker m = enter_section_(b); r = consumeToken(b, KEYWORDDEFM); r = r && defmStmt_1(b, l + 1); - r = r && consumeToken(b, ":"); - r = r && baseClassListNE(b, l + 1); + r = r && baseClassList(b, l + 1); r = r && consumeToken(b, ";"); exit_section_(b, m, DEFM_STMT, r); return r; @@ -576,144 +600,35 @@ private static boolean letStmt_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // ";" | "{" multiBodyList "}" - public static boolean multiBody(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBody")) return false; - boolean r; - Marker m = enter_section_(b, l, _NONE_, MULTI_BODY, ""); - r = consumeToken(b, ";"); - if (!r) r = multiBody_1(b, l + 1); - exit_section_(b, l, m, r, false, null); - return r; - } - - // "{" multiBodyList "}" - private static boolean multiBody_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBody_1")) return false; + // IDENTIFIER + public static boolean multiClassID(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "multiClassID")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; boolean r; Marker m = enter_section_(b); - r = consumeToken(b, "{"); - r = r && multiBodyList(b, l + 1); - r = r && consumeToken(b, "}"); - exit_section_(b, m, null, r); + r = consumeToken(b, IDENTIFIER); + exit_section_(b, m, MULTI_CLASS_ID, r); return r; } /* ********************************************************** */ - // declaration ";" - // | KeywordLet IDENTIFIER [ "{" rangeList "}" ] "=" value ";" - // | KeywordField declaration ";" - // | KeywordDef value? objectBody - public static boolean multiBodyItem(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBodyItem")) return false; - boolean r; - Marker m = enter_section_(b, l, _NONE_, MULTI_BODY_ITEM, ""); - r = multiBodyItem_0(b, l + 1); - if (!r) r = multiBodyItem_1(b, l + 1); - if (!r) r = multiBodyItem_2(b, l + 1); - if (!r) r = multiBodyItem_3(b, l + 1); - exit_section_(b, l, m, r, false, null); - return r; - } - - // declaration ";" - private static boolean multiBodyItem_0(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBodyItem_0")) return false; - boolean r; - Marker m = enter_section_(b); - r = declaration(b, l + 1); - r = r && consumeToken(b, ";"); - exit_section_(b, m, null, r); - return r; - } - - // KeywordLet IDENTIFIER [ "{" rangeList "}" ] "=" value ";" - private static boolean multiBodyItem_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBodyItem_1")) return false; - boolean r; - Marker m = enter_section_(b); - r = consumeTokens(b, 0, KEYWORDLET, IDENTIFIER); - r = r && multiBodyItem_1_2(b, l + 1); - r = r && consumeToken(b, "="); - r = r && value(b, l + 1); - r = r && consumeToken(b, ";"); - exit_section_(b, m, null, r); - return r; - } - - // [ "{" rangeList "}" ] - private static boolean multiBodyItem_1_2(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBodyItem_1_2")) return false; - multiBodyItem_1_2_0(b, l + 1); - return true; - } - - // "{" rangeList "}" - private static boolean multiBodyItem_1_2_0(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBodyItem_1_2_0")) return false; + // assertStmt | defStmt | defmStmt | letStmt | defvarStmt + public static boolean multiClassStatement(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "multiClassStatement")) return false; boolean r; - Marker m = enter_section_(b); - r = consumeToken(b, "{"); - r = r && rangeList(b, l + 1); - r = r && consumeToken(b, "}"); - exit_section_(b, m, null, r); - return r; - } - - // KeywordField declaration ";" - private static boolean multiBodyItem_2(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBodyItem_2")) return false; - boolean r; - Marker m = enter_section_(b); - r = consumeToken(b, KEYWORDFIELD); - r = r && declaration(b, l + 1); - r = r && consumeToken(b, ";"); - exit_section_(b, m, null, r); - return r; - } - - // KeywordDef value? objectBody - private static boolean multiBodyItem_3(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBodyItem_3")) return false; - boolean r; - Marker m = enter_section_(b); - r = consumeToken(b, KEYWORDDEF); - r = r && multiBodyItem_3_1(b, l + 1); - r = r && objectBody(b, l + 1); - exit_section_(b, m, null, r); + Marker m = enter_section_(b, l, _NONE_, MULTI_CLASS_STATEMENT, ""); + r = assertStmt(b, l + 1); + if (!r) r = defStmt(b, l + 1); + if (!r) r = defmStmt(b, l + 1); + if (!r) r = letStmt(b, l + 1); + if (!r) r = defvarStmt(b, l + 1); + exit_section_(b, l, m, r, false, null); return r; } - // value? - private static boolean multiBodyItem_3_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBodyItem_3_1")) return false; - value(b, l + 1); - return true; - } - - /* ********************************************************** */ - // multiBodyItem* - public static boolean multiBodyList(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiBodyList")) return false; - Marker m = enter_section_(b, l, _NONE_, MULTI_BODY_LIST, ""); - while (true) { - int c = current_position_(b); - if (!multiBodyItem(b, l + 1)) break; - if (!empty_element_parsed_guard_(b, "multiBodyList", c)) break; - } - exit_section_(b, l, m, true, false, null); - return true; - } - /* ********************************************************** */ - public static boolean multiClassID(PsiBuilder b, int l) { - Marker m = enter_section_(b); - exit_section_(b, m, MULTI_CLASS_ID, true); - return true; - } - - /* ********************************************************** */ - // KeywordMultiClass IDENTIFIER templateArgList? multiObjectBody + // KeywordMultiClass IDENTIFIER templateArgList? baseClassList + // "{" multiClassStatement+ "}" public static boolean multiClassStmt(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "multiClassStmt")) return false; if (!nextTokenIs(b, KEYWORDMULTICLASS)) return false; @@ -721,7 +636,10 @@ public static boolean multiClassStmt(PsiBuilder b, int l) { Marker m = enter_section_(b); r = consumeTokens(b, 0, KEYWORDMULTICLASS, IDENTIFIER); r = r && multiClassStmt_2(b, l + 1); - r = r && multiObjectBody(b, l + 1); + r = r && baseClassList(b, l + 1); + r = r && consumeToken(b, "{"); + r = r && multiClassStmt_5(b, l + 1); + r = r && consumeToken(b, "}"); exit_section_(b, m, MULTI_CLASS_STMT, r); return r; } @@ -733,15 +651,18 @@ private static boolean multiClassStmt_2(PsiBuilder b, int l) { return true; } - /* ********************************************************** */ - // baseClassList multiBody - public static boolean multiObjectBody(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "multiObjectBody")) return false; + // multiClassStatement+ + private static boolean multiClassStmt_5(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "multiClassStmt_5")) return false; boolean r; - Marker m = enter_section_(b, l, _NONE_, MULTI_OBJECT_BODY, ""); - r = baseClassList(b, l + 1); - r = r && multiBody(b, l + 1); - exit_section_(b, l, m, r, false, null); + Marker m = enter_section_(b); + r = multiClassStatement(b, l + 1); + while (r) { + int c = current_position_(b); + if (!multiClassStatement(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "multiClassStmt_5", c)) break; + } + exit_section_(b, m, null, r); return r; } @@ -829,6 +750,7 @@ private static boolean rangeList_1_0(PsiBuilder b, int l) { /* ********************************************************** */ // integer '-' integer + // | integer '...' integer // | integer integer // | integer public static boolean rangePiece(PsiBuilder b, int l) { @@ -837,6 +759,7 @@ public static boolean rangePiece(PsiBuilder b, int l) { Marker m = enter_section_(b, l, _NONE_, RANGE_PIECE, ""); r = rangePiece_0(b, l + 1); if (!r) r = rangePiece_1(b, l + 1); + if (!r) r = rangePiece_2(b, l + 1); if (!r) r = integer(b, l + 1); exit_section_(b, l, m, r, false, null); return r; @@ -854,12 +777,24 @@ private static boolean rangePiece_0(PsiBuilder b, int l) { return r; } - // integer integer + // integer '...' integer private static boolean rangePiece_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "rangePiece_1")) return false; boolean r; Marker m = enter_section_(b); r = integer(b, l + 1); + r = r && consumeToken(b, "..."); + r = r && integer(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // integer integer + private static boolean rangePiece_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "rangePiece_2")) return false; + boolean r; + Marker m = enter_section_(b); + r = integer(b, l + 1); r = r && integer(b, l + 1); exit_section_(b, m, null, r); return r; @@ -873,7 +808,7 @@ private static boolean rangePiece_1(PsiBuilder b, int l) { // | classID '<' valueListNE '>' // | '[' valueList ']' ("<" type ">")? // | "(" dagArg dagArgList? ")" - // // TODO BANG Operator + // | BANG_OPR IDENTIFIER // | integer // | IDENTIFIER public static boolean simpleValue(PsiBuilder b, int l) { @@ -887,6 +822,7 @@ public static boolean simpleValue(PsiBuilder b, int l) { if (!r) r = simpleValue_4(b, l + 1); if (!r) r = simpleValue_5(b, l + 1); if (!r) r = simpleValue_6(b, l + 1); + if (!r) r = parseTokens(b, 0, BANG_OPR, IDENTIFIER); if (!r) r = integer(b, l + 1); if (!r) r = consumeToken(b, IDENTIFIER); exit_section_(b, l, m, r, false, null); @@ -970,15 +906,110 @@ private static boolean simpleValue_6_2(PsiBuilder b, int l) { return true; } + /* ********************************************************** */ + // value + // | value "..." value + // | value "-" value + // | value integer + public static boolean sliceElement(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "sliceElement")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, SLICE_ELEMENT, ""); + r = value(b, l + 1); + if (!r) r = sliceElement_1(b, l + 1); + if (!r) r = sliceElement_2(b, l + 1); + if (!r) r = sliceElement_3(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // value "..." value + private static boolean sliceElement_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "sliceElement_1")) return false; + boolean r; + Marker m = enter_section_(b); + r = value(b, l + 1); + r = r && consumeToken(b, "..."); + r = r && value(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // value "-" value + private static boolean sliceElement_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "sliceElement_2")) return false; + boolean r; + Marker m = enter_section_(b); + r = value(b, l + 1); + r = r && consumeToken(b, "-"); + r = r && value(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // value integer + private static boolean sliceElement_3(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "sliceElement_3")) return false; + boolean r; + Marker m = enter_section_(b); + r = value(b, l + 1); + r = r && integer(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // (sliceElement ",")* sliceElement ","? + public static boolean sliceElements(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "sliceElements")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, SLICE_ELEMENTS, ""); + r = sliceElements_0(b, l + 1); + r = r && sliceElement(b, l + 1); + r = r && sliceElements_2(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // (sliceElement ",")* + private static boolean sliceElements_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "sliceElements_0")) return false; + while (true) { + int c = current_position_(b); + if (!sliceElements_0_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "sliceElements_0", c)) break; + } + return true; + } + + // sliceElement "," + private static boolean sliceElements_0_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "sliceElements_0_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = sliceElement(b, l + 1); + r = r && consumeToken(b, ","); + exit_section_(b, m, null, r); + return r; + } + + // ","? + private static boolean sliceElements_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "sliceElements_2")) return false; + consumeToken(b, ","); + return true; + } + /* ********************************************************** */ // (classID | multiClassID) ("<" valueList ">")? public static boolean subClassRef(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "subClassRef")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; boolean r; - Marker m = enter_section_(b, l, _NONE_, SUB_CLASS_REF, ""); + Marker m = enter_section_(b); r = subClassRef_0(b, l + 1); r = r && subClassRef_1(b, l + 1); - exit_section_(b, l, m, r, false, null); + exit_section_(b, m, SUB_CLASS_REF, r); return r; } @@ -1107,13 +1138,14 @@ private static boolean type_6(PsiBuilder b, int l) { } /* ********************************************************** */ - // simpleValue valueSuffix* + // simpleValue valueSuffix* ( "#" value )* public static boolean value(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "value")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, VALUE, ""); r = simpleValue(b, l + 1); r = r && value_1(b, l + 1); + r = r && value_2(b, l + 1); exit_section_(b, l, m, r, false, null); return r; } @@ -1129,6 +1161,28 @@ private static boolean value_1(PsiBuilder b, int l) { return true; } + // ( "#" value )* + private static boolean value_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "value_2")) return false; + while (true) { + int c = current_position_(b); + if (!value_2_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "value_2", c)) break; + } + return true; + } + + // "#" value + private static boolean value_2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "value_2_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, "#"); + r = r && value(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + /* ********************************************************** */ // valueListNE? public static boolean valueList(PsiBuilder b, int l) { @@ -1175,7 +1229,7 @@ private static boolean valueListNE_1_0(PsiBuilder b, int l) { /* ********************************************************** */ // '{' rangeList '}' - // | '[' rangeList ']' + // | '[' sliceElements ']' // | '.' IDENTIFIER public static boolean valueSuffix(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "valueSuffix")) return false; @@ -1200,13 +1254,13 @@ private static boolean valueSuffix_0(PsiBuilder b, int l) { return r; } - // '[' rangeList ']' + // '[' sliceElements ']' private static boolean valueSuffix_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "valueSuffix_1")) return false; boolean r; Marker m = enter_section_(b); r = consumeToken(b, "["); - r = r && rangeList(b, l + 1); + r = r && sliceElements(b, l + 1); r = r && consumeToken(b, "]"); exit_section_(b, m, null, r); return r; diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenAssertStmt.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenAssertStmt.java new file mode 100644 index 0000000..eb51867 --- /dev/null +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenAssertStmt.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package cn.codetector.tablegenintellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TableGenAssertStmt extends PsiElement { + + @NotNull + PsiElement getCondition(); + + @NotNull + PsiElement getString(); + +} diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenDeclaration.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenDeclaration.java index 7837a01..9d6e687 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenDeclaration.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenDeclaration.java @@ -7,7 +7,7 @@ public interface TableGenDeclaration extends PsiElement { - @NotNull + @Nullable TableGenType getType(); @Nullable diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenDefmStmt.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenDefmStmt.java index 473d801..0b551f9 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenDefmStmt.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenDefmStmt.java @@ -8,7 +8,7 @@ public interface TableGenDefmStmt extends PsiElement { @NotNull - TableGenBaseClassListNE getBaseClassListNE(); + TableGenBaseClassList getBaseClassList(); @Nullable TableGenValue getValue(); diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassID.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassID.java index f208cf9..de89bcf 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassID.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassID.java @@ -7,4 +7,7 @@ public interface TableGenMultiClassID extends PsiElement { + @NotNull + PsiElement getIdentifier(); + } diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassStatement.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassStatement.java new file mode 100644 index 0000000..9fd4509 --- /dev/null +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassStatement.java @@ -0,0 +1,25 @@ +// This is a generated file. Not intended for manual editing. +package cn.codetector.tablegenintellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TableGenMultiClassStatement extends PsiElement { + + @Nullable + TableGenAssertStmt getAssertStmt(); + + @Nullable + TableGenDefStmt getDefStmt(); + + @Nullable + TableGenDefmStmt getDefmStmt(); + + @Nullable + TableGenDefvarStmt getDefvarStmt(); + + @Nullable + TableGenLetStmt getLetStmt(); + +} diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassStmt.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassStmt.java index 6189395..57ba097 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassStmt.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenMultiClassStmt.java @@ -8,7 +8,10 @@ public interface TableGenMultiClassStmt extends PsiElement { @NotNull - TableGenMultiObjectBody getMultiObjectBody(); + TableGenBaseClassList getBaseClassList(); + + @NotNull + List getMultiClassStatementList(); @Nullable TableGenTemplateArgList getTemplateArgList(); diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenSliceElement.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenSliceElement.java new file mode 100644 index 0000000..80f63f4 --- /dev/null +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenSliceElement.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package cn.codetector.tablegenintellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TableGenSliceElement extends PsiElement { + + @Nullable + TableGenInteger getInteger(); + + @NotNull + List getValueList(); + +} diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenSliceElements.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenSliceElements.java new file mode 100644 index 0000000..890adbe --- /dev/null +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenSliceElements.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package cn.codetector.tablegenintellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TableGenSliceElements extends PsiElement { + + @NotNull + List getSliceElementList(); + +} diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenTypes.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenTypes.java index caa11be..abd339c 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenTypes.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenTypes.java @@ -8,6 +8,7 @@ public interface TableGenTypes { + IElementType ASSERT_STMT = new TableGenElementType("ASSERT_STMT"); IElementType BASE_CLASS_LIST = new TableGenElementType("BASE_CLASS_LIST"); IElementType BASE_CLASS_LIST_NE = new TableGenElementType("BASE_CLASS_LIST_NE"); IElementType BINARY_INT = new TableGenElementType("BINARY_INT"); @@ -29,16 +30,15 @@ public interface TableGenTypes { IElementType LET_ITEM = new TableGenElementType("LET_ITEM"); IElementType LET_LIST = new TableGenElementType("LET_LIST"); IElementType LET_STMT = new TableGenElementType("LET_STMT"); - IElementType MULTI_BODY = new TableGenElementType("MULTI_BODY"); - IElementType MULTI_BODY_ITEM = new TableGenElementType("MULTI_BODY_ITEM"); - IElementType MULTI_BODY_LIST = new TableGenElementType("MULTI_BODY_LIST"); IElementType MULTI_CLASS_ID = new TableGenElementType("MULTI_CLASS_ID"); + IElementType MULTI_CLASS_STATEMENT = new TableGenElementType("MULTI_CLASS_STATEMENT"); IElementType MULTI_CLASS_STMT = new TableGenElementType("MULTI_CLASS_STMT"); - IElementType MULTI_OBJECT_BODY = new TableGenElementType("MULTI_OBJECT_BODY"); IElementType OBJECT_BODY = new TableGenElementType("OBJECT_BODY"); IElementType RANGE_LIST = new TableGenElementType("RANGE_LIST"); IElementType RANGE_PIECE = new TableGenElementType("RANGE_PIECE"); IElementType SIMPLE_VALUE = new TableGenElementType("SIMPLE_VALUE"); + IElementType SLICE_ELEMENT = new TableGenElementType("SLICE_ELEMENT"); + IElementType SLICE_ELEMENTS = new TableGenElementType("SLICE_ELEMENTS"); IElementType SUB_CLASS_REF = new TableGenElementType("SUB_CLASS_REF"); IElementType TEMPLATE_ARG_LIST = new TableGenElementType("TEMPLATE_ARG_LIST"); IElementType TYPE = new TableGenElementType("TYPE"); @@ -47,12 +47,15 @@ public interface TableGenTypes { IElementType VALUE_LIST_NE = new TableGenElementType("VALUE_LIST_NE"); IElementType VALUE_SUFFIX = new TableGenElementType("VALUE_SUFFIX"); + IElementType BANG_OPR = new TableGenTokenType("!"); IElementType BIN_INT = new TableGenTokenType("BIN_INT"); IElementType CODE_FRAGMENT = new TableGenTokenType("CODE_FRAGMENT"); IElementType COMMENTS = new TableGenTokenType("COMMENTS"); + IElementType CONDITION = new TableGenTokenType("CONDITION"); IElementType DEC_INT = new TableGenTokenType("DEC_INT"); IElementType HEX_INT = new TableGenTokenType("HEX_INT"); IElementType IDENTIFIER = new TableGenTokenType("IDENTIFIER"); + IElementType KEYWORDASSERT = new TableGenTokenType("KeywordAssert"); IElementType KEYWORDBIT = new TableGenTokenType("bit"); IElementType KEYWORDBITS = new TableGenTokenType("bits"); IElementType KEYWORDCLASS = new TableGenTokenType("class"); @@ -80,7 +83,10 @@ public interface TableGenTypes { class Factory { public static PsiElement createElement(ASTNode node) { IElementType type = node.getElementType(); - if (type == BASE_CLASS_LIST) { + if (type == ASSERT_STMT) { + return new TableGenAssertStmtImpl(node); + } + else if (type == BASE_CLASS_LIST) { return new TableGenBaseClassListImpl(node); } else if (type == BASE_CLASS_LIST_NE) { @@ -143,24 +149,15 @@ else if (type == LET_LIST) { else if (type == LET_STMT) { return new TableGenLetStmtImpl(node); } - else if (type == MULTI_BODY) { - return new TableGenMultiBodyImpl(node); - } - else if (type == MULTI_BODY_ITEM) { - return new TableGenMultiBodyItemImpl(node); - } - else if (type == MULTI_BODY_LIST) { - return new TableGenMultiBodyListImpl(node); - } else if (type == MULTI_CLASS_ID) { return new TableGenMultiClassIDImpl(node); } + else if (type == MULTI_CLASS_STATEMENT) { + return new TableGenMultiClassStatementImpl(node); + } else if (type == MULTI_CLASS_STMT) { return new TableGenMultiClassStmtImpl(node); } - else if (type == MULTI_OBJECT_BODY) { - return new TableGenMultiObjectBodyImpl(node); - } else if (type == OBJECT_BODY) { return new TableGenObjectBodyImpl(node); } @@ -173,6 +170,12 @@ else if (type == RANGE_PIECE) { else if (type == SIMPLE_VALUE) { return new TableGenSimpleValueImpl(node); } + else if (type == SLICE_ELEMENT) { + return new TableGenSliceElementImpl(node); + } + else if (type == SLICE_ELEMENTS) { + return new TableGenSliceElementsImpl(node); + } else if (type == SUB_CLASS_REF) { return new TableGenSubClassRefImpl(node); } diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenValue.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenValue.java index 9dc0a9f..21a1ffd 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenValue.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenValue.java @@ -10,6 +10,9 @@ public interface TableGenValue extends PsiElement { @NotNull TableGenSimpleValue getSimpleValue(); + @NotNull + List getValueList(); + @NotNull List getValueSuffixList(); diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenValueSuffix.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenValueSuffix.java index 4370c73..995884d 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenValueSuffix.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenValueSuffix.java @@ -10,6 +10,9 @@ public interface TableGenValueSuffix extends PsiElement { @Nullable TableGenRangeList getRangeList(); + @Nullable + TableGenSliceElements getSliceElements(); + @Nullable PsiElement getIdentifier(); diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenVisitor.java b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenVisitor.java index 7e44a3f..3455370 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenVisitor.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/TableGenVisitor.java @@ -7,6 +7,10 @@ public class TableGenVisitor extends PsiElementVisitor { + public void visitAssertStmt(@NotNull TableGenAssertStmt o) { + visitPsiElement(o); + } + public void visitBaseClassList(@NotNull TableGenBaseClassList o) { visitPsiElement(o); } @@ -91,43 +95,39 @@ public void visitLetStmt(@NotNull TableGenLetStmt o) { visitPsiElement(o); } - public void visitMultiBody(@NotNull TableGenMultiBody o) { - visitPsiElement(o); - } - - public void visitMultiBodyItem(@NotNull TableGenMultiBodyItem o) { + public void visitMultiClassID(@NotNull TableGenMultiClassID o) { visitPsiElement(o); } - public void visitMultiBodyList(@NotNull TableGenMultiBodyList o) { + public void visitMultiClassStatement(@NotNull TableGenMultiClassStatement o) { visitPsiElement(o); } - public void visitMultiClassID(@NotNull TableGenMultiClassID o) { + public void visitMultiClassStmt(@NotNull TableGenMultiClassStmt o) { visitPsiElement(o); } - public void visitMultiClassStmt(@NotNull TableGenMultiClassStmt o) { + public void visitObjectBody(@NotNull TableGenObjectBody o) { visitPsiElement(o); } - public void visitMultiObjectBody(@NotNull TableGenMultiObjectBody o) { + public void visitRangeList(@NotNull TableGenRangeList o) { visitPsiElement(o); } - public void visitObjectBody(@NotNull TableGenObjectBody o) { + public void visitRangePiece(@NotNull TableGenRangePiece o) { visitPsiElement(o); } - public void visitRangeList(@NotNull TableGenRangeList o) { + public void visitSimpleValue(@NotNull TableGenSimpleValue o) { visitPsiElement(o); } - public void visitRangePiece(@NotNull TableGenRangePiece o) { + public void visitSliceElement(@NotNull TableGenSliceElement o) { visitPsiElement(o); } - public void visitSimpleValue(@NotNull TableGenSimpleValue o) { + public void visitSliceElements(@NotNull TableGenSliceElements o) { visitPsiElement(o); } diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiBodyImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenAssertStmtImpl.java similarity index 66% rename from src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiBodyImpl.java rename to src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenAssertStmtImpl.java index da4e323..cb659fe 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiBodyImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenAssertStmtImpl.java @@ -11,14 +11,14 @@ import com.intellij.extapi.psi.ASTWrapperPsiElement; import cn.codetector.tablegenintellij.psi.*; -public class TableGenMultiBodyImpl extends ASTWrapperPsiElement implements TableGenMultiBody { +public class TableGenAssertStmtImpl extends ASTWrapperPsiElement implements TableGenAssertStmt { - public TableGenMultiBodyImpl(@NotNull ASTNode node) { + public TableGenAssertStmtImpl(@NotNull ASTNode node) { super(node); } public void accept(@NotNull TableGenVisitor visitor) { - visitor.visitMultiBody(this); + visitor.visitAssertStmt(this); } @Override @@ -28,9 +28,15 @@ public void accept(@NotNull PsiElementVisitor visitor) { } @Override - @Nullable - public TableGenMultiBodyList getMultiBodyList() { - return findChildByClass(TableGenMultiBodyList.class); + @NotNull + public PsiElement getCondition() { + return findNotNullChildByType(CONDITION); + } + + @Override + @NotNull + public PsiElement getString() { + return findNotNullChildByType(STRING); } } diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenDeclarationImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenDeclarationImpl.java index 8765b18..9de70b8 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenDeclarationImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenDeclarationImpl.java @@ -28,9 +28,9 @@ public void accept(@NotNull PsiElementVisitor visitor) { } @Override - @NotNull + @Nullable public TableGenType getType() { - return findNotNullChildByClass(TableGenType.class); + return findChildByClass(TableGenType.class); } @Override diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenDefmStmtImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenDefmStmtImpl.java index 93e6003..8cb63ac 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenDefmStmtImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenDefmStmtImpl.java @@ -29,8 +29,8 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @NotNull - public TableGenBaseClassListNE getBaseClassListNE() { - return findNotNullChildByClass(TableGenBaseClassListNE.class); + public TableGenBaseClassList getBaseClassList() { + return findNotNullChildByClass(TableGenBaseClassList.class); } @Override diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassIDImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassIDImpl.java index beb836f..ad150dd 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassIDImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassIDImpl.java @@ -27,4 +27,10 @@ public void accept(@NotNull PsiElementVisitor visitor) { else super.accept(visitor); } + @Override + @NotNull + public PsiElement getIdentifier() { + return findNotNullChildByType(IDENTIFIER); + } + } diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiBodyItemImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassStatementImpl.java similarity index 56% rename from src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiBodyItemImpl.java rename to src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassStatementImpl.java index 6c4097f..a1f1149 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiBodyItemImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassStatementImpl.java @@ -11,14 +11,14 @@ import com.intellij.extapi.psi.ASTWrapperPsiElement; import cn.codetector.tablegenintellij.psi.*; -public class TableGenMultiBodyItemImpl extends ASTWrapperPsiElement implements TableGenMultiBodyItem { +public class TableGenMultiClassStatementImpl extends ASTWrapperPsiElement implements TableGenMultiClassStatement { - public TableGenMultiBodyItemImpl(@NotNull ASTNode node) { + public TableGenMultiClassStatementImpl(@NotNull ASTNode node) { super(node); } public void accept(@NotNull TableGenVisitor visitor) { - visitor.visitMultiBodyItem(this); + visitor.visitMultiClassStatement(this); } @Override @@ -29,32 +29,32 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @Nullable - public TableGenDeclaration getDeclaration() { - return findChildByClass(TableGenDeclaration.class); + public TableGenAssertStmt getAssertStmt() { + return findChildByClass(TableGenAssertStmt.class); } @Override @Nullable - public TableGenObjectBody getObjectBody() { - return findChildByClass(TableGenObjectBody.class); + public TableGenDefStmt getDefStmt() { + return findChildByClass(TableGenDefStmt.class); } @Override @Nullable - public TableGenRangeList getRangeList() { - return findChildByClass(TableGenRangeList.class); + public TableGenDefmStmt getDefmStmt() { + return findChildByClass(TableGenDefmStmt.class); } @Override @Nullable - public TableGenValue getValue() { - return findChildByClass(TableGenValue.class); + public TableGenDefvarStmt getDefvarStmt() { + return findChildByClass(TableGenDefvarStmt.class); } @Override @Nullable - public PsiElement getIdentifier() { - return findChildByType(IDENTIFIER); + public TableGenLetStmt getLetStmt() { + return findChildByClass(TableGenLetStmt.class); } } diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassStmtImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassStmtImpl.java index a850c95..503df34 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassStmtImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiClassStmtImpl.java @@ -29,8 +29,14 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @NotNull - public TableGenMultiObjectBody getMultiObjectBody() { - return findNotNullChildByClass(TableGenMultiObjectBody.class); + public TableGenBaseClassList getBaseClassList() { + return findNotNullChildByClass(TableGenBaseClassList.class); + } + + @Override + @NotNull + public List getMultiClassStatementList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TableGenMultiClassStatement.class); } @Override diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiObjectBodyImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenSliceElementImpl.java similarity index 64% rename from src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiObjectBodyImpl.java rename to src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenSliceElementImpl.java index 34eaa80..bd817e1 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiObjectBodyImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenSliceElementImpl.java @@ -11,14 +11,14 @@ import com.intellij.extapi.psi.ASTWrapperPsiElement; import cn.codetector.tablegenintellij.psi.*; -public class TableGenMultiObjectBodyImpl extends ASTWrapperPsiElement implements TableGenMultiObjectBody { +public class TableGenSliceElementImpl extends ASTWrapperPsiElement implements TableGenSliceElement { - public TableGenMultiObjectBodyImpl(@NotNull ASTNode node) { + public TableGenSliceElementImpl(@NotNull ASTNode node) { super(node); } public void accept(@NotNull TableGenVisitor visitor) { - visitor.visitMultiObjectBody(this); + visitor.visitSliceElement(this); } @Override @@ -28,15 +28,15 @@ public void accept(@NotNull PsiElementVisitor visitor) { } @Override - @NotNull - public TableGenBaseClassList getBaseClassList() { - return findNotNullChildByClass(TableGenBaseClassList.class); + @Nullable + public TableGenInteger getInteger() { + return findChildByClass(TableGenInteger.class); } @Override @NotNull - public TableGenMultiBody getMultiBody() { - return findNotNullChildByClass(TableGenMultiBody.class); + public List getValueList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TableGenValue.class); } } diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiBodyListImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenSliceElementsImpl.java similarity index 69% rename from src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiBodyListImpl.java rename to src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenSliceElementsImpl.java index b07bd9a..fb46494 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenMultiBodyListImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenSliceElementsImpl.java @@ -11,14 +11,14 @@ import com.intellij.extapi.psi.ASTWrapperPsiElement; import cn.codetector.tablegenintellij.psi.*; -public class TableGenMultiBodyListImpl extends ASTWrapperPsiElement implements TableGenMultiBodyList { +public class TableGenSliceElementsImpl extends ASTWrapperPsiElement implements TableGenSliceElements { - public TableGenMultiBodyListImpl(@NotNull ASTNode node) { + public TableGenSliceElementsImpl(@NotNull ASTNode node) { super(node); } public void accept(@NotNull TableGenVisitor visitor) { - visitor.visitMultiBodyList(this); + visitor.visitSliceElements(this); } @Override @@ -29,8 +29,8 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @NotNull - public List getMultiBodyItemList() { - return PsiTreeUtil.getChildrenOfTypeAsList(this, TableGenMultiBodyItem.class); + public List getSliceElementList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TableGenSliceElement.class); } } diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenValueImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenValueImpl.java index a9bab13..f4d122d 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenValueImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenValueImpl.java @@ -33,6 +33,12 @@ public TableGenSimpleValue getSimpleValue() { return findNotNullChildByClass(TableGenSimpleValue.class); } + @Override + @NotNull + public List getValueList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TableGenValue.class); + } + @Override @NotNull public List getValueSuffixList() { diff --git a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenValueSuffixImpl.java b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenValueSuffixImpl.java index 76c456f..63ff239 100644 --- a/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenValueSuffixImpl.java +++ b/src/main/gen/cn/codetector/tablegenintellij/psi/impl/TableGenValueSuffixImpl.java @@ -33,6 +33,12 @@ public TableGenRangeList getRangeList() { return findChildByClass(TableGenRangeList.class); } + @Override + @Nullable + public TableGenSliceElements getSliceElements() { + return findChildByClass(TableGenSliceElements.class); + } + @Override @Nullable public PsiElement getIdentifier() { diff --git a/src/main/resources/cn/codetector/tablegenintellij/grammar/_TableGenLexer.flex b/src/main/resources/cn/codetector/tablegenintellij/grammar/_TableGenLexer.flex index 75e6073..73b3887 100644 --- a/src/main/resources/cn/codetector/tablegenintellij/grammar/_TableGenLexer.flex +++ b/src/main/resources/cn/codetector/tablegenintellij/grammar/_TableGenLexer.flex @@ -27,14 +27,15 @@ WHITE_SPACE=\s+ LINE_BREAK=[\r\n] WHITE_SPACE=[ \t\n\x0B\f\r]+ -COMMENTS=("//".*)|("/"\*(.|\n)*\*"/") +COMMENTS=("//".*?|"/"\*(.|\n)*?\*"/") IDENTIFIER=[0-9]*[a-zA-Z_]([a-zA-Z_]|[0-9])* VARNAME=[$][a-zA-Z_]([a-zA-Z_]|[0-9])* BIN_INT=0b[0-1]+ HEX_INT=0x[0-9a-fA-F]+ DEC_INT=[0-9]+ STRING=\"([^\n\r\"]|\\n|\\\")*\" -CODE_FRAGMENT=\[\{([^]}]*)}] +CODE_FRAGMENT=\[\{([^}\]]*)}] +CONDITION=[!]*[a-zA-Z_][a-zA-Z_0-9]* %% { @@ -61,6 +62,8 @@ CODE_FRAGMENT=\[\{([^]}]*)}] "bit" { return KEYWORDBIT; } "bits" { return KEYWORDBITS; } "multiclass" { return KEYWORDMULTICLASS; } + "!" { return BANG_OPR; } + "KeywordAssert" { return KEYWORDASSERT; } {LINE_BREAK} { return LINE_BREAK; } {WHITE_SPACE} { return WHITE_SPACE; } @@ -72,6 +75,7 @@ CODE_FRAGMENT=\[\{([^]}]*)}] {DEC_INT} { return DEC_INT; } {STRING} { return STRING; } {CODE_FRAGMENT} { return CODE_FRAGMENT; } + {CONDITION} { return CONDITION; } } diff --git a/src/main/resources/cn/codetector/tablegenintellij/grammar/tablegen.bnf b/src/main/resources/cn/codetector/tablegenintellij/grammar/tablegen.bnf index 3541b25..d1ed633 100644 --- a/src/main/resources/cn/codetector/tablegenintellij/grammar/tablegen.bnf +++ b/src/main/resources/cn/codetector/tablegenintellij/grammar/tablegen.bnf @@ -46,8 +46,9 @@ KeywordBits="bits" KeywordMultiClass="multiclass" - COMMENTS="regexp:(//.*)|(/\*(.|\n)*\*/)" + COMMENTS="regexp:(//.*?|/\*(.|\n)*?\*/)" IDENTIFIER="regexp:[0-9]*[a-zA-Z_]([a-zA-Z_]|[0-9])*" + BANG_OPR="!" VARNAME="regexp:[$][a-zA-Z_]([a-zA-Z_]|[0-9])*" BIN_INT="regexp:0b[0-1]+" @@ -55,10 +56,11 @@ DEC_INT="regexp:[0-9]+" STRING='regexp:"([^\n\r"]|\\n|\\")*"' - CODE_FRAGMENT='regexp:\[\{([^]}]*)}]' + CODE_FRAGMENT='regexp:\[\{([^}\]]*)}]' + // todo: fix condition + CONDITION='regexp:[!]*[a-zA-Z_][a-zA-Z_0-9]*' ] } - tableGenFile ::= object* private object ::= !<> (classStmt | multiClassStmt | defStmt | defmStmt | includeDirective | letStmt | defvarStmt) {pin=3} @@ -67,10 +69,16 @@ binaryInt ::= BIN_INT decimalInteger ::= ["-"] DEC_INT integer ::= binaryInt | decimalInteger | HEX_INT -value ::= simpleValue valueSuffix* +value ::= simpleValue valueSuffix* ( "#" value )* + valueSuffix ::= '{' rangeList '}' - | '[' rangeList ']' + | '[' sliceElements ']' | '.' IDENTIFIER +sliceElements ::= (sliceElement ",")* sliceElement ","? +sliceElement ::= value + | value "..." value + | value "-" value + | value integer simpleValue ::= CODE_FRAGMENT | STRING | '?' @@ -78,7 +86,7 @@ simpleValue ::= CODE_FRAGMENT | classID '<' valueListNE '>' | '[' valueList ']' ("<" type ">")? | "(" dagArg dagArgList? ")" - // TODO BANG Operator + | BANG_OPR IDENTIFIER | integer | IDENTIFIER @@ -90,6 +98,7 @@ valueListNE ::= value ("," value)* rangeList ::= rangePiece (',' rangePiece)* rangePiece ::= integer '-' integer + | integer '...' integer | integer integer | integer @@ -104,21 +113,16 @@ type ::= KeywordString | KeywordCode | KeywordBit | KeywordInt | KeywordList "<" type ">" | classID classID ::= IDENTIFIER -multiClassID ::= // TODO +multiClassID ::= IDENTIFIER classStmt ::= KeywordClass IDENTIFIER templateArgList? objectBody templateArgList ::= "<" declaration ("," declaration)* ">" -declaration ::= type IDENTIFIER ("=" value)? - -multiClassStmt ::= KeywordMultiClass IDENTIFIER templateArgList? multiObjectBody -multiObjectBody ::= baseClassList multiBody -multiBody ::= ";" | "{" multiBodyList "}" -multiBodyList ::= multiBodyItem* -multiBodyItem ::= declaration ";" - | KeywordLet IDENTIFIER [ "{" rangeList "}" ] "=" value ";" - | KeywordField declaration ";" - | KeywordDef value? objectBody +declaration ::= (type | "code") IDENTIFIER ("=" value)? +multiClassStmt ::= KeywordMultiClass IDENTIFIER templateArgList? baseClassList + "{" multiClassStatement+ "}" +// todo: add foreach, if stmt +multiClassStatement ::= assertStmt | defStmt | defmStmt | letStmt | defvarStmt objectBody ::= baseClassList body baseClassList ::= (":" baseClassListNE)? @@ -136,6 +140,8 @@ includeDirective ::= KeywordInclude STRING defStmt ::= KeywordDef value? objectBody -defmStmt ::= KeywordDefm [value] ":" baseClassListNE ";" +defmStmt ::= KeywordDefm [value] baseClassList ";" + +defvarStmt ::= KeywordDefVar IDENTIFIER "=" value ";" -defvarStmt ::= KeywordDefVar IDENTIFIER "=" value ";" \ No newline at end of file +assertStmt ::= KeywordAssert CONDITION "," STRING ";" \ No newline at end of file