SkillAgentSearch skills...

ANIL

ANIL(A Nice Intermediate Language) Python & C++ inspired programming language that transpiles to C and can be embedded within C source files.

Install / Use

/learn @AnilBK/ANIL
About this skill

Quality Score

0/100

Supported Platforms

Universal

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
  1. 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 @static Annotation for static functions
  • Standard Library: See Lib/. Shows mixing of C code and ANIL.
  • Windows UI FrameWork: See Todo App Example
  • Windows UI App using JSX like syntax: See Todo App JSX like Syntax Example
  • Windows Web Server: See Todo App Web Server Example
  • Function Pointers: See Example
  • Threads & Channel: See Example
  • Dunder methods:
    • __init__ : To implement constructors.
    • __del__ : To implement destructors. For automatic destructor call for a struct member(if it has a destructor), use the ~ operator. Lookup _call_destructor_for_element() in Vector
    • __str__: To print a given object with print(). It should return str(char*).
    • __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.
View on GitHub
GitHub Stars63
CategoryDevelopment
Updated18d ago
Forks2

Languages

C

Security Score

80/100

Audited on Mar 9, 2026

No findings