// # import "stdio";
-func main(int argc, string argv[]): int {
+func main(argc: int, argv: string[]): int {
print("Hello, World!");
return 0;
}
else:
raise Exception(f"Unexpected symbol '{symbol}'")
-
return token
elif c == '"':
return Token(Token_Type.STRING, self.consume_string())
if (len(sys.argv) <= 0):
raise Exception("Please provide the filename!")
filename = sys.argv.pop(0)
+ # 1. Source
src = ""
with open(filename, mode='r') as file:
src = file.read()
+
+ # 2. Lexical Analysis
lexer = Lexer(src)
+ tokens = []
token = lexer.next_token()
while token:
- dlog(token)
+ tokens.append(token)
token = lexer.next_token()
+ pprint.pp(tokens)
+
+ # 3. TODO: Syntactical Analysis
+
if __name__ == '__main__':
main()