Fixed syntax error for files ending on non-empty line

This commit is contained in:
Chris Hodges 2021-07-26 10:59:40 +02:00
parent 3165d99fc2
commit 82feb8c43c
6 changed files with 30 additions and 13 deletions

View File

@ -71,9 +71,10 @@ make it work with JUnit 5. Feel free to use the code (in package ```de.platon42.
### V0.2 (unreleased)
- Added (same) icon for plugin as for file type.
- Cosmetics: Added (same) icon for plugin as for file type.
- Performance improvement: Use Word-Index for global labels and symbols instead of iterating over the file.
- Performance improvement: Use Stub-Index for global labels and symbols.
- Bugfix: No longer reports a syntax error when file lacks terminating End-Of-Line
### V0.1 (20-Jul-21)

View File

@ -48,9 +48,10 @@ patchPluginXml {
setChangeNotes("""
<h4>V0.2 (xx-Jul-21)</h4>
<ul>
<li>Added (same) icon for plugin as for file type.
<li>Cosmetics: Added (same) icon for plugin as for file type.
<li>Performance improvement: Use Word-Index for global labels and symbols instead of iterating over the file.
<li>Performance improvement: Use Stub-Index for global labels and symbols.
<li>Bugfix: No longer reports a syntax error when file lacks terminating End-Of-Line
</ul>
<h4>V0.1 (20-Jul-21)</h4>
<ul>

View File

@ -1051,14 +1051,14 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// !<<eof>> statement EOL
// !<<eof>> statement (<<eof>>|EOL)
static boolean line(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "line")) return false;
boolean r;
Marker m = enter_section_(b);
r = line_0(b, l + 1);
r = r && statement(b, l + 1);
r = r && consumeToken(b, EOL);
r = r && line_2(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
@ -1073,6 +1073,17 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
// <<eof>>|EOL
private static boolean line_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "line_2")) return false;
boolean r;
Marker m = enter_section_(b);
r = eof(b, l + 1);
if (!r) r = consumeToken(b, EOL);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// Assignment
// | PreprocessorDirective

View File

@ -118,7 +118,7 @@
M68kFile ::= line*
private line ::= !<<eof>> statement EOL
private line ::= !<<eof>> statement (<<eof>>|EOL)
statement ::= (Assignment
| PreprocessorDirective

View File

@ -13,13 +13,14 @@ internal class BasicAsmInstTest : AbstractParsingTest() {
@ParserResultFile("basic_block_of_code")
internal fun parser_can_parse_basic_block_of_code(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(
testCase, "\tadd.l d0,d0\n"
+ "\tmoveq #10,d1\n"
+ " rts\n"
+ "\n"
+ "; comment\n"
+ " jmp\tresetcode ; unreachable\n"
+ " \n"
testCase, "\tadd.l d0,d0\n"
+ "\tmoveq #10,d1\n"
+ " rts\n"
+ "\n"
+ "; comment\n"
+ " jmp\tresetcode ; unreachable\n"
+ " \n"
+ "eoflabel"
)
}
}

View File

@ -53,4 +53,7 @@ Assembly File: a.asm
PsiComment(M68kTokenType.COMMENT)('; unreachable')
PsiElement(M68kTokenType.EOL)('\n')
PsiWhiteSpace(' ')
PsiWhiteSpace('\n')
PsiWhiteSpace('\n')
M68kStatementImpl(STATEMENT)
M68kGlobalLabelImpl(GLOBAL_LABEL)
PsiElement(M68kTokenType.GLOBAL_LABEL_DEF)('eoflabel')