Bugfix: Macro definitions with colons and without space supported (as found in P61a source).

This commit is contained in:
Chris Hodges 2021-08-02 09:31:10 +02:00
parent 587b284d25
commit 19e3b519db
9 changed files with 158 additions and 122 deletions

View File

@ -45,6 +45,7 @@ it's "good enough" to get started, and I can return to demo coding with its curr
- While the Lexer supports the -spaces option (where a space introduces a comment), this cannot be configured yet (default is off).
- No support for other processor instructions, FPU or 68020+ address modes.
- Unit Test coverage is not as good as it could be (ahem).
- `opt` keyword needs special treatment and will currently show a parsing error
- Missing but planned features:
- Macro evaluation on invocation
- Folding
@ -79,6 +80,7 @@ make it work with JUnit 5. Feel free to use the code (in package ```de.platon42.
- Bugfix: Interpretation of register lists was wrong in BNF.
- New: Added Documentation Provider for symbol definitions (shows assigned declaration).
- New: Added Documentation Provider for mnemonics (simple version, generated out of ISA information).
- Bugfix: Macro definitions with colons and without space supported (as found in P61a source).
### V0.3 (28-Jul-21)

View File

@ -67,6 +67,7 @@ patchPluginXml {
<li>Bugfix: Interpretation of register lists was wrong in BNF.
<li>New: Added Documentation Provider for symbol definitions (shows assigned declaration).
<li>New: Added Documentation Provider for mnemonics (simple version, generated out of ISA information).
<li>Bugfix: Macro definitions with colons and without space supported (as found in P61a source).
</ul>
<h4>V0.3 (28-Jul-21)</h4>
<ul>

View File

@ -207,13 +207,13 @@ public class _M68kLexer implements FlexLexer {
"\1\71\1\16\1\72\1\73\1\16\1\74\1\75\2\0" +
"\1\76\4\0\1\77\1\16\1\32\1\100\1\101\1\102" +
"\1\103\1\104\1\105\1\106\3\0\1\52\1\0\1\52" +
"\1\0\1\52\1\0\1\52\1\55\1\57\4\0\1\4" +
"\1\0\1\52\1\0\1\52\1\55\1\57\3\0\1\4" +
"\1\62\1\63\1\7\1\107\1\7\1\110\1\111\1\112" +
"\1\113\1\0\1\52\3\0\1\55\1\57\3\0\1\7" +
"\1\55\1\57\2\0\1\114\1\115\1\116\1\0\1\117";
private static int[] zzUnpackAction() {
int[] result = new int[185];
int[] result = new int[184];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@ -257,14 +257,13 @@ public class _M68kLexer implements FlexLexer {
"\0\u1342\0\u0828\0\u137c\0\u0366\0\u0366\0\u0366\0\u0366\0\u0366" +
"\0\u0366\0\u0366\0\u0366\0\u13b6\0\u13f0\0\u142a\0\u1464\0\u149e" +
"\0\u14d8\0\u1512\0\u154c\0\u1586\0\u15c0\0\u15fa\0\u1634\0\u166e" +
"\0\u16a8\0\u16e2\0\u171c\0\u0366\0\u0366\0\u0366\0\u0366\0\u0366" +
"\0\u1756\0\u0828\0\u0828\0\u0828\0\u0366\0\u1790\0\u0366\0\u17ca" +
"\0\u16a8\0\u16e2\0\u0366\0\u0366\0\u0366\0\u0366\0\u0366\0\u171c" +
"\0\u0828\0\u0828\0\u0828\0\u0366\0\u1756\0\u0366\0\u1790\0\u17ca" +
"\0\u1804\0\u183e\0\u1878\0\u18b2\0\u18ec\0\u1926\0\u1960\0\u199a" +
"\0\u19d4\0\u1a0e\0\u108a\0\u1a48\0\u04fc\0\u0eba\0\u1a82\0\u1abc" +
"\0\u1af6";
"\0\u19d4\0\u108a\0\u1a0e\0\u04fc\0\u0eba\0\u1a48\0\u1a82\0\u1abc";
private static int[] zzUnpackRowMap() {
int[] result = new int[185];
int[] result = new int[184];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@ -320,115 +319,115 @@ public class _M68kLexer implements FlexLexer {
"\1\122\1\123\1\34\1\35\1\44\25\122\1\41\12\122" +
"\1\124\1\125\1\126\1\127\1\122\1\62\17\122\1\130" +
"\1\131\1\34\1\35\66\130\1\20\2\132\1\133\1\27" +
"\1\134\1\20\1\134\1\20\2\134\2\20\5\134\3\20" +
"\1\135\4\134\1\136\1\20\4\134\2\20\1\134\24\20" +
"\3\134\1\137\1\140\1\141\1\142\1\143\25\137\1\136" +
"\37\137\1\20\2\34\1\35\1\27\25\20\1\41\37\20" +
"\1\130\1\144\1\141\1\142\66\130\74\0\1\21\73\0" +
"\1\23\71\0\1\145\7\24\1\146\5\24\1\147\1\0" +
"\1\150\5\24\2\0\4\24\1\0\3\24\23\0\3\24" +
"\5\0\1\151\1\0\1\151\1\0\2\151\2\0\5\151" +
"\3\0\5\151\2\0\4\151\2\0\1\151\24\0\3\151" +
"\1\26\3\0\66\26\4\0\1\27\72\0\1\30\1\31" +
"\1\30\1\31\1\30\2\31\1\152\5\30\1\0\1\153" +
"\1\154\5\30\2\0\4\30\1\0\1\31\1\30\1\31" +
"\23\0\3\30\5\0\7\31\1\152\5\31\2\0\1\154" +
"\5\31\2\0\4\31\1\0\3\31\23\0\3\31\5\0" +
"\1\155\1\0\1\155\1\0\2\155\2\0\5\155\3\0" +
"\5\155\2\0\4\155\2\0\1\155\24\0\3\155\5\0" +
"\1\156\1\31\1\30\1\31\1\30\2\31\1\152\5\30" +
"\1\0\1\153\1\154\5\30\2\0\4\30\1\0\1\31" +
"\1\30\1\31\23\0\3\30\2\0\1\34\74\0\1\36" +
"\1\37\1\36\1\37\1\36\2\37\1\0\5\36\1\0" +
"\1\153\1\0\5\36\2\0\4\36\1\0\1\37\1\36" +
"\1\37\23\0\3\36\5\0\7\37\1\0\5\37\3\0" +
"\5\37\2\0\4\37\1\0\3\37\23\0\3\37\1\41" +
"\3\0\66\41\4\0\1\42\121\0\2\157\1\160\1\161" +
"\36\0\1\44\72\0\1\50\1\162\1\50\1\163\3\50" +
"\1\0\5\50\2\0\6\50\2\0\4\50\1\0\1\162" +
"\2\50\23\0\3\50\6\0\1\46\1\0\1\46\30\0" +
"\1\46\1\0\1\46\33\0\1\50\1\164\1\50\1\164" +
"\1\134\1\20\1\134\1\20\2\134\1\20\1\40\5\134" +
"\3\20\1\135\4\134\1\136\1\20\4\134\2\20\1\134" +
"\24\20\3\134\1\137\1\140\1\141\1\142\1\143\25\137" +
"\1\136\37\137\1\20\2\34\1\35\1\27\25\20\1\41" +
"\37\20\1\130\1\144\1\141\1\142\66\130\74\0\1\21" +
"\73\0\1\23\71\0\1\145\7\24\1\146\5\24\1\147" +
"\1\0\1\150\5\24\2\0\4\24\1\0\3\24\23\0" +
"\3\24\5\0\1\151\1\0\1\151\1\0\2\151\2\0" +
"\5\151\3\0\5\151\2\0\4\151\2\0\1\151\24\0" +
"\3\151\1\26\3\0\66\26\4\0\1\27\72\0\1\30" +
"\1\31\1\30\1\31\1\30\2\31\1\152\5\30\1\0" +
"\1\153\1\154\5\30\2\0\4\30\1\0\1\31\1\30" +
"\1\31\23\0\3\30\5\0\7\31\1\152\5\31\2\0" +
"\1\154\5\31\2\0\4\31\1\0\3\31\23\0\3\31" +
"\5\0\1\155\1\0\1\155\1\0\2\155\2\0\5\155" +
"\3\0\5\155\2\0\4\155\2\0\1\155\24\0\3\155" +
"\5\0\1\156\1\31\1\30\1\31\1\30\2\31\1\152" +
"\5\30\1\0\1\153\1\154\5\30\2\0\4\30\1\0" +
"\1\31\1\30\1\31\23\0\3\30\2\0\1\34\74\0" +
"\1\36\1\37\1\36\1\37\1\36\2\37\1\0\5\36" +
"\1\0\1\153\1\0\5\36\2\0\4\36\1\0\1\37" +
"\1\36\1\37\23\0\3\36\5\0\7\37\1\0\5\37" +
"\3\0\5\37\2\0\4\37\1\0\3\37\23\0\3\37" +
"\1\41\3\0\66\41\4\0\1\42\121\0\2\157\1\160" +
"\1\161\36\0\1\44\72\0\1\50\1\162\1\50\1\163" +
"\3\50\1\0\5\50\2\0\6\50\2\0\4\50\1\0" +
"\1\164\2\50\23\0\3\50\5\0\7\50\1\0\5\50" +
"\2\0\6\50\2\0\4\50\1\0\3\50\23\0\3\50" +
"\5\0\7\50\1\0\3\50\1\165\1\50\2\0\6\50" +
"\2\0\1\50\1\165\2\50\1\0\3\50\23\0\3\50" +
"\5\0\7\50\1\0\5\50\2\0\3\50\1\166\2\50" +
"\2\0\4\50\1\0\3\50\23\0\1\163\2\50\5\0" +
"\4\167\4\0\1\167\10\0\1\167\5\0\1\167\4\0" +
"\3\167\25\0\1\167\5\0\7\50\1\0\5\50\2\0" +
"\2\50\1\170\3\50\2\0\4\50\1\0\3\50\23\0" +
"\3\50\41\0\1\171\36\0\1\172\1\0\1\172\30\0" +
"\1\172\30\0\2\173\2\0\27\173\1\174\11\173\1\175" +
"\24\173\2\176\2\0\27\176\1\177\12\176\1\175\23\176" +
"\2\200\2\0\27\200\1\201\13\200\1\175\22\200\5\0" +
"\7\50\1\0\5\50\2\0\2\50\1\202\3\50\2\0" +
"\4\50\1\0\3\50\23\0\3\50\5\0\7\50\1\0" +
"\5\50\2\0\6\50\2\0\1\203\3\50\1\0\3\50" +
"\23\0\2\50\1\203\22\0\1\204\71\0\1\205\25\0" +
"\1\206\1\207\42\0\1\210\26\0\1\211\42\0\1\207" +
"\133\0\1\212\72\0\1\213\72\0\1\77\21\0\1\214" +
"\70\0\1\215\61\0\7\121\1\0\5\121\1\0\7\121" +
"\1\0\5\121\1\0\3\121\23\0\3\121\2\122\3\0" +
"\25\122\1\0\17\122\1\0\17\122\2\124\2\0\1\216" +
"\25\124\1\216\1\217\11\124\1\122\4\124\1\216\17\124" +
"\2\125\2\0\1\220\25\125\1\220\1\221\12\125\1\122" +
"\3\125\1\220\17\125\2\126\2\0\1\222\25\126\1\222" +
"\1\223\13\126\1\122\2\126\1\222\17\126\2\127\2\0" +
"\1\224\25\127\1\224\1\225\15\127\1\122\1\224\17\127" +
"\2\130\2\0\66\130\2\0\1\132\74\0\7\134\1\0" +
"\5\134\3\0\5\134\2\0\4\134\1\0\3\134\23\0" +
"\3\134\5\0\1\226\6\134\1\0\5\134\3\0\5\134" +
"\2\0\4\134\1\0\3\134\23\0\3\134\1\136\3\0" +
"\66\136\2\137\2\0\26\137\1\0\37\137\2\0\1\141" +
"\67\0\2\137\2\0\1\143\10\137\1\227\14\137\1\0" +
"\37\137\4\0\1\145\10\0\1\230\2\0\1\231\1\0" +
"\1\147\2\0\1\232\7\0\1\231\40\0\1\233\7\0" +
"\1\234\5\0\1\147\53\0\1\147\101\0\1\235\62\0" +
"\7\151\1\235\5\151\3\0\5\151\2\0\4\151\1\0" +
"\3\151\23\0\3\151\14\0\1\236\55\0\1\237\3\0" +
"\66\237\14\0\1\240\62\0\7\155\1\240\5\155\3\0" +
"\5\155\2\0\4\155\1\0\3\155\23\0\3\155\5\0" +
"\1\30\1\31\1\30\1\31\1\30\2\31\1\152\5\30" +
"\1\0\1\153\1\154\1\30\1\241\3\30\2\0\4\30" +
"\1\0\1\31\1\30\1\31\23\0\3\30\5\0\7\50" +
"\1\0\5\50\2\0\6\50\2\0\4\50\1\0\3\50" +
"\23\0\1\242\2\50\5\0\7\50\1\0\5\50\2\0" +
"\3\50\1\243\2\50\2\0\4\50\1\0\3\50\23\0" +
"\3\50\1\173\3\0\66\173\1\176\3\0\66\176\1\200" +
"\3\0\66\200\5\0\7\50\1\0\5\50\2\0\3\50" +
"\1\244\2\50\2\0\4\50\1\0\3\50\23\0\3\50" +
"\17\0\1\245\73\0\1\245\50\0\2\216\2\0\27\216" +
"\1\246\11\216\1\247\24\216\1\124\1\122\2\0\1\216" +
"\25\124\1\216\17\124\1\216\17\124\2\220\2\0\27\220" +
"\1\250\12\220\1\247\23\220\1\125\1\122\2\0\1\220" +
"\25\125\1\220\17\125\1\220\17\125\2\222\2\0\27\222" +
"\1\251\13\222\1\247\22\222\1\126\1\122\2\0\1\222" +
"\25\126\1\222\17\126\1\222\17\126\2\224\2\0\27\224" +
"\1\252\15\224\1\247\20\224\1\127\1\122\2\0\1\224" +
"\25\127\1\224\17\127\1\224\17\127\5\0\7\134\1\0" +
"\5\134\3\0\1\134\1\253\3\134\2\0\4\134\1\0" +
"\3\134\23\0\3\134\2\137\2\0\25\137\1\254\1\0" +
"\37\137\16\0\1\255\70\0\1\256\61\0\1\257\70\0" +
"\1\233\10\0\1\230\2\0\1\231\1\0\1\147\12\0" +
"\1\231\41\0\1\30\1\31\1\30\1\31\1\30\2\31" +
"\1\152\5\30\1\0\1\153\1\154\2\30\1\260\2\30" +
"\2\0\4\30\1\0\1\31\1\30\1\31\23\0\3\30" +
"\1\216\3\0\66\216\1\220\3\0\66\220\1\222\3\0" +
"\66\222\1\224\3\0\66\224\5\0\7\134\1\0\5\134" +
"\3\0\2\134\1\261\2\134\2\0\4\134\1\0\3\134" +
"\23\0\3\134\2\137\2\0\3\137\1\262\22\137\1\0" +
"\37\137\17\0\1\263\73\0\1\263\76\0\1\264\50\0" +
"\1\30\1\31\1\30\1\31\1\30\2\31\1\152\5\30" +
"\1\0\1\153\1\154\3\30\1\265\1\30\2\0\4\30" +
"\1\0\1\31\1\30\1\31\23\0\3\30\5\0\7\134" +
"\1\0\5\134\3\0\3\134\1\266\1\134\2\0\4\134" +
"\1\0\3\134\23\0\3\134\2\137\2\0\21\137\1\267" +
"\4\137\1\0\37\137\27\0\1\270\42\0\2\267\2\0" +
"\26\267\1\0\37\267\30\0\1\271\45\0\1\271\65\0";
"\1\162\2\50\23\0\3\50\6\0\1\46\1\0\1\46" +
"\30\0\1\46\1\0\1\46\33\0\1\50\1\164\1\50" +
"\1\164\3\50\1\0\5\50\2\0\6\50\2\0\4\50" +
"\1\0\1\164\2\50\23\0\3\50\5\0\7\50\1\0" +
"\5\50\2\0\6\50\2\0\4\50\1\0\3\50\23\0" +
"\3\50\5\0\7\50\1\0\3\50\1\165\1\50\2\0" +
"\6\50\2\0\1\50\1\165\2\50\1\0\3\50\23\0" +
"\3\50\5\0\7\50\1\0\5\50\2\0\3\50\1\166" +
"\2\50\2\0\4\50\1\0\3\50\23\0\1\163\2\50" +
"\5\0\4\167\4\0\1\167\10\0\1\167\5\0\1\167" +
"\4\0\3\167\25\0\1\167\5\0\7\50\1\0\5\50" +
"\2\0\2\50\1\170\3\50\2\0\4\50\1\0\3\50" +
"\23\0\3\50\41\0\1\171\36\0\1\172\1\0\1\172" +
"\30\0\1\172\30\0\2\173\2\0\27\173\1\174\11\173" +
"\1\175\24\173\2\176\2\0\27\176\1\177\12\176\1\175" +
"\23\176\2\200\2\0\27\200\1\201\13\200\1\175\22\200" +
"\5\0\7\50\1\0\5\50\2\0\2\50\1\202\3\50" +
"\2\0\4\50\1\0\3\50\23\0\3\50\5\0\7\50" +
"\1\0\5\50\2\0\6\50\2\0\1\203\3\50\1\0" +
"\3\50\23\0\2\50\1\203\22\0\1\204\71\0\1\205" +
"\25\0\1\206\1\207\42\0\1\210\26\0\1\211\42\0" +
"\1\207\133\0\1\212\72\0\1\213\72\0\1\77\21\0" +
"\1\214\70\0\1\215\61\0\7\121\1\0\5\121\1\0" +
"\7\121\1\0\5\121\1\0\3\121\23\0\3\121\2\122" +
"\3\0\25\122\1\0\17\122\1\0\17\122\2\124\2\0" +
"\1\216\25\124\1\216\1\217\11\124\1\122\4\124\1\216" +
"\17\124\2\125\2\0\1\220\25\125\1\220\1\221\12\125" +
"\1\122\3\125\1\220\17\125\2\126\2\0\1\222\25\126" +
"\1\222\1\223\13\126\1\122\2\126\1\222\17\126\2\127" +
"\2\0\1\224\25\127\1\224\1\225\15\127\1\122\1\224" +
"\17\127\2\130\2\0\66\130\2\0\1\132\74\0\7\134" +
"\1\0\5\134\3\0\5\134\2\0\4\134\1\0\3\134" +
"\23\0\3\134\5\0\1\226\6\134\1\0\5\134\3\0" +
"\5\134\2\0\4\134\1\0\3\134\23\0\3\134\1\136" +
"\3\0\66\136\2\137\2\0\26\137\1\0\37\137\2\0" +
"\1\141\67\0\2\137\2\0\1\143\10\137\1\227\14\137" +
"\1\0\37\137\4\0\1\145\10\0\1\230\2\0\1\231" +
"\1\0\1\147\2\0\1\232\7\0\1\231\40\0\1\145" +
"\7\0\1\233\5\0\1\147\2\0\1\232\50\0\1\147" +
"\101\0\1\234\62\0\7\151\1\234\5\151\3\0\5\151" +
"\2\0\4\151\1\0\3\151\23\0\3\151\14\0\1\235" +
"\55\0\1\236\3\0\66\236\14\0\1\237\62\0\7\155" +
"\1\237\5\155\3\0\5\155\2\0\4\155\1\0\3\155" +
"\23\0\3\155\5\0\1\30\1\31\1\30\1\31\1\30" +
"\2\31\1\152\5\30\1\0\1\153\1\154\1\30\1\240" +
"\3\30\2\0\4\30\1\0\1\31\1\30\1\31\23\0" +
"\3\30\5\0\7\50\1\0\5\50\2\0\6\50\2\0" +
"\4\50\1\0\3\50\23\0\1\241\2\50\5\0\7\50" +
"\1\0\5\50\2\0\3\50\1\242\2\50\2\0\4\50" +
"\1\0\3\50\23\0\3\50\1\173\3\0\66\173\1\176" +
"\3\0\66\176\1\200\3\0\66\200\5\0\7\50\1\0" +
"\5\50\2\0\3\50\1\243\2\50\2\0\4\50\1\0" +
"\3\50\23\0\3\50\17\0\1\244\73\0\1\244\50\0" +
"\2\216\2\0\27\216\1\245\11\216\1\246\24\216\1\124" +
"\1\122\2\0\1\216\25\124\1\216\17\124\1\216\17\124" +
"\2\220\2\0\27\220\1\247\12\220\1\246\23\220\1\125" +
"\1\122\2\0\1\220\25\125\1\220\17\125\1\220\17\125" +
"\2\222\2\0\27\222\1\250\13\222\1\246\22\222\1\126" +
"\1\122\2\0\1\222\25\126\1\222\17\126\1\222\17\126" +
"\2\224\2\0\27\224\1\251\15\224\1\246\20\224\1\127" +
"\1\122\2\0\1\224\25\127\1\224\17\127\1\224\17\127" +
"\5\0\7\134\1\0\5\134\3\0\1\134\1\252\3\134" +
"\2\0\4\134\1\0\3\134\23\0\3\134\2\137\2\0" +
"\25\137\1\253\1\0\37\137\16\0\1\254\70\0\1\255" +
"\61\0\1\256\71\0\1\30\1\31\1\30\1\31\1\30" +
"\2\31\1\152\5\30\1\0\1\153\1\154\2\30\1\257" +
"\2\30\2\0\4\30\1\0\1\31\1\30\1\31\23\0" +
"\3\30\1\216\3\0\66\216\1\220\3\0\66\220\1\222" +
"\3\0\66\222\1\224\3\0\66\224\5\0\7\134\1\0" +
"\5\134\3\0\2\134\1\260\2\134\2\0\4\134\1\0" +
"\3\134\23\0\3\134\2\137\2\0\3\137\1\261\22\137" +
"\1\0\37\137\17\0\1\262\73\0\1\262\76\0\1\263" +
"\50\0\1\30\1\31\1\30\1\31\1\30\2\31\1\152" +
"\5\30\1\0\1\153\1\154\3\30\1\264\1\30\2\0" +
"\4\30\1\0\1\31\1\30\1\31\23\0\3\30\5\0" +
"\7\134\1\0\5\134\3\0\3\134\1\265\1\134\2\0" +
"\4\134\1\0\3\134\23\0\3\134\2\137\2\0\21\137" +
"\1\266\4\137\1\0\37\137\27\0\1\267\42\0\2\266" +
"\2\0\26\266\1\0\37\266\30\0\1\270\45\0\1\270" +
"\65\0";
private static int[] zzUnpackTrans() {
int[] result = new int[6960];
int[] result = new int[6902];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
@ -471,11 +470,11 @@ public class _M68kLexer implements FlexLexer {
"\11\1\1\11\6\1\1\11\3\1\1\0\5\1\3\0" +
"\1\1\3\11\11\1\2\0\1\11\4\0\2\1\10\11" +
"\3\0\1\1\1\0\1\1\1\0\1\1\1\0\3\1" +
"\4\0\5\11\4\1\1\11\1\0\1\11\3\0\2\1" +
"\3\0\5\11\4\1\1\11\1\0\1\11\3\0\2\1" +
"\3\0\3\1\2\0\3\1\1\0\1\1";
private static int[] zzUnpackAttribute() {
int[] result = new int[185];
int[] result = new int[184];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;

View File

@ -658,7 +658,7 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// ((MacroNameDefinition MACRO_TAG)|(MACRO_TAG MacroNameDefinition)) MacroPlainLine* MACRO_END_TAG
// ((MacroNameDefinition COLON? MACRO_TAG)|(MACRO_TAG MacroNameDefinition)) MacroPlainLine* MACRO_END_TAG
public static boolean MacroDefinition(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition")) return false;
if (!nextTokenIs(b, "<macro definition>", MACRO_NAME, MACRO_TAG)) return false;
@ -672,7 +672,7 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r || p;
}
// (MacroNameDefinition MACRO_TAG)|(MACRO_TAG MacroNameDefinition)
// (MacroNameDefinition COLON? MACRO_TAG)|(MACRO_TAG MacroNameDefinition)
private static boolean MacroDefinition_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition_0")) return false;
boolean r;
@ -683,17 +683,25 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
// MacroNameDefinition MACRO_TAG
// MacroNameDefinition COLON? MACRO_TAG
private static boolean MacroDefinition_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition_0_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = MacroNameDefinition(b, l + 1);
r = r && MacroDefinition_0_0_1(b, l + 1);
r = r && consumeToken(b, MACRO_TAG);
exit_section_(b, m, null, r);
return r;
}
// COLON?
private static boolean MacroDefinition_0_0_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition_0_0_1")) return false;
consumeToken(b, COLON);
return true;
}
// MACRO_TAG MacroNameDefinition
private static boolean MacroDefinition_0_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition_0_1")) return false;

View File

@ -9,7 +9,7 @@ import de.platon42.intellij.plugins.m68k.psi.M68kTypes
object LexerUtil {
private val ASSIGNMENT_SEPARATORS = charArrayOf(' ', '\t', '=', ':')
private val TOKEN_SEPARATORS = charArrayOf(' ', '\t')
private val TOKEN_SEPARATORS = charArrayOf(' ', '\t', ':')
@JvmStatic
fun isAsmMnemonic(text: CharSequence) = mnemonics.contains(text.toString().lowercase())

View File

@ -51,7 +51,7 @@ LOCAL_LABEL=(\.([:letter:]|_)([:letter:]|[:digit:]|_)*:?)|(([:letter:]|_)([:lett
LOCAL_LABEL_WC=(\.([:letter:]|_)([:letter:]|[:digit:]|_)*:)|(([:letter:]|_)([:letter:]|[:digit:]|_)*\$:)
GLOBAL_LABEL=(([:letter:]|_)([:letter:]|[:digit:]|_)*:?:?)
GLOBAL_LABEL_WC=(([:letter:]|_)([:letter:]|[:digit:]|_)*::?)
MACRO_DEF_LEFT=(([:letter:]|_)(([:letter:]|[:digit:]|_))*)\p{Blank}+macro\p{Blank}*
MACRO_DEF_LEFT=(([:letter:]|_)(([:letter:]|[:digit:]|_))*)(\p{Blank}+|:\p{Blank}*)macro\p{Blank}*
MACRO_END_TAG=\p{Blank}+endm\p{Blank}*[^;\r\n]*
//MNEMONIC=(([:letter:])+)
SYMBOL=(([:letter:]|_|\.)(([:letter:]|[:digit:]|[_\$]))*)
@ -123,7 +123,7 @@ PLAIN_MACRO_LINE=[^;\r\n]+
{MACRONAME} { return handleMacroMode(this); }
}
<INSTRPART> {
<INSTRPART,MACRODEF> {
":" { return COLON; }
// {MNEMONIC} { if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } else { return SYMBOL; } }
}

View File

@ -179,7 +179,7 @@ PreprocessorDirective ::= Label? (DATA_DIRECTIVE | OTHER_DIRECTIVE)
MacroPlainLine ::= MACRO_LINE
MacroNameDefinition ::= MACRO_NAME
MacroDefinition ::= ((MacroNameDefinition MACRO_TAG)|(MACRO_TAG MacroNameDefinition)) MacroPlainLine* MACRO_END_TAG {
MacroDefinition ::= ((MacroNameDefinition COLON? MACRO_TAG)|(MACRO_TAG MacroNameDefinition)) MacroPlainLine* MACRO_END_TAG {
pin = 1
name = "macro definition"
implements = "de.platon42.intellij.plugins.m68k.psi.M68kNamedElement"

View File

@ -63,4 +63,15 @@ label: move.w d0,d1
)
}
@Test
internal fun macro_name_with_colon_p61_source_suxxor(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(
testCase, """
structure:macro
\1:equ 0
soffset:set \2
endm"""
)
}
}

View File

@ -0,0 +1,15 @@
Assembly File: a.asm
PsiWhiteSpace('\n')
M68kMacroDefinitionImpl(MACRO_DEFINITION)
M68kMacroNameDefinitionImpl(MACRO_NAME_DEFINITION)
PsiElement(M68kTokenType.MACRO_NAME)('structure')
PsiElement(M68kTokenType.COLON)(':')
PsiElement(M68kTokenType.MACRO_TAG)('macro')
PsiWhiteSpace('\n')
M68kMacroPlainLineImpl(MACRO_PLAIN_LINE)
PsiElement(M68kTokenType.MACRO_LINE)('\1:equ 0')
PsiWhiteSpace('\n')
M68kMacroPlainLineImpl(MACRO_PLAIN_LINE)
PsiElement(M68kTokenType.MACRO_LINE)('soffset:set \2')
PsiWhiteSpace('\n')
PsiElement(M68kTokenType.MACRO_END_TAG)('\tendm')