parser: rename main function to __rayoko_main

This commit is contained in:
Luna 2019-09-29 12:46:31 -03:00
parent f00741deca
commit 88e505b524
4 changed files with 11 additions and 2 deletions

View file

@ -30,5 +30,5 @@ fn add(a: i32, b: i32) i32 {
}
fn main() i32 {
return 0;
return 1;
}

BIN
hello

Binary file not shown.

3
src/entry.c Normal file
View file

@ -0,0 +1,3 @@
int main(void) {
__rayoko_main();
}

View file

@ -464,7 +464,13 @@ pub const Parser = struct {
method = try self.parsePreMethod();
}
const name = try self.consumeSingle(.Identifier);
const orig_name = try self.consumeSingle(.Identifier);
const name = if (std.mem.eql(u8, orig_name.lexeme, "main")) blk: {
break :blk try self.mkToken(.Identifier, "__rayoko_main", orig_name.line);
} else blk: {
break :blk orig_name;
};
self.setErrContext("function {}", name.lexeme);