Skip to content

Commit 53e30fa

Browse files
committed
Add EOF matching
1 parent 74716b7 commit 53e30fa

5 files changed

Lines changed: 69 additions & 156 deletions

File tree

.idea/workspace.xml

Lines changed: 52 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/ko/carbonel/compiler/ParserAssistant.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public boolean peek(TokenType... types) {
7171
public void parse() {
7272
try {
7373
matchTokenprogram();
74+
match(TokenType.EOF); // Assert EOF
7475
} catch (StackOverflowError e) {
7576
throw new CompilerError(lexer.peek().location(), "Stack overflow error. You probably gave me code that is too large :c.");
7677
}
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
/* No Errors */
2-
class A {
3-
create(){
4-
(false || ((nil)));
5-
}
6-
fn setB(I32: i) -> I32 {
7-
}
8-
fn setB(I32: i, I32: v) -> void {
9-
}
1+
/* MatchMismatchError(EOF, CLASS) */
2+
/* @:9 */
3+
class A{
4+
105
}
116
fn main(){
12-
I32: a;
7+
8+
}
9+
class B{
10+
1311
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
/* UnexpectedTokenError(ATTR_ID, CLASS_ID, STR, BOOL, CHR, INT) */
2-
/* @:5 */
1+
/* MatchMismatchError(EOF, FN) */
2+
/* @:9 */
33
class A{
4-
fn a(Array I32: bnf) -> I32 {
5-
luna = new cat; // <3
6-
}
4+
75
}
8-
fn main() {
9-
I32 : int;
6+
fn main(){
7+
8+
}
9+
fn main(){
10+
1011
}

src/test/resources/syntax/main2.bnf

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)