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:
@@ -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>')
|
||||
@@ -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-')
|
||||
Reference in New Issue
Block a user