From: ahmedsamyh Date: Mon, 18 Nov 2024 17:24:13 +0000 (+0500) Subject: Update README.md X-Git-Url: https://www.git.momoyon.org/?a=commitdiff_plain;h=d192cf467017f0048e0e25e6171fb1eb3aff3150;p=lang.git Update README.md --- diff --git a/README.md b/README.md index 9cace29..4387b54 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,28 @@ -# Language (unnamed) +# C+ (WIP name) -Programming Language. +A Programming Language like the [C Programming Language](https://en.wikipedia.org/wiki/C_(programming_language)) that adds some useful features, different syntax, etc that ultimately transpiles to C itself. + +## Goals + +- [x] Lexical Analysis (Generate Tokens from source file) +- [ ] Parsing (Generate a Syntax Tree from the Tokens) +- [ ] Convert C+ syntax to C syntax +- [ ] Call C compiler and linker to create the executable +- [ ] Success!!! + +## Why? + +I mainly program using C because of its simpilicty. But some features are kinda bad and some even missing such as defer, shitty macros(preprocessor), shitty variadic functions, etc. + +- Why not use [C++](https://en.wikipedia.org/wiki/C%2B%2B), doesn't it basically solve all those problems? + +Because i don't like feel like its a good language... I'm not an big [OOP](https://en.wikipedia.org/wiki/Object-oriented_programming) person and don't get me started on the mess that is called the [templates](https://en.wikipedia.org/wiki/Template_(C%2B%2B)). Anyways i won't use C++ as my main language and i'm not quite satisfied with C, so i wondered "why don't i make my own language that adds these features to C?". And that's what i'm trying to do with this project. I'm not talking about creating a completely new programming language from scratch, just change some syntax of C, add these new features and make some of it better. This is also a great exercise to further increase my wisdom of computers. + +TL;DR: +- I like C but quite not, (don't likey C++) so create C+ that is in the middle. +- Good opportunity to learn how a programming language works. +- Because it's fun. + +## References + +- [Book im reading(The dragon book)](https://drive.google.com/file/d/0B1MogsyNAsj9elVzQWR5NWVTSVE/view?pli=1&resourcekey=0-zoBDMpzTafr6toxDuQLNUg) diff --git a/main.py b/main.py index 1f1d1c6..9a342ba 100644 --- a/main.py +++ b/main.py @@ -304,7 +304,7 @@ class Parser: return None - def parse(self) -> [Token]: + def lex(self) -> [Token]: tokens: [Token] = [] token = self.next_token() while token != None: @@ -323,8 +323,8 @@ def main(): filename: str = sys.argv.pop(0) parser = Parser(filename) - - tokens = parser.parse() + # Lexical Analysis + tokens = parser.lex() for t in tokens: pprint.pp(str(t))