Fixed syntax error for files ending on non-empty line
This commit is contained in:
@@ -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')
|
||||
Reference in New Issue
Block a user