diff --git a/README.md b/README.md index f1f4624..d46f69a 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,11 @@ make it work with JUnit 5. Feel free to use the code (in package ```de.platon42. ## Changelog +### V0.6 (unreleased) + +- Enhancement: `opt` and several other directives (`printt`, `fail` etc.) no longer causes a syntax error when unquoted. +- Enhancement: `include`, `incdir` and `incbin` and `output` with `` quotes no longer cause syntax error. + ### V0.5 (06-Aug-21) - Bugfix: `movem` ISA was wrong regarding the `movem.w ,` (sign extends registers). diff --git a/build.gradle b/build.gradle index 91df61f..518aba7 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { } group = 'de.platon42' -version = '0.5' +version = '0.6' sourceCompatibility = "1.8" targetCompatibility = "1.8" @@ -57,9 +57,14 @@ runPluginVerifier { patchPluginXml { setChangeNotes(""" +

V0.6 (unreleased)

+
    +
  • Enhancement: 'opt' and several other directives ('printt', 'fail' etc.) no longer causes a syntax error when unquoted. +

    V0.5 (06-Aug-21)

      -
    • Bugfix: movem ISA was wrong regarding movem.w , (sign extends registers). +
    • Bugfix: movem ISA was wrong regarding movem.w <ea>,<registerlist> (sign extends registers).
    • Cosmetics: Changed Register Flow Documentation wording from 'reads' to 'uses' and from 'modifies' to 'changes'.
    • Bugfix: Minor fix for `andi/eori/ori to ccr` which were not byte sized in ISA.
    • Bugfix: Added alternate condition code tests HS (=CC) and LO (=CS). @@ -71,7 +76,7 @@ patchPluginXml {

    V0.4 (03-Aug-21)

      -
    • Notice: Due to major new API use, this plugin no longer works on IDEs >=2019.3.1, but rather requires >=2020.3. +
    • Notice: Due to major new API use, this plugin no longer works on IDEs >=2019.3.1, but rather requires >=2020.3.
    • Enhancement: Added Structure View filters.
    • New: Added inspection to validate the correctness of a MC68000 instruction regarding operation size and address modes.
    • Bugfix: Added several missing assembler directives (opt, machine, etc.). diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.java b/src/main/gen/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.java index e8ce9ea..0e10b22 100644 --- a/src/main/gen/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.java +++ b/src/main/gen/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.java @@ -867,6 +867,10 @@ public class _M68kLexer implements FlexLexer { startExpr(EXPR, EXPR_OP); return DATA_DIRECTIVE; } + if (isPlainDirective(yytext())) { + yybegin(MACROCALL); + return OTHER_DIRECTIVE; + } if (isOtherDirective(yytext())) { startExpr(EXPR, EXPR_OP); return OTHER_DIRECTIVE; diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/asm/AssemblerDirectives.kt b/src/main/java/de/platon42/intellij/plugins/m68k/asm/AssemblerDirectives.kt index 06405a3..239c3df 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/asm/AssemblerDirectives.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/asm/AssemblerDirectives.kt @@ -22,7 +22,15 @@ object AssemblerDirectives { "rsset", "clrfo", "clrso", "setfo", "setso" ) - val otherDirective: Set = setOf( + val plainDirectives: Set = setOf( + "incdir", "include", "incbin", "output", "idnt", + + "printt", "echo", "fail", + + "opt" + ) + + val otherDirectives: Set = setOf( "if", "ifeq", "ifne", "ifgt", "ifge", "iflt", "ifle", "ifb", "ifnb", "ifc", "ifnc", "ifd", "ifnd", "ifmacrod", "ifmacrond", @@ -38,12 +46,10 @@ object AssemblerDirectives { "reg", "equr", "equrl", "freg", "fequr", "fequrl", - "incdir", "include", "incbin", "output", - "list", "nlist", "nolist", "llen", "nopage", "page", "spc", "org", - "assert", "fail", "print", "printt", "printv", "echo", + "assert", "printv", "inline", "einline", "rem", "erem", @@ -51,8 +57,6 @@ object AssemblerDirectives { "machine", "mc68000", "mc68010", "mc68020", "mc68030", "mc68040", "mc68060", "fpu", - "basereg", "endb", "far", "near", "initnear", - - "opt" + "basereg", "endb", "far", "near", "initnear" ) } \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/lexer/LexerUtil.kt b/src/main/java/de/platon42/intellij/plugins/m68k/lexer/LexerUtil.kt index df7533b..6847c95 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/lexer/LexerUtil.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/lexer/LexerUtil.kt @@ -23,7 +23,10 @@ object LexerUtil { fun isDataDirective(text: CharSequence) = AssemblerDirectives.dataDirectives.contains(text.toString().lowercase()) @JvmStatic - fun isOtherDirective(text: CharSequence) = AssemblerDirectives.otherDirective.contains(text.toString().lowercase()) + fun isPlainDirective(text: CharSequence) = AssemblerDirectives.plainDirectives.contains(text.toString().lowercase()) + + @JvmStatic + fun isOtherDirective(text: CharSequence) = AssemblerDirectives.otherDirectives.contains(text.toString().lowercase()) @JvmStatic fun pushbackAssignment(text: CharSequence): Int { diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.flex b/src/main/java/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.flex index 8a84a8c..089e527 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.flex +++ b/src/main/java/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.flex @@ -1,6 +1,5 @@ package de.platon42.intellij.plugins.m68k.lexer; -import com.intellij.lexer.FlexLexer; import com.intellij.psi.tree.IElementType; import static com.intellij.psi.TokenType.BAD_CHARACTER; @@ -72,7 +71,7 @@ HASH_COMMENT=([#;*].*+) SKIP_TO_EOL=[^\r\n]+ PLAIN_MACRO_LINE=[^;\r\n]+ -%state NOSOL,INSTRPART,ASMINSTR,ASMOPS,ASMOPS_OP,ASSIGNMENT,EXPR,EXPR_OP,MACROCALL,WAITEOL,MACRODEF,MACROLINE,MACROTERMINATION,MACROWAITEOL +%state NOSOL,INSTRPART,ASMINSTR,ASMOPS,ASMOPS_OP,ASSIGNMENT,EXPR,EXPR_OP,PLAINPARAMS,WAITEOL,MACRODEF,MACROLINE,MACROTERMINATION,MACROWAITEOL %% @@ -81,7 +80,7 @@ PLAIN_MACRO_LINE=[^;\r\n]+ {HASH_COMMENT} { yybegin(YYINITIAL); return COMMENT; } } - + { {EOL} { yybegin(YYINITIAL); return EOL; } {COMMENT} { yybegin(WAITEOL); return COMMENT; } @@ -92,7 +91,7 @@ PLAIN_MACRO_LINE=[^;\r\n]+ {WHITE_SPACE} { return WHITE_SPACE; } } - { + { {WHITE_SPACE} { return handleEolCommentWhitespace(this); } } @@ -117,6 +116,7 @@ PLAIN_MACRO_LINE=[^;\r\n]+ if(isAsmMnemonicWithSize(yytext())) { yybegin(ASMINSTR); yypushback(2); return MNEMONIC; } if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } if(isDataDirective(yytext())) { startExpr(EXPR, EXPR_OP); return DATA_DIRECTIVE; } + if(isPlainDirective(yytext())) { yybegin(PLAINPARAMS); return OTHER_DIRECTIVE; } if(isOtherDirective(yytext())) { startExpr(EXPR, EXPR_OP); return OTHER_DIRECTIVE; } return handleMacroMode(this); } @@ -136,7 +136,7 @@ PLAIN_MACRO_LINE=[^;\r\n]+ {OPSIZE_L} { return OPSIZE_L; } } - { + { "," { return SEPARATOR; } {PLAINPARAM} { return STRINGLIT; } diff --git a/src/test/java/de/platon42/intellij/plugins/m68k/parser/OtherDirectivesTest.kt b/src/test/java/de/platon42/intellij/plugins/m68k/parser/OtherDirectivesTest.kt index b6efad3..65fabe8 100644 --- a/src/test/java/de/platon42/intellij/plugins/m68k/parser/OtherDirectivesTest.kt +++ b/src/test/java/de/platon42/intellij/plugins/m68k/parser/OtherDirectivesTest.kt @@ -22,4 +22,14 @@ internal class OtherDirectivesTest : AbstractParsingTest() { internal fun if_defined_block(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { testGoodSyntax(testCase, "\tIFD DEBUG ; cause a crash\n illegal\n ENDC\n") } + + @Test + internal fun kalms_include_file_special_quote(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " include\t") + } + + @Test + internal fun opt_directive(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " opt o+,w-") + } } \ No newline at end of file diff --git a/src/test/resources/parser/directives/include_file_unquoted.txt b/src/test/resources/parser/directives/include_file_unquoted.txt index 4f82fa3..245dd65 100644 --- a/src/test/resources/parser/directives/include_file_unquoted.txt +++ b/src/test/resources/parser/directives/include_file_unquoted.txt @@ -6,7 +6,6 @@ Assembly File: a.asm PsiElement(M68kTokenType.COLON)(':') PsiElement(M68kTokenType.OTHER_DIRECTIVE)('incbin') PsiWhiteSpace(' ') - M68kRefExprImpl(REF_EXPR) - M68kSymbolReferenceImpl(SYMBOL_REFERENCE) - PsiElement(M68kTokenType.SYMBOL)('Convertedassets\scroller_howto.raw.BPL') + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.STRINGLIT)('Convertedassets\scroller_howto.raw.BPL') PsiElement(M68kTokenType.EOL)('\n') \ No newline at end of file diff --git a/src/test/resources/parser/directives/kalms_include_file_special_quote.txt b/src/test/resources/parser/directives/kalms_include_file_special_quote.txt new file mode 100644 index 0000000..65bfc6e --- /dev/null +++ b/src/test/resources/parser/directives/kalms_include_file_special_quote.txt @@ -0,0 +1,8 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kPreprocessorDirectiveImpl(PREPROCESSOR_DIRECTIVE) + PsiElement(M68kTokenType.OTHER_DIRECTIVE)('include') + PsiWhiteSpace('\t') + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.STRINGLIT)('') \ No newline at end of file diff --git a/src/test/resources/parser/directives/opt_directive.txt b/src/test/resources/parser/directives/opt_directive.txt new file mode 100644 index 0000000..20daacc --- /dev/null +++ b/src/test/resources/parser/directives/opt_directive.txt @@ -0,0 +1,11 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kPreprocessorDirectiveImpl(PREPROCESSOR_DIRECTIVE) + PsiElement(M68kTokenType.OTHER_DIRECTIVE)('opt') + PsiWhiteSpace(' ') + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.STRINGLIT)('o+') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.STRINGLIT)('w-') \ No newline at end of file