Added M68kLexerPrefs (preliminary). Added support for optional space-introducing comments.

This commit is contained in:
2021-07-17 16:49:50 +02:00
parent 618a4eee01
commit 349372f6b3
17 changed files with 771 additions and 536 deletions
@@ -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")
}
}