Added M68kLexerPrefs (preliminary). Added support for optional space-introducing comments.
This commit is contained in:
@@ -112,6 +112,9 @@ public class ParsingTestExtension implements ParameterResolver, AfterTestExecuti
|
||||
}
|
||||
|
||||
public interface IParsingTestCase {
|
||||
|
||||
ParserDefinition getParserDefinition();
|
||||
|
||||
void ensureNoErrorElements();
|
||||
|
||||
void doTest(boolean checkResult);
|
||||
@@ -129,11 +132,14 @@ public class ParsingTestExtension implements ParameterResolver, AfterTestExecuti
|
||||
|
||||
private static class ParsingTestCaseWrapper extends ParsingTestCase implements IParsingTestCase {
|
||||
private ExtensionContext extensionContext;
|
||||
|
||||
private ParserDefinition parserDefinition;
|
||||
private static ExtensionContext extensionContextHack;
|
||||
|
||||
private ParsingTestCaseWrapper(ExtensionContext extensionContext, String extension, ParserDefinition parserDefinition) {
|
||||
super(passthroughInitHack(extensionContext), extension, parserDefinition);
|
||||
this.extensionContext = extensionContext;
|
||||
this.parserDefinition = parserDefinition;
|
||||
}
|
||||
|
||||
private static String passthroughInitHack(ExtensionContext extensionContext) {
|
||||
@@ -159,6 +165,11 @@ public class ParsingTestExtension implements ParameterResolver, AfterTestExecuti
|
||||
super.tearDown(); // Clears fields!
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParserDefinition getParserDefinition() {
|
||||
return parserDefinition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
String testname = extensionContext.getDisplayName().replace(" ", "_");
|
||||
|
||||
@@ -47,4 +47,40 @@ internal class CommentsTest : AbstractParsingTest() {
|
||||
internal fun end_of_line_comments(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
testGoodSyntax(testCase, "foo = 1234; hi\n\n\nlabel; foo\n\n\n add.w d0,d0;narf \n\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun comment_after_instruction_with_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = true
|
||||
testGoodSyntax(testCase, " add.w d0,d0 hey comment\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun comment_after_assignment_with_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = true
|
||||
testGoodSyntax(testCase, "FOO = 123+23 hey comment\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun comment_after_macro_call_with_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = true
|
||||
testGoodSyntax(testCase, " PUSHM d0,d0 hey comment\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun space_does_not_start_comment_within_instruction_without_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = false
|
||||
testGoodSyntax(testCase, " add.w # 234, d0 ; hey comment\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun space_does_not_start_comment_within_assignment_without_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = false
|
||||
testGoodSyntax(testCase, "FOO = 123 + 23 ; hey comment\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun space_does_not_start_comment_within_macro_call_without_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = false
|
||||
testGoodSyntax(testCase, " PUSHM d0, d0 ; hey comment\n")
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
Assembly File: a.asm
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAssignmentImpl(ASSIGNMENT)
|
||||
PsiElement(M68kTokenType.SYMBOLDEF)('FOO')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.OP_ASSIGN)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kBinaryAddExprImpl(BINARY_ADD_EXPR)
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('123')
|
||||
PsiElement(M68kTokenType.OP_PLUS)('+')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('23')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
Assembly File: a.asm
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAsmInstructionImpl(ASM_INSTRUCTION)
|
||||
M68kAsmOpImpl(ASM_OP)
|
||||
PsiElement(M68kTokenType.MNEMONIC)('add')
|
||||
M68kOperandSizeImpl(OPERAND_SIZE)
|
||||
PsiElement(M68kTokenType.OPSIZE_W)('.w')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE)
|
||||
M68kDataRegisterImpl(DATA_REGISTER)
|
||||
PsiElement(M68kTokenType.DREG)('d0')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE)
|
||||
M68kDataRegisterImpl(DATA_REGISTER)
|
||||
PsiElement(M68kTokenType.DREG)('d0')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
Assembly File: a.asm
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kMacroCallImpl(MACRO_CALL)
|
||||
PsiElement(M68kTokenType.MACRO_INVOKATION)('PUSHM')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.STRINGLIT)('d0')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
PsiElement(M68kTokenType.STRINGLIT)('d0')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
Assembly File: a.asm
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAssignmentImpl(ASSIGNMENT)
|
||||
PsiElement(M68kTokenType.SYMBOLDEF)('FOO')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.OP_ASSIGN)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kBinaryAddExprImpl(BINARY_ADD_EXPR)
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('123')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.OP_PLUS)('+')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('23')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('; hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
Assembly File: a.asm
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAsmInstructionImpl(ASM_INSTRUCTION)
|
||||
M68kAsmOpImpl(ASM_OP)
|
||||
PsiElement(M68kTokenType.MNEMONIC)('add')
|
||||
M68kOperandSizeImpl(OPERAND_SIZE)
|
||||
PsiElement(M68kTokenType.OPSIZE_W)('.w')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kImmediateDataImpl(IMMEDIATE_DATA)
|
||||
PsiElement(M68kTokenType.HASH)('#')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('234')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE)
|
||||
M68kDataRegisterImpl(DATA_REGISTER)
|
||||
PsiElement(M68kTokenType.DREG)('d0')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('; hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
Assembly File: a.asm
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kMacroCallImpl(MACRO_CALL)
|
||||
PsiElement(M68kTokenType.MACRO_INVOKATION)('PUSHM')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.STRINGLIT)('d0')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.STRINGLIT)('d0')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('; hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
||||
Reference in New Issue
Block a user