Fixed syntax error for files ending on non-empty line
This commit is contained in:
parent
3165d99fc2
commit
82feb8c43c
@ -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)
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -118,7 +118,7 @@
|
||||
|
||||
M68kFile ::= line*
|
||||
|
||||
private line ::= !<<eof>> statement EOL
|
||||
private line ::= !<<eof>> statement (<<eof>>|EOL)
|
||||
|
||||
statement ::= (Assignment
|
||||
| PreprocessorDirective
|
||||
|
@ -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"
|
||||
)
|
||||
}
|
||||
}
|
@ -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')
|
Loading…
Reference in New Issue
Block a user