Skip to content

SilvesterHsu/AstroParse

Repository files navigation

AstroParse — Code to Cosmic JSON 🚀

License: MIT Docker Image

Turn C++ code into LLM-digestible JSON – because AI deserves X-ray vision for code! Powered by Clang AST dissection, Bazel/Docker industrial pipelines, and JSON that pleases both machines and humans.


🔥 Features

  • C++ AST → JSON: Surgical precision with Clang's parsing scalpel
  • Bazel Builds: Industrial-grade compilation with dependency isolation
  • Docker in One Shot: No dependency hell – just warp-speed deployment
  • Pre-built Binaries: For rebels who hate compiling from source

🛠 Installation

Prerequisites

  • Docker (recommended)
  • Linux (Windows warriors: WSL2 required)

Pre-built Release (For Binary Cowboys)

./astroparse-linux-amd64 your_code.cpp 

Build from source

Init docker container for build

./docker.sh init

Enter the build env

./docker.sh

Build the code

./scripts/build.sh

Generate AST json for example

Gen compile_commands.json

./scripts/update_compile_commands.sh

Get AST json file

./bazel-bin/astroparse/astroparse /AstroParse/parse/util.cc

🚀 Demo

Input: demo.cpp

#include <iostream>  
class SpaceShip {  
public:  
    void launch() { std::cout << "3...2...1...Ignition!\n"; }  
};  

Output: ast.json (snippet)

{  
  "AST": {  
    "type": "TranslationUnitDecl",  
    "children": [  
      {  
        "type": "ClassDecl",  
        "name": "SpaceShip",  
        "methods": [  
          {  
            "type": "CXXMethodDecl",  
            "name": "launch",  
            "body": "CompoundStmt"  
          }  
        ]  
      }  
    ]  
  }  
}  

📡 Architecture

[Your C++ Code] → Clang Frontend → AST → Custom Traverser → JSON Serializer → [Feed to LLMs/Tools]  

🤖 Contributing

  1. Fork This Repo: Clone your personal universe branch
  2. Code Style: Follow .clang-format – follow Google style
  3. Tests: All PRs must pass ./scripts/test.sh

⚖️ License

MIT License – Details at LICENSE


Crafted with ❤️ and Clang by Seel.Xu

“Any sufficiently advanced code parser is indistinguishable from magic.” – Arthur C. Clarke (remixed)

About

Turn C++ code into LLM-digestible JSON

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published