https://github.com/AnilBK/C-Preprocessor-Language Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} AnilBK / ANIL Public * Notifications You must be signed in to change notification settings * Fork 1 * Star 38 ANIL(A Nice Intermediate Language) Python & C++ inspired programming language that transpiles to C and can be embedded within C source files. 38 stars 1 fork Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights AnilBK/ANIL main BranchesTags [ ] Go to file Code Folders and files Last Last Name Name commit commit message date Latest commit History 365 Commits Bootstrap Bootstrap Lib Lib examples examples .gitignore .gitignore ErrorHandler.py ErrorHandler.py Parser.py Parser.py README.md README.md batch_compile.py batch_compile.py input_variables_gui_manager.py input_variables_gui_manager.py lexer.py lexer.py preprocess_2.py preprocess_2.py View all files Repository files navigation * README A Nice Intermediate Language(ANIL) ANIL is a statically typed programming language, inspired by Python and C++, that can be embedded within C source files. ss1 Fig: ANIL functions written in C and ANIL respectively. The first function written in C is the general implementation for the __contains__ method whereas the second function written in ANIL is template specialization for String class. ANIL generates appropriate C code, which is then compiled using a C compiler. ss2 Fig: The generated C code from the second __contains__ method in the first screenshot. Requirements: * C compiler. * Python. * clang-format(Recommended). Usage 1. Open preprocess_2.py. 2. Uncomment one of the source_file = "FILE_NAME*.c" line. 3. Run python preprocess_2.py Alternatively, you can specify the filename directly by running: python preprocess_2.py --filename examples\FILE_NAME*.c 4. This will generate a FILE_NAME*_generated.c file. Compile the generated c file using a C compiler and execute the generated executable. Features: * Classes: Example 1 Example 2 * Templates & Function Overloading: Example * Macros: Example * Compile-Time Reflection: Example 1 * Annotations: Example 1 WebSever Example * Standard Library: See Lib/. Shows mixing of C code and ANIL. * Dunder methods: + __init__ : To implement constructors. + __del__ : To implement destructors. + __getitem__ : To get an item at a specified index (e.g. obj [index]). + __setitem__ : To set an item at a specified index (e.g. obj [index] = value). + __reassign__ : To implement reassignment (e.g. obj = value). + __add__ : To implement addition. + __contains__ : To implement in operator (e.g value in list). + len : To get total number of items. It is used along with __getitem__ to implement iterators. The examples in examples/ and Lib/ folder shows all different features of ANIL. Right now, these examples serve as documentation for the language. Project Structure Directories * Bootstrap: Implementation of the compiler in ANIL itself. Files in this directory uses all (advanced) features available in the language. * examples: Demonstrations of various language features and usage of the standard library. * Lib: Standard Library. Individual Files * preprocess_2.py: The actual compiler and code generator. * batch_compile.py: Compiles all the ANIL files one by one. Used to verify if the changes made to the compiler doesn't break existing functionality. --------------------------------------------------------------------- Note This is my first ever compiler project. I created this compiler for the following reasons: 1. To learn about compiler development. 2. To build a self-compiling compiler. 3. To implement features I find interesting and cool. About ANIL(A Nice Intermediate Language) Python & C++ inspired programming language that transpiles to C and can be embedded within C source files. Resources Readme Activity Stars 38 stars Watchers 3 watching Forks 1 fork Report repository Releases No releases published Languages * Python 52.9% * C 47.1% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.