'END' directive stops parsing. Prepared next release.
This commit is contained in:
@@ -624,11 +624,11 @@ public class _M68kLexer implements FlexLexer {
|
||||
/**
|
||||
* Refills the input buffer.
|
||||
*
|
||||
* @return {@code false}, iff there was new input.
|
||||
* @return {@code false}, iff there was NO new input.
|
||||
* @throws java.io.IOException if any I/O-Error occurs
|
||||
*/
|
||||
private boolean zzRefill() throws java.io.IOException {
|
||||
return true;
|
||||
return !zzAtEOF;
|
||||
}
|
||||
|
||||
|
||||
@@ -871,6 +871,11 @@ public class _M68kLexer implements FlexLexer {
|
||||
yybegin(ASMINSTR);
|
||||
return MNEMONIC;
|
||||
}
|
||||
if (isEndDirective(yytext())) {
|
||||
yybegin(YYINITIAL);
|
||||
zzAtEOF = true;
|
||||
return null;
|
||||
}
|
||||
if (isDataDirective(yytext())) {
|
||||
startExpr(EXPR, EXPR_OP);
|
||||
return DATA_DIRECTIVE;
|
||||
|
||||
@@ -57,6 +57,8 @@ object AssemblerDirectives {
|
||||
"machine", "mc68000", "mc68010", "mc68020", "mc68030", "mc68040", "mc68060",
|
||||
"fpu",
|
||||
|
||||
"basereg", "endb", "far", "near", "initnear"
|
||||
"basereg", "endb", "far", "near", "initnear",
|
||||
|
||||
"end"
|
||||
)
|
||||
}
|
||||
@@ -19,6 +19,9 @@ object LexerUtil {
|
||||
&& text.dropLast(1).endsWith('.')
|
||||
&& mnemonics.contains(text.dropLast(2).toString().lowercase())
|
||||
|
||||
@JvmStatic
|
||||
fun isEndDirective(text: CharSequence) = text.contentEquals("end", ignoreCase = true)
|
||||
|
||||
@JvmStatic
|
||||
fun isDataDirective(text: CharSequence) = AssemblerDirectives.dataDirectives.contains(text.toString().lowercase())
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ PLAIN_MACRO_LINE=[^;\r\n]+
|
||||
{DIRECTIVE_KEYWORD} {
|
||||
if(isAsmMnemonicWithSize(yytext())) { yybegin(ASMINSTR); yypushback(2); return MNEMONIC; }
|
||||
if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; }
|
||||
if(isEndDirective(yytext())) { yybegin(YYINITIAL); zzAtEOF = true; return null; }
|
||||
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; }
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.platon42.intellij.plugins.m68k.parser
|
||||
|
||||
import de.platon42.intellij.jupiter.MyTestCase
|
||||
import de.platon42.intellij.jupiter.ParsingTestExtension
|
||||
import de.platon42.intellij.jupiter.TestDataSubPath
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@TestDataSubPath("directives")
|
||||
internal class EndDirectiveTest : AbstractParsingTest() {
|
||||
|
||||
@Test
|
||||
internal fun end_directive(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
testGoodSyntax(
|
||||
testCase, """
|
||||
moveq.l #0,d0
|
||||
rts
|
||||
END narf
|
||||
äöö#öä235r2352ou485742q3535p3ü
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
Assembly File: a.asm
|
||||
PsiWhiteSpace('\n')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAsmInstructionImpl(ASM_INSTRUCTION)
|
||||
M68kAsmOpImpl(ASM_OP)
|
||||
PsiElement(M68kTokenType.MNEMONIC)('moveq')
|
||||
M68kOperandSizeImpl(OPERAND_SIZE)
|
||||
PsiElement(M68kTokenType.OPSIZE_L)('.l')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kImmediateDataImpl(IMMEDIATE_DATA)
|
||||
PsiElement(M68kTokenType.HASH)('#')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('0')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE)
|
||||
M68kDataRegisterImpl(DATA_REGISTER)
|
||||
PsiElement(M68kTokenType.DREG)('d0')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAsmInstructionImpl(ASM_INSTRUCTION)
|
||||
M68kAsmOpImpl(ASM_OP)
|
||||
PsiElement(M68kTokenType.MNEMONIC)('rts')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
||||
PsiWhiteSpace(' END narf\n äöö#öä235r2352ou485742q3535p3ü\n')
|
||||
Reference in New Issue
Block a user