From 3b0db63e006dacc102c02d729b8100977e3c1d51 Mon Sep 17 00:00:00 2001 From: ahmedsamyh Date: Mon, 21 Oct 2024 13:28:36 +0500 Subject: [PATCH] Change some minor syntax things... --- main.momo | 2 +- main.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/main.momo b/main.momo index aabfb08..fa7f294 100644 --- a/main.momo +++ b/main.momo @@ -1,6 +1,6 @@ // # import "stdio"; -func main(int argc, string argv[]): int { +func main(argc: int, argv: string[]): int { print("Hello, World!"); return 0; } diff --git a/main.py b/main.py index da893f3..6eceb80 100644 --- a/main.py +++ b/main.py @@ -183,7 +183,6 @@ class Lexer: else: raise Exception(f"Unexpected symbol '{symbol}'") - return token elif c == '"': return Token(Token_Type.STRING, self.consume_string()) @@ -197,15 +196,23 @@ def main(): 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() -- 2.39.5