Slightly reworked lexer to for a few directives:
'opt' and several other directives ('printt', 'fail' etc.) no longer causes a syntax error when unquoted. 'include', 'incdir' and 'incbin' and 'output' with '<pathname>' quotes no longer cause syntax error.
This commit is contained in:
parent
2c3daf28f7
commit
ddf78ec210
@ -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 `<pathname>` quotes no longer cause syntax error.
|
||||
|
||||
### V0.5 (06-Aug-21)
|
||||
|
||||
- Bugfix: `movem` ISA was wrong regarding the `movem.w <ea>,<registerlist>` (sign extends registers).
|
||||
|
11
build.gradle
11
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("""
|
||||
<h4>V0.6 (unreleased)</h4>
|
||||
<ul>
|
||||
<li>Enhancement: 'opt' and several other directives ('printt', 'fail' etc.) no longer causes a syntax error when unquoted.
|
||||
<li<Enhancement: 'include', 'incdir' and 'incbin' and 'output' with '<pathname>' quotes no longer cause syntax error.
|
||||
</ul>
|
||||
<h4>V0.5 (06-Aug-21)</h4>
|
||||
<ul>
|
||||
<li>Bugfix: movem ISA was wrong regarding movem.w <ea>,<registerlist> (sign extends registers).
|
||||
<li>Bugfix: movem ISA was wrong regarding movem.w <ea>,<registerlist> (sign extends registers).
|
||||
<li>Cosmetics: Changed Register Flow Documentation wording from 'reads' to 'uses' and from 'modifies' to 'changes'.
|
||||
<li>Bugfix: Minor fix for `andi/eori/ori to ccr` which were not byte sized in ISA.
|
||||
<li>Bugfix: Added alternate condition code tests HS (=CC) and LO (=CS).
|
||||
@ -71,7 +76,7 @@ patchPluginXml {
|
||||
</ul>
|
||||
<h4>V0.4 (03-Aug-21)</h4>
|
||||
<ul>
|
||||
<li>Notice: Due to major new API use, this plugin no longer works on IDEs >=2019.3.1, but rather requires >=2020.3.
|
||||
<li>Notice: Due to major new API use, this plugin no longer works on IDEs >=2019.3.1, but rather requires >=2020.3.
|
||||
<li>Enhancement: Added Structure View filters.
|
||||
<li>New: Added inspection to validate the correctness of a MC68000 instruction regarding operation size and address modes.
|
||||
<li>Bugfix: Added several missing assembler directives (opt, machine, etc.).
|
||||
|
@ -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;
|
||||
|
@ -22,7 +22,15 @@ object AssemblerDirectives {
|
||||
"rsset", "clrfo", "clrso", "setfo", "setso"
|
||||
)
|
||||
|
||||
val otherDirective: Set<String> = setOf(
|
||||
val plainDirectives: Set<String> = setOf(
|
||||
"incdir", "include", "incbin", "output", "idnt",
|
||||
|
||||
"printt", "echo", "fail",
|
||||
|
||||
"opt"
|
||||
)
|
||||
|
||||
val otherDirectives: Set<String> = 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"
|
||||
)
|
||||
}
|
@ -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 {
|
||||
|
@ -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
|
||||
|
||||
%%
|
||||
<YYINITIAL, NOSOL>
|
||||
@ -81,7 +80,7 @@ PLAIN_MACRO_LINE=[^;\r\n]+
|
||||
{HASH_COMMENT} { yybegin(YYINITIAL); return COMMENT; }
|
||||
}
|
||||
|
||||
<INSTRPART,ASMINSTR,MACROCALL,ASSIGNMENT,EXPR,EXPR_OP,ASMOPS,ASMOPS_OP>
|
||||
<INSTRPART,ASMINSTR,PLAINPARAMS,ASSIGNMENT,EXPR,EXPR_OP,ASMOPS,ASMOPS_OP>
|
||||
{
|
||||
{EOL} { yybegin(YYINITIAL); return EOL; }
|
||||
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
|
||||
@ -92,7 +91,7 @@ PLAIN_MACRO_LINE=[^;\r\n]+
|
||||
{WHITE_SPACE} { return WHITE_SPACE; }
|
||||
}
|
||||
|
||||
<MACROCALL, EXPR, EXPR_OP, ASMOPS, ASMOPS_OP> {
|
||||
<PLAINPARAMS, EXPR, EXPR_OP, ASMOPS, ASMOPS_OP> {
|
||||
{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; }
|
||||
}
|
||||
|
||||
<MACROCALL> {
|
||||
<PLAINPARAMS> {
|
||||
"," { return SEPARATOR; }
|
||||
|
||||
{PLAINPARAM} { return STRINGLIT; }
|
||||
|
@ -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<Engine/A500/System/Copper.i>")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun opt_directive(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
testGoodSyntax(testCase, " opt o+,w-")
|
||||
}
|
||||
}
|
@ -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')
|
@ -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)('<Engine/A500/System/Copper.i>')
|
11
src/test/resources/parser/directives/opt_directive.txt
Normal file
11
src/test/resources/parser/directives/opt_directive.txt
Normal file
@ -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-')
|
Loading…
Reference in New Issue
Block a user