DEV Community

Yash Arya
Yash Arya

Posted on

Ion+: An experimental low-level language with indentation scoping written in Python (Seeking feedback on AST & frontend design)

Hi everyone,

I've been working on a compiler hobby project called Ion+. The project explores combining low-level systems programming concepts (typed variables, manual memory handling, hardware-level control) with a clean, indentation-based syntax.

The entire compiler frontend is written from scratch in Python to keep the pipeline clear, modular, and accessible before targeting an LLVM backend.

What the Syntax Looks Like

struct Node:
   int node_id
   ptr char ip_address
   bool is_active
   byte latency

const unsigned int MAX_RETRIES = 5

alloc ptr buffer = addr MAX_RETRIES

?int Node.connect():
    if not network_ready:
        return none

    int attempts = 0
    while attempts < MAX_RETRIES:
        if hardware.ping() == True:
            return 1
        attempts += 1
    return 0
Enter fullscreen mode Exit fullscreen mode

Current Pipeline & Implementation

The compiler frontend currently covers stages 1 through 4:

  • Lexing & Scanning: Regex-based tokenizer identifying keywords, types (int, byte, ptr, none), modifiers (const, volatile, atomic, alloc), operators, and literals.
  • Indentation Handling: Post-lexer stream processor that tracks indentation depth and automatically injects explicit INDENT and DEDENT tokens for block boundaries.
  • AST Construction: Explicit node definitions (nodes.py) representing program structures, typed variable declarations, member/call expressions, conditionals, and loops.
  • Parser: Recursive descent parser (core_parser.py) converting token streams into a structured AST ready for semantic analysis.

What You Can Test Right Now

  • Parsing source files directly using the .ionx extension.
  • Inspecting token streams and generated AST structures via main.py.
  • Experimenting with typed variable declarations, structs, and control-flow blocks.

Looking for Contributors & Feedback

Ion+ is open source and licensed under the MIT License.

Contributions, feedback, and discussions are welcome across multiple areas:

Feel free to check out the repository, try the code, open issues, or share your thoughts!

Top comments (0)