Ensure main function is named correctly
This commit is contained in:
parent
837b7018b9
commit
70528858cc
1 changed files with 3 additions and 0 deletions
|
|
@ -50,6 +50,9 @@ public class Parser {
|
||||||
private FunctionTree parseFunction() {
|
private FunctionTree parseFunction() {
|
||||||
Keyword returnType = this.tokenSource.expectKeyword(KeywordType.INT);
|
Keyword returnType = this.tokenSource.expectKeyword(KeywordType.INT);
|
||||||
Identifier identifier = this.tokenSource.expectIdentifier();
|
Identifier identifier = this.tokenSource.expectIdentifier();
|
||||||
|
if (!identifier.value().equals("main")) {
|
||||||
|
throw new ParseException("expected main function but got " + identifier);
|
||||||
|
}
|
||||||
this.tokenSource.expectSeparator(SeparatorType.PAREN_OPEN);
|
this.tokenSource.expectSeparator(SeparatorType.PAREN_OPEN);
|
||||||
this.tokenSource.expectSeparator(SeparatorType.PAREN_CLOSE);
|
this.tokenSource.expectSeparator(SeparatorType.PAREN_CLOSE);
|
||||||
BlockTree body = parseBlock();
|
BlockTree body = parseBlock();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue